Deploy example application to Kubernetes


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
kubectl apply -f

For redis slave

kubectl apply -f
kubectl apply -f

Deploy frontend app

kubectl apply -f
kubectl apply -f

The result redis-master, redis-slave and guestbook created

kubectl get replicationcontroller
# The output as below
$ kubectl get replicationcontroller
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   3000:32767/TCP   2m25s
service/kubernetes     ClusterIP       <none>                                                                   443/TCP          52m
service/redis-master   ClusterIP     <none>                                                                   6379/TCP         4m24s
service/redis-slave    ClusterIP   <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)

Note: ELB is ready in 3-5 minutes


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


About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.