Three-Tier Guestbook Application Deployment on Kubernetes
Executive Summary
I have successfully deployed the required three-tier Guestbook application on the Kubernetes cluster. All six resources—three Deployments and three Services—were created and are now running correctly. The Redis master and slave tiers, along with the PHP frontend, are operational, and the application is exposed externally via the required NodePort 30009.
Deployment Execution and Manifest (guestbook-deployment.yaml)
The following unified YAML manifest (guestbook-deployment.yaml) was used to create all application components:
# ----------------------------------------------------
# BACK-END TIER: REDIS MASTER DEPLOYMENT
# ----------------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-master
labels:
app: redis
role: master
tier: backend
spec:
replicas: 1
selector:
matchLabels:
app: redis
role: master
template:
metadata:
labels:
app: redis
role: master
tier: backend
spec:
containers:
- name: master-redis-datacenter
image: redis
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 6379
---
# ----------------------------------------------------
# BACK-END TIER: REDIS MASTER SERVICE
# ----------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: redis-master
labels:
app: redis
role: master
tier: backend
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
role: master
---
# ----------------------------------------------------
# BACK-END TIER: REDIS SLAVE DEPLOYMENT
# ----------------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-slave
labels:
app: redis
role: slave
tier: backend
spec:
replicas: 2
selector:
matchLabels:
app: redis
role: slave
template:
metadata:
labels:
app: redis
role: slave
tier: backend
spec:
containers:
- name: slave-redis-datacenter
image: gcr.io/google_samples/gb-redisslave:v3
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 6379
---
# ----------------------------------------------------
# BACK-END TIER: REDIS SLAVE SERVICE
# ----------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: redis-slave
labels:
app: redis
role: slave
tier: backend
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
role: slave
---
# ----------------------------------------------------
# FRONT-END TIER DEPLOYMENT
# ----------------------------------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
replicas: 3
selector:
matchLabels:
app: guestbook
tier: frontend
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis-datacenter
image: gcr.io/google-samples/gb-frontend@sha256:a908df8486ff66f2c4daa0d3d8a2fa09846a1fc8efd65649c0109695c7c5cbff
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 80
---
# ----------------------------------------------------
# FRONT-END TIER SERVICE (NODEPORT)
# ----------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 30009
selector:
app: guestbook
tier: frontend
Deployment Execution and Verification
The following commands and their outputs confirm the successful creation and status of all components:
Execution Commands
| Command | Output |
|---|---|
thor@jumphost ~$ kubectl apply -f guestbook-deployment.yaml |
deployment.apps/redis-master createdservice/redis-master createddeployment.apps/redis-slave createdservice/redis-slave createddeployment.apps/frontend createdservice/frontend created
|
Deployment Health Check
| Command | Output |
|---|---|
thor@jumphost ~$ kubectl get deployments |
NAME READY UP-TO-DATE AVAILABLE AGEfrontend 3/3 3 3 50sredis-master 1/1 1 1 51sredis-slave 2/2 2 2 51s
|
Pod Status Check
| Command | Output |
|---|---|
thor@jumphost ~$ kubectl get pods |
NAME READY STATUS RESTARTS AGEfrontend-5dc567d575-9mfnq 1/1 Running 0 50sfrontend-5dc567d575-tmq4s 1/1 Running 0 50sfrontend-5dc567d575-xfxng 1/1 Running 0 50sredis-master-554f64dc8b-fwbt8 1/1 Running 0 51sredis-slave-bf4ff5dbf-krsb4 1/1 Running 0 51sredis-slave-bf4ff5dbf-r6h2q 1/1 Running 0 50s
|
Service and Networking Verification
| Command | Output |
|---|---|
thor@jumphost ~$ kubectl get services |
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEfrontend NodePort 10.96.58.65 <none> 80:30009/TCP 40skubernetes ClusterIP 10.96.0.1 <none> 443/TCP 11mredis-master ClusterIP 10.96.127.189 <none> 6379/TCP 41sredis-slave ClusterIP 10.96.34.8 <none> 6379/TCP 41s
|
The application is deployed and ready for access on NodePort 30009.
Top comments (0)