deploy a complicate application group
guestbook.yaml
apiVersion: v1
kind: Service
metadata:
name: redis-master
labels:
app: redis
tier: backend
role: master
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
tier: backend
role: master
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis-master
spec:
replicas: 1
template:
metadata:
labels:
app: redis
role: master
tier: backend
spec:
containers:
- name: master
image: gcr.io/google_containers/redis:e2e # or just image: redis
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
name: redis-slave
labels:
app: redis
tier: backend
role: slave
spec:
ports:
- port: 6379
selector:
app: redis
tier: backend
role: slave
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis-slave
spec:
replicas: 2
template:
metadata:
labels:
app: redis
role: slave
tier: backend
spec:
containers:
- name: slave
image: gcr.io/google_samples/gb-redisslave:v1
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# If your cluster config does not include a dns service, then to
# instead access an environment variable to find the master
# service's host, comment out the 'value: dns' line above, and
# uncomment the line below:
# value: env
ports:
- containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
type: NodePort
ports:
- port: 80
selector:
app: guestbook
tier: frontend
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: frontend
spec:
replicas: 3
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google-samples/gb-frontend:v4
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# If your cluster config does not include a dns service, then to
# instead access environment variables to find service host
# info, comment out the 'value: dns' line above, and uncomment the
# line below:
# value: env
ports:
- containerPort: 80
the application contains frontend with 3 pods and redis cluster as backend.
localhost:~ xunyang$ kubectl create -f guestbook.yaml
service "redis-master" created
deployment.extensions "redis-master" created
service "redis-slave" created
deployment.extensions "redis-slave" created
service "frontend" created
deployment.extensions "frontend" created
localhost:~ xunyang$ kubectl get all
NAME READY STATUS RESTARTS AGE
frontend-5c548f4769-4xcj6 1/1 Running 0 9m
frontend-5c548f4769-c74tg 1/1 Running 0 9m
frontend-5c548f4769-xzrfg 1/1 Running 0 9m
redis-master-6c46f6cfb8-xktwx 1/1 Running 0 9m
redis-slave-584c66c5b5-6lnkj 1/1 Running 0 9m
redis-slave-584c66c5b5-ggdqp 1/1 Running 0 9m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
frontend NodePort 10.96.27.12 <none> 80:31784/TCP 9m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 11m
redis-master ClusterIP 10.97.97.230 <none> 6379/TCP 9m
redis-slave ClusterIP 10.101.33.203 <none> 6379/TCP 9m
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
frontend 3 3 3 3 9m
redis-master 1 1 1 1 9m
redis-slave 2 2 2 2 9m
NAME DESIRED CURRENT READY AGE
frontend-5c548f4769 3 3 3 9m
redis-master-6c46f6cfb8 1 1 1 9m
redis-slave-584c66c5b5 2 2 2 9m
check the application status
minikube service frontend
submit your comments in the web browser.