#Introduction
In this tutorial, How to deploy example application to Kubernetes.
Deploy example application to Kubernetes
Fronted application
- load balanced by public ELB
- read request load balanced to multiple slaves
- write request to a single master
Backend example Redis
- single master (write)
- multi slaves (read)
- slaves sync continuously from master
Deploy Redis Master and Redis Slave
For Redis Master
kubectl apply -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook-go/redis-master-controller.json
kubectl apply -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook-go/redis-master-service.json
For redis slave
kubectl apply -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook-go/redis-slave-controller.json
kubectl apply -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook-go/redis-slave-service.json
Deploy frontend app
kubectl apply -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook-go/guestbook-controller.json
kubectl apply -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook-go/guestbook-service.json
The result redis-master, redis-slave and guestbook created
kubectl get replicationcontroller
# The output as below
$ kubectl get replicationcontroller
NAME DESIRED CURRENT READY AGE
guestbook 3 3 3 2m13s
redis-master 1 1 1 4m32s
redis-slave 2 2 2 3m10s
Get service and pod
kubectl get pod,service
The output terminal
$ kubectl get pod,service
NAME READY STATUS RESTARTS AGE
pod/guestbook-tnc42 1/1 Running 0 2m33s
pod/guestbook-vqgws 1/1 Running 0 2m33s
pod/guestbook-vqnxf 1/1 Running 0 2m33s
pod/redis-master-dp7h7 1/1 Running 0 4m52s
pod/redis-slave-54mt6 1/1 Running 0 3m30s
pod/redis-slave-8g8h4 1/1 Running 0 3m30s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/guestbook LoadBalancer 10.100.231.216 aff3d414c479f4faaa2ab82062c87fe5-264485147.us-west-2.elb.amazonaws.com 3000:32767/TCP 2m25s
service/kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 52m
service/redis-master ClusterIP 10.100.76.16 <none> 6379/TCP 4m24s
service/redis-slave ClusterIP 10.100.126.163 <none> 6379/TCP 3m25s
Show external ELB DNS
echo $(kubectl get svc guestbook | awk '{ print $4 }' | tail -1):$(kubectl get svc guestbook | awk '{ print $5 }' | tail -1 | cut -d ":" -f 13000)
The output terminal
$ echo $(kubectl get svc guestbook | awk '{ print $4 }' | tail -1):$(kubectl get svc guestbook | awk '{ print $5 }' | tail -1 | cut -d ":" -f 13000)
aff3d414c479f4faaa2ab82062c87fe5-264485147.us-west-2.elb.amazonaws.com:
Note: ELB is ready in 3-5 minutes
Conclusion
You have to Deploy example application to Kubernetes. we will expose these pods with Ingress the post later. I hope will this your helpful. Thank you for reading the DevopsRoles page! Refer source