First of all, run this command:
kubectl get -n namespace services
The above command will return the output something like this:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE backend NodePort 10.100.44.154 <none> 9400:3003/TCP 13h frontend NodePort 10.107.53.39 <none> 3000:30017/TCP 13h
From the above output, it can be seen that the external IP addresses are not yet assigned to the services. To assign external IP addresses for the internal service, run the following command.
kubectl patch svc backend -p '{"spec":{"externalIPs":["192.168.0.194"]}}'
and to assign an external IP address to an external service, run this command.
kubectl patch svc frontend -p '{"spec":{"externalIPs":["192.168.0.194"]}}'
Now get the namespace service to verify the assignment of external IP addresses:
kubectl get -n namespace services
We get the following conclusion:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE backend NodePort 10.100.44.154 192.168.0.194 9400:3003/TCP 13h frontend NodePort 10.107.53.39 192.168.0.194 3000:30017/TCP 13h
Hooray !!! Kubernetes External IPs are now assigned.
source share