Is it possible from inside the cluster to figure o...
# k3s
q
Is it possible from inside the cluster to figure out the "advertised" URL to the API server, such as the one you would put in your kubeconfig file?
n
you can find some more information via
kubectl cluster-info --v=7
for example but that depends on your KUBECONFIG as an end point
also if you have access to the control plane machine you can check if you have something specified on the k3s server at the service
cat ./etc/systemd/system/k3s.service
q
Thanks a lot
👍 1
c
kubectl get endpoints kubernetes
any one of those apiserver endpoints…
q
Looking at my endpoints I only get the internal IP. My server has multiple interfaces and the api-server binds to 0.0.0.0, so the VPN IP also works, but that's not visible on the endpoint.
The cluster-info seems dependent on your kubeconfig? Looking at the original config used when installing k3s obviously contains the information, I was more looking for ways to discover it from inside the cluster.
The idea was to have an application in the cluster, and when a user calls an endpoint with proper authentication, a valid kubeconfig is returned. But for that I need the advertised URL. I was hoping it was discoverable somewhere, but I guess I'll just have to supply it as config.
c
apiservers advertise the internal IP of the node they are running on, as the endpoints are used to provide in-cluster connectivity. If you want to connect to the cluster from outside then you will need to know on your own how reach your nodes from outside the cluster. that is not something Kubernetes is aware of.
👍 1
s
kubectl get endpoints kubernetes
Because I like to play-along at home, I thought I'd try that on my non-ha k3s cluster.
Copy code
$ kubectl get endpoints kubernetes --context=kube001
Error from server (NotFound): endpoints "kubernetes" not found
Is that expected?
q
Are you sure you checked the
default
namespace? AFAIK, the
kubernetes
service is always created.
c
yes you will always have that. It will always exist in the default namespace.
s
Ah yes -
kubectl get endpoints -n=default
does return them.