Table of Contents
Introduction
Dive into the world of Kubernetes with our easy-to-follow guide on deploy example application to Kubernetes. Whether you’re a beginner or an experienced developer, this tutorial will demonstrate how to efficiently deploy and manage applications in a Kubernetes environment.
Learn how to set up your application with Kubernetes pods, services, and external load balancers to ensure scalable and resilient deployment.
Step-by-Step deploy example application to Kubernetes
Fronted application
- load balanced by public ELB
- read request load balanced to multiple slaves
- write a request to a single master
Backend example Redis
- single master (write)
- multi slaves (read)
- slaves sync continuously from the 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 an example application to Kubernetes. we will expose these pods with Ingress in the post later.
Congratulations on taking your first steps towards mastering application deployment with Kubernetes! By following this tutorial, you’ve gained valuable insights into the intricacies of Kubernetes architecture and how to leverage it for effective application management. Continue to explore and expand your skills, and don’t hesitate to revisit this guide or explore further topics on our website to enhance your Kubernetes expertise.
I hope will this your helpful. Thank you for reading the DevopsRoles page! Refer source