Microk8s: how to get the node external-ip, like "minikube ip"?

Using microk8s 1.18 on Ubuntu 20.04.

I’d like to get the external ip of the node. Similar to minikube ip as shown in the Istio Ingress Gateways documentation.

Question: How to get the IP address of the node so to allow remote clients outside of the cluster to access services installed within the cluster? In my example, this address would be 192.168.1.98. Maybe it is possible to grep it from microk8s.kubectl cluster-info
However all I can see is the loopback IP 127.0.0.1.

$ microk8s.kubectl cluster-info

Kubernetes master is running at https://127.0.0.1:16443
Heapster is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/heapster/proxy
CoreDNS is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Grafana is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
InfluxDB is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy

EDIT: Hum maybe I am asking the wrong question? A cluster theoritically has multiple nodes so it’s kind of illogical to ask the cluster to give a node IP address. Maybe I should query the node details and read the info in the Addresses section:

$ microk8s.kubectl describe node $(microk8s.kubectl get nodes --no-headers | cut -f 1 -d " ")

// console output:
Name:               myhostname
Roles:              <none>
... etc ...
Addresses:
  InternalIP:  192.168.1.98
  Hostname:    myhostname
... etc ...

1 Like

MicroK8s will use the default interface. You should be able to locate that with ip route | grep default.
You are right that in a MIcroK8s cluster you will get one IP per node.

In case you look for a kubeconfig file to access the api server, you can use microk8s config [1]

[1] https://microk8s.io/docs/commands#microk8s-config

This command returns the IP address of the router, not the IP of the machine where microk8s is installed. Can you please clarify?

With ip route | grep default you will get the interface used by MicroK8s. You can do an ifconfig of that interface to see more info.

Oh Ok thanks. I did directly ifconfig. But found the output of kubectl describe node more informative (details in initial post).