Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the cluster IP in Kubernetes?

I have created a cluster of three nodes: one master, two minions. How to check the cluster IP in Kubernetes? Is it the IP of the master node?

like image 759
Madhurima Mishra Avatar asked Oct 29 '15 06:10

Madhurima Mishra


People also ask

How do I find my Kubernetes cluster IP?

To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.

What is cluster IP address?

A cluster IP is a term in cloud computing to refer to a proxy that represents a computer cluster with a single IP address. It is a term used by the cloud computing system Kubernetes (stylised as ClusterIP) to provide load balancing to IP addresses for devices in the internal network.

Is cluster IP same as node IP?

NodePort definitions have the same mandatory properties as ClusterIP services. The only difference is the change to type: NodePort . The targetPort field is still required, as NodePorts are backed by a ClusterIP service. This will route traffic on port 32000 to port 80 in your Pods.

What does cluster IP none mean?

Default Kubernetes service type is clusterIP , When you create a headless service by setting clusterIP None , no load-balancing is done and no cluster IP is allocated for this service. Only DNS is automatically configured.


2 Answers

ClusterIP can mean 2 things: a type of service which is only accessible within a Kubernetes cluster, or the internal ("virtual") IP of components within a Kubernetes cluster. Assuming you're asking about finding the internal IP of a cluster, it can be accessed in 3 ways (using the simple-nginx example):

  1. Via command line kubectl utility:

    $ kubectl describe service my-nginx Name:           my-nginx Namespace:      default Labels:         run=my-nginx Selector:       run=my-nginx Type:           LoadBalancer IP:         10.123.253.27 LoadBalancer Ingress:   104.197.129.240 Port:           <unnamed>   80/TCP NodePort:       <unnamed>   30723/TCP Endpoints:      10.120.0.6:80 Session Affinity:   None No events. 
  2. Via the kubernetes API (here I've used kubectl proxy to route through localhost to my cluster):

    $ kubectl proxy & $ curl -G http://localhost:8001/api/v1/namespaces/default/services/my-nginx {   "kind": "Service",   "apiVersion": "v1",   "metadata": <omitted>,   "spec": {     "ports": [       {         "protocol": "TCP",         "port": 80,         "targetPort": 80,         "nodePort": 30723       }     ],     "selector": {       "run": "my-nginx"     },     "clusterIP": "10.123.253.27",     "type": "LoadBalancer",     "sessionAffinity": "None"   },   "status": {     "loadBalancer": {       "ingress": [         {           "ip": "104.197.129.240"         }       ]     }   } } 
  3. Via the $<NAME>_SERVICE_HOST environment variable within a Kubernetes container (in this example my-nginx-yczg9 is the name of a pod in the cluster):

    $ kubectl exec my-nginx-yczg9 -- sh -c 'echo $MY_NGINX_SERVICE_HOST' 10.123.253.27 

More details on service IPs can be found in the Services in Kubernetes documentation, and the previously mentioned simple-nginx example is a good example of exposing a service outside your cluster with the LoadBalancer service type.

like image 58
Tim Allclair Avatar answered Nov 09 '22 07:11

Tim Allclair


Run this

$ kubectl cluster-info 

It shows result like this where you can see the Kubernetes master IP

Kubernetes Cluster IP

like image 29
Abu Shoeb Avatar answered Nov 09 '22 06:11

Abu Shoeb