Module 7: Kubernetes Assignment - 4
Tasks To Be Performed:
- Use the previous deployment
- Change the service type to ClusterIP
%%Referencing assignment 4%%
Step 1:
Continuing from Assignment 3
nstances and Their Private IP Addresses
k-master:
10.0.1.82worker1:10.0.1.57worker2:10.0.1.119
Step 2: Changing Service
Currently, I have a NodePort service set up for my deployment. I’ll modify this service to be a ClusterIP type, which is only accessible within the Kubernetes cluster.

I use the kubectl edit command to modify the service configuration directly:
kubectl edit serviceThis command opens the service’s configuration in an editor. Within the editor, I perform the following changes:
- Change the
typefield fromNodePorttoClusterIP. - Set the
nodePortfield tonullor remove it entirely, as ClusterIP services do not require an external port.
Before:
After:

I verify the change by inspecting the list of services with the command kubectl get svc. In the output, I confirm that my service, my-nginx-service, now shows ClusterIP in the TYPE column. %%previous%%
Success
To quickly test the ClusterIP service, I use the curl command to send a request to the service’s IP address from within the cluster (master node) :
Successfully returns the webpage

