Manually Schedule Deployment Pods on a Specific Node
Scenario
A namespace named gcp already exists in the Kubernetes cluster. Your task is to deploy an application, manually schedule it on a specific node, and expose it externally using a NodePort Service.
Task
Create a Deployment named cloud-run in the gcp namespace with the following specifications:
- Use the container image
gcr.io/cloudrun/hello - Run
3replicas - Expose port
8080viacontainerPort - Ensure all Pods have the label
gcp-service=cloud-runand the Service selector matches this label to route traffic correctly. - Schedule all Pods manually on node
node-02
Once the Deployment is created, expose it using a Service named cloud-run-service with the NodePort type so the application can be accessed externally.
Finally, verify the Deployment and Pods are running, the Service is created, and identify the NodePort assigned to access the application.
# Test whether the application is accessible
curl -s cplane-01:<NodePort>
Hint 1
Schedule all Pods manually on node node-02 using nodeName under spec.template.spec.
See the official docs: Assign Pods to Nodes