Task Summary
SSH into cka000022 ✅
Modify an existing Deployment:
Create a Service:
✅ Step-by-Step Solution
1️⃣ SSH into the correct node
ssh cka000022
⚠️ Skipping this = zero score
2️⃣ Edit the Deployment to expose port 80
kubectl edit deployment front-end -n spline-reticulator
Under containers: → nginx, add this if not present:
ports:
- containerPort: 80
protocol: TCP
✅ This enables the container to accept traffic on port 80.
3️⃣ Create a NodePort Service
Create a file named front-end-svc.yaml:
cat < front-end-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: front-end-svc
namespace: spline-reticulator
spec:
type: NodePort
selector:
app: front-end
ports:
- port: 80
targetPort: 80
protocol: TCP
EOF
⚠️ Make sure the Deployment has a matching label selector like app: front-end. You can verify with:
kubectl get deployment front-end -n spline-reticulator -o yaml | grep labels -A 2
4️⃣ Apply the service
kubectl apply -f front-end-svc.yaml
5️⃣ Verify
Check if the service is created and has a NodePort assigned:
kubectl get svc front-end-svc -n spline-reticulator
✅ You should see something like:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
front-end-svc NodePort 10.96.0.123 80:3XXXX/TCP 10s
Where 3XXXX is your automatically assigned NodePort (between 30000–32767).
Final Command Summary
ssh cka000022
kubectl edit deployment front-end -n spline-reticulator
# Add:
# ports:
# - containerPort: 80
cat < front-end-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: front-end-svc
namespace: spline-reticulator
spec:
type: NodePort
selector:
app: front-end
ports:
- port: 80
targetPort: 80
protocol: TCP
EOF
kubectl apply -f front-end-svc.yaml
kubectl get svc front-end-svc -n spline-reticulator