How to Change the NodePort Service to Cluster IP — Kubernetes Assignment 4
Tasks to Be Performed:
1. Use the previous deployment
2. Change the service type to ClusterIP
Check the Git Hub Repository for this Assignment to Copy the Commands:
Problem (1) Solution: Use the previous deployment
Before working on this assignment, you have to check the Kubernetes Assignment 1, where we have created a Kubernetes Cluster & After that you have to check the Kubernetes Assignment 2 & Kubernetes-Assignment-3, where we have created the NodePort in Assignment 2 & changed the deployment from 3 replica to 5 replica in Assignment 3 respectively.
After perfoming the Assignment 2 & 3, you have to perform this assignment. We will use a new t2.medium machine with 5 replica node because t2.medium is chargeable, not possible to run the machine everytime.
So that’s why we set up a new Kubernetes Cluster with 5 replica.
Problem (2) Solution: Change the service type to ClusterIP
Step 1: Run the below-given command to find the service:
kubectl get svc
my-nginx-deployment will be as a “NodePort” type, we will make it as “Cluster IP” to communicate internally.
Step 2: Run the below-given command to edit the “svc” file:
kubectl edit svc
Step 3: Your “svc” file will be opened. Press “I” from keyboard to insert anything.
Do these changes in the “svc” file.
- nodePort: null
type: ClusterIP
Press “esc” from keyboard & run the below-given command to save & exit from file:-
:wq!
Step 4: Again, run the below-given command:
kubectl get svc
Your “my-nginx-deployment” has been successfully changed to “ClusterIP”.
More Kubernetes Assignments:
How to Deploy Ingress Service Using MiniKube in Kubernetes — Kubernetes Assignment 5
How to Deploy a Sample Website on Kubernetes Using Ingress — Kubernetes Case Study