Kubernetes101 : Exposing a deployment and its pods through the Cluster IP service.
Creating a deployment resource:
A deployment is a kubernetes resource used for deploying pods.
Below is the Yaml file describing our deployment:
The above Yaml file is used to deploy two replicas of a pod using the "nginx" image.
Exposing the deployment:
A service is an entry point to pods in kubernetes.
By exposing a deployment resource using a service, we expose the pods mentioned in the deployment Yaml file.
The below command exposes the deployment "deploy-service" and its pods:
We can then check the service using the below command:
Remark:
The application running inside the pods, will be accessible through the internal service (ClusterIP service)
ClusterIP, the default service:
Because we didn't mention the type of the service, the default one "ClusterIP" is created.
The ClusterIP service is accessible only from within the kubernetes cluster.
Comments