Chapter 7 – Demystifying Kubernetes networking
You have two virtual machines: master-0
and worker-0
. Please complete the following mock scenarios.
Scenario 1
Deploy a new deployment nginx with the latest image of nginx for 2 replicas, in a namespace called packt-app
. The container is exposed on port 80
. Create a service type ClusterIP within the same namespace. Deploy a sandbox-nginx pod and make a call using curl
to verify the connectivity to the nginx service.
Use the following command to create nginx deployment in the targeting namespace:
kubectl create deployment nginx --image=nginx --replicas=2 -n packt-app
Use the following command to expose nginx deployment with a ClusterIP service in the targeting namespace:
kubectl expose deployment nginx --type=ClusterIP --port 8080 --name=packt-svc --target-port 80 -n packt-app
Use the following command to get the internal IP:
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?( @.type==...