I can log into a work terminal via a public IP, and list all the nodes
by
kubectl get nodes # only gives me internal IPs
and also be able to check the basic info by
kubectl cluster-info
and the basic IP info for the current instance by:
ifconfig # but this gives me public IP not internal
The problem is I have no idea how to determine which node I am currently in: a master
? which master (there are several masters) or just a slave? then which slave?
Thanks for the help ;)
Some of these commands might show different output based on your Kubernetes cluster, I am showing examples from GKE here.
You can use -owide
option to get some additional information:
$kubectl get nodes -owide
NAME STATUS ROLES AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
gke-test-pool2-772ceaec-0tzf Ready <none> 23h v1.9.7-gke.5 35.200.255.186 Container-Optimized OS from Google 4.4.111+ docker://17.3.2
gke-test-pool2-772ceaec-1722 Ready <none> 20h v1.9.7-gke.5 35.200.152.18 Container-Optimized OS from Google 4.4.111+ docker://17.3.2
From the above output you can use:
Also, you can use labels to get some more information:
$ kubectl get --show-labels nodes
NAME STATUS ROLES AGE VERSION LABELS
gke-test-pool2-772ceaec-0tzf Ready <none> 23h v1.9.7-gke.5 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/instance-type=n1-standard-1,beta.kubernetes.io/os=linux,cloud.google.com/gke-nodepool=pool2,cloud.google.com/gke-preemptible=true,failure-domain.beta.kubernetes.io/region=asia-south1,failure-domain.beta.kubernetes.io/zone=asia-south1-b,kubernetes.io/hostname=gke-test-pool2-772ceaec-0tzf
gke-test-pool2-772ceaec-1722 Ready <none> 20h v1.9.7-gke.5 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/instance-type=n1-standard-1,beta.kubernetes.io/os=linux,cloud.google.com/gke-nodepool=pool2,cloud.google.com/gke-preemptible=true,failure-domain.beta.kubernetes.io/region=asia-south1,failure-domain.beta.kubernetes.io/zone=asia-south1-b,kubernetes.io/hostname=gke-test-pool2-772ceaec-1722
From this output, you can:
You can match above information with ifconfig
to figure out the IP of your node. Lastly - it is not necessary that the terminal you are logged in is one of the nodes in the cluster.
Lastly, it could very well be a node which is outside cluster with Kubeconfig
and kubectl
configured.