# Create two namespaces and name them ns1 and ns2 ```bash k create ns ns1 k create ns ns2 ``` # Create a deployment with a single replica in each of these namespaces with the image as nginx and name as deploy-ns1 and deploy-ns2, respectively ```bash k create deployment deploy-ns1 --image=nginx --replicas=1 -n ns1 k create deployment deploy-ns2 --image=nginx --replicas=1 -n ns2 ``` # Get the IP address of each of the pods (Remember the kubectl command for that?) ```bash k get po -n ns1 -o wide k get po -n ns2 -o wide ``` # Exec into the pod of deploy-ns1 and try to curl the IP address of the pod running on deploy-ns2 ```bash k exec -it -n ns1 deploy-ns1-56c4d4b7-xzvl2 -- sh curl 10.244.2.4 ``` # Your pod-to-pod connection should work, and you should be able to get a successful response back. ```html Welcome to nginx!

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

``` # Now scale both of your deployments from 1 to 3 replicas. ```bash k scale --replicas=3 -n ns1 deploy/deploy-ns1 k scale --replicas=3 -n ns2 deploy/deploy-ns2 ``` ``` deploy-ns1-56c4d4b7-xzvl2 10.244.2.3 kind-worker2 deploy-ns2-846f6b4c9b-r85f7 10.244.2.4 kind-worker2 ``` # Create two services to expose both of your deployments and name them svc-ns1 and svc-ns2 ```bash k expose deployment deploy-ns1 -n ns1 --port=80 --target-port=80 k expose deployment deploy-ns2 -n ns2 --port=80 --target-port=80 ``` # exec into each pod and try to curl the IP address of the service running on the other namespace. ```bash k exec -it deploy-ns1-56c4d4b7-4tptj -n ns1 -- sh curl 10.244.1.6 k exec -it deploy-ns2-846f6b4c9b-7dqwf -n ns2 -- sh curl 10.244.1.4 ``` # This curl should work. ``` Yes ``` # Now try curling the service name instead of IP. You will notice that you are getting an error and cannot resolve the host. ```bash in deploy-ns2-846f6b4c9b-7dqwf: curl deploy-ns1-56c4d4b7-4tptj not work curl deploy-ns2-846f6b4c9b-7dqwf works ``` # Now use the FQDN of the service and try to curl again, this should work. ```bash curl deploy-ns1.ns1.svc.cluster.local works ``` # In the end, delete both the namespaces, which should delete the services and deployments underneath them. ```bash k delete svc deploy-ns1 -n ns1 k delete svc deploy-ns2 -n ns2 k delete deployment deploy-ns1 -n ns1 k delete deployment deploy-ns2 -n ns2 k delete ns ns1 ns2 ```