Deploy Guest Book App on Kubernetes
I’m a hands-on software engineer with over 18 years of experience solving real-world problems with code. I’ve spent most of that time building web applications, backend systems, and automation tools — often using Python, Django, REST, and a healthy mix of SQL and shell scripts on Linux.
Along the way, I’ve also picked up frontend work with Angular and React, and built infrastructure using Docker, Kubernetes, AWS, and Terraform. I wouldn’t call myself a DevOps engineer, but I do believe in owning the full stack — from writing the API to making sure it runs smoothly in production.
I’ve worked in all kinds of teams — large, small, remote, distributed, fast-paced, slow-paced. For the last few years, I’ve been freelancing, which has been both freeing and demanding in the best possible way. It’s pushed me to keep learning, stay sharp, and step outside my comfort zone. I love the mix of flexibility and challenge it brings.
This is part five of a series of lab tasks from KodeKloud for Kubernetes level 4. Master blog listing all parts can be seen here. Make sure to follow setup instructions for minikube on your PC.
Problem with Inline Solutions
The Nautilus Application development team has finished development of one of the applications and it is ready for deployment. It is a guestbook application that will be used to manage entries for guests/visitors. As per discussion with the DevOps team, they have finalized the infrastructure that will be deployed on Kubernetes cluster. Below you can find more details about it.
BACK-END TIER
Create a deployment named
redis-masterfor Redis master.a.) Replicas count should be
1.b.) Container name should be
master-redis-xfusionand it should use imageredis.c.) Request resources as CPU should be
100mand Memory should be100Mi.d.) Container port should be redis default port i.e
6379.apiVersion: apps/v1 kind: Deployment metadata: name: redis-master spec: replicas: 1 selector: matchLabels: app: redis-master tier: back-end template: metadata: labels: app: redis-master tier: back-end spec: containers: - name: master-redis-xfusion image: redis resources: requests: memory: "100Mi" cpu: "100m" ports: - containerPort: 6379Create a service named
redis-masterfor Redis master. Port and targetPort should be Redis default port i.e6379.apiVersion: v1 kind: Service metadata: name: redis-master spec: type: ClusterIP selector: app: redis-master tier: back-end ports: - port: 6379 targetPort: 6379Create another deployment named
redis-slavefor Redis slave.a.) Replicas count should be
2.b.) Container name should be
slave-redis-xfusionand it should usegcr.io/google_samples/gb-redisslave:v3image.c.) Requests resources as CPU should be
100mand Memory should be100Mi.d.) Define an environment variable named
GET_HOSTS_FROMand its value should bedns.e.) Container port should be Redis default port i.e
6379.apiVersion: apps/v1 kind: Deployment metadata: name: redis-slave spec: replicas: 2 selector: matchLabels: app: redis-slave tier: back-end template: metadata: labels: app: redis-slave tier: back-end spec: containers: - name: slave-redis-xfusion image: gcr.io/google_samples/gb-redisslave:v3 resources: requests: memory: "100Mi" cpu: "100m" env: - name: GET_HOSTS_FROM value: dns ports: - containerPort: 6379Create another service named
redis-slave. It should use Redis default port i.e6379.apiVersion: v1 kind: Service metadata: name: redis-slave spec: type: ClusterIP selector: app: redis-slave tier: back-end ports: - port: 6379 targetPort: 6379
FRONT END TIER
Create a deployment named
frontend.a.) Replicas count should be
3.b.) Container name should be
php-redis-xfusionand it should usegcr.io/google-samples/gb-frontend@sha256:cbc8ef4b0a2d0b95965e0e7dc8938c270ea98e34ec9d60ea64b2d5f2df2dfbbfimage.c.) Request resources as CPU should be
100mand Memory should be100Mi.d.) Define an environment variable named as
GET_HOSTS_FROMand its value should bedns.e.) Container port should be
80.apiVersion: apps/v1 kind: Deployment metadata: name: frontend spec: replicas: 3 selector: matchLabels: app: guestbook tier: front-end template: metadata: labels: app: guestbook tier: front-end spec: containers: - name: php-redis-xfusion image: gcr.io/google-samples/gb-frontend@sha256:cbc8ef4b0a2d0b95965e0e7dc8938c270ea98e34ec9d60ea64b2d5f2df2dfbbf resources: requests: memory: "100Mi" cpu: "100m" env: - name: GET_HOSTS_FROM value: dns ports: - containerPort: 80Create a service named
frontend. Its type should be NodePort, port should be80and its nodePort should be30009.apiVersion: v1 kind: Service metadata: name: frontend spec: type: NodePort selector: app: guestbook tier: front-end ports: - port: 80 targetPort: 80 nodePort: 30009
Finally, you can check the guestbook app by clicking on App button.
You can use any labels as per your choice.
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.

