Kubernetes 101 : Exposing pods through a service for local access - Deployment, ClusterIP -



We first create a deployment for two replicas of the nginx pod using the below command:


Remark:

The above command might get deprecated in the upcoming versions of kubernetes
We could use a Yaml file to create a deployment instead.

After creating our deployment, we check its pods using the below command:


We could also check the services in our cluster, using the below command:


We check our deployment using the below command. It has two replicas of nginx pods running :


We expose our deployment on port "80":


Then we recheck our services using the below command:


We notice that a new ClusterIP service for our pods has been created.

We could see that our service "service/nginx-svc" is reachable on port "80" at the IP address "10.106.231.18".


We could access one of our pods through our service "service/nginx-svc" using the below command:

Comments

Leave as a comment:

Archive