ClusterIP Exercise
Applications running in a Kubernetes cluster find and communicate with each other, and the outside world, through the Service abstraction
We are using a Nginx webserver that echoes back the source IP of requests it receives through an HTTP header.
Create a Nginx WebServer with echoserver Image
kubectl create deployment web-app --image=k8s.gcr.io/echoserver:1.4
Expose the echoserver Image pod with the help of a service.
kubectl expose deployment web-app --name=web-app-svc --port=80 --target-port=8080
Get the Service IP Address
kubectl get svc web-app-svc
Run a Client Server to test Cluster IP
kubectl run busybox -it --image=busybox --restart=Never --rm
Inside the Busy Box Image, we are going to run the below commands.
Check the IP Address of the Client.
ip addr
Use Wget to call the Web-app-svc from the Busybox Pod
Replace "10.0.170.92" with the IPv4 address of the Service named "web-app-svc"
wget -qO - 10.0.170.92
If you observe the output has "client_address"
The client_address is always the client pod's IP address, whether the client pod and server pod are in the same node or in different nodes
Run nslookup to the above web-app-svc to know the fully qualified domain name
Cleanup
Delete Service and Deployment
kubectl delete svc web-app-svc
kubectl delete deployment web-app
Last updated