ClusterIP – Kubernetes

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…


This content originally appeared on DEV Community and was authored by Ibrahim S

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

  1. nginx-pod.yml
  2. nginx-deployment.yml
  3. nginx-svc.yml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
  - image: nginx
    name: nginx-ctr

Execute the pod

kubectl apply -f nginx-pod.yml
kubectl get pods 

Image description

Get the pod full details

kubectl get pods -o wide

Image description

Create a deployment file

apiVersion: apps/v1
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 apply -f nginx-deployment.yml
kubectl get pods

Image description

Create a service file

apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  selector:
    app: nginx
  ports:
    - name: nginx-port
      protocol: TCP
      port: 32767
      targetPort: 80

Image description

Get the full information on pods

kubectl get all

Image description

Get the pod IP address

kubectl get pods -o wide (or)
kubectl get endpoints

Image description

POD → 1

Image description

POD → 2

Image description

Login to the container and change the Nginx file

kubectl -it exec nginx-deployment-7bb9945d7c-75nc5 -- /bin/sh

Image description

Get the services IP

kubectl get svc

Image description

Automatically load balancing selected

Image description

  • 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.


This content originally appeared on DEV Community and was authored by Ibrahim S


Print Share Comment Cite Upload Translate Updates
APA

Ibrahim S | Sciencx (2024-07-06T05:50:32+00:00) ClusterIP – Kubernetes. Retrieved from https://www.scien.cx/2024/07/06/clusterip-kubernetes/

MLA
" » ClusterIP – Kubernetes." Ibrahim S | Sciencx - Saturday July 6, 2024, https://www.scien.cx/2024/07/06/clusterip-kubernetes/
HARVARD
Ibrahim S | Sciencx Saturday July 6, 2024 » ClusterIP – Kubernetes., viewed ,<https://www.scien.cx/2024/07/06/clusterip-kubernetes/>
VANCOUVER
Ibrahim S | Sciencx - » ClusterIP – Kubernetes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/06/clusterip-kubernetes/
CHICAGO
" » ClusterIP – Kubernetes." Ibrahim S | Sciencx - Accessed . https://www.scien.cx/2024/07/06/clusterip-kubernetes/
IEEE
" » ClusterIP – Kubernetes." Ibrahim S | Sciencx [Online]. Available: https://www.scien.cx/2024/07/06/clusterip-kubernetes/. [Accessed: ]
rf:citation
» ClusterIP – Kubernetes | Ibrahim S | Sciencx | https://www.scien.cx/2024/07/06/clusterip-kubernetes/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.