ClusterIP –> The default service type, accessible only within the cluster. It’s used for internal communication between services.
For example, communication between the front-end and back-end components of your application.
Create a 3 file
nginx-pod.yml
nginx-deployment.yml
nginx-svc.yml
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
– image: nginx
name: nginx-ctr
Execute the pod
kubectl get pods
Get the pod full details
Create a deployment file
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
– image: nginx
name: nginx-ctr
Execute the deployment file
kubectl get pods
Create a service file
kind: Service
metadata:
name: nginx-svc
spec:
selector:
app: nginx
ports:
– name: nginx-port
protocol: TCP
port: 32767
targetPort: 80
Get the full information on pods
Get the pod IP address
kubectl get endpoints
POD → 1
POD → 2
Login to the container and change the Nginx file
Get the services IP
Automatically load balancing selected
Accessible only within the cluster → ClusterIP → Internal load balancer.
Cluster IP service identifies pods using the selector → How pods are identified.
Target port helps in identifying pod port → how port is identified.