Question 01
Question - 1
You need to scale an existing deployment for availability and create a service to expose the deployment within your infrastructure. Task:
- Start with the deployment named
nov2025-deploymentwhich has already been deployed to the namespacenov2025. - Add the key/value label
func=webFrontendto the pod template metadata to identify the pods for the service definition. - Have 4 replicas.
-
Next, create and deploy in namespace
nov2025a Service that accomplishes the following: -
Is of type NodePort, and name Berry
- Exposes the service on TCP port 8080
- Mapped to pods defined by the specification of
nov2025-deployment
π¨ Common Mistakes / Traps
- Changing the Deployment selector instead of only adding a label to the pod template β this can break the Deployment (pods may not be recognized).
- Using the wrong label in Service selector β e.g., selecting
app=nov2025-appwhen you changed the label or selecting an incorrect label (func=webFrontend) mistakenly while pods donβt have it. - Forgetting to add the new label to the pod template (so Service selector fails).
- Forgetting to set replicas to 4 (exam may count it as failure).
- Incorrect port mapping (e.g., specifying service port 80 instead of 8080).
- Creating Service in wrong namespace.
- Using
ClusterIPinstead ofNodePort. - Not verifying Service
NodePortexists or is reachable.
π§ Step-by-step Solution Logic
kubectl edit deployment nov2025-deployment -n nov2025(or export, modify YAML)- In
spec.template.metadata.labels, addfunc: webFrontend - In the same Deployment, modify
spec.replicas: 4 - Save changes β check rollout status:
kubectl rollout status deployment/nov2025-deployment -n nov2025 - Create a Service manifest named
Berryin namespacenov2025, type NodePort, port 8080, selectorfunc=webFrontend. (EnsuretargetPortset to container port of pods; assume 8080 unless other given). - Apply the Service:
kubectl apply -f service-berry.yaml - Verify Service:
kubectl get svc Berry -n nov2025β checkType: NodePort,Port: 8080/TCP,NodePort: <someport> - Verify pods:
kubectl get pods -n nov2025 -l func=webFrontendβ should return 4 pods - Test connectivity (if permitted): from a node:
curl <NodeIP>:<NodePort>and expect HTTP response - Confirm everything is ready and matches requirements.
π Kubectl Commands
kubectl -n nov2025 edit deployment nov2025-deployment
kubectl -n nov2025 rollout status deployment/nov2025-deployment
kubectl expose deploy nov2025-deployment --type NodePort --port 8080 --selector func=webFrontend -n nov2025
kubectl -n nov2025 get svc Berry
kubectl -n nov2025 get pods -l func=webFrontend
# optional connectivity test:
# curl http://<node-ip>:<nodePort>
π Final YAML (exam-ready)
Deployment (modified)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nov2025-deployment
namespace: nov2025
spec:
replicas: 4
selector:
matchLabels:
app: nov2025-app
template:
metadata:
labels:
app: nov2025-app
func: webFrontend
spec:
containers:
- name: nov2025-container
image: nginx
ports:
- containerPort: 8080
Service (NodePort)
apiVersion: v1
kind: Service
metadata:
name: Berry
namespace: nov2025
spec:
type: NodePort
selector:
func: webFrontend
ports:
- protocol: TCP
port: 8080
targetPort: 8080