Adding own service to Kubernetes Cluster Info

Suraj Narwade
Suraj in Cloud
Published in
1 min readMar 26, 2021

Last week, while going through some of the Kubernetes manifest files, I stumbled upon this label:

kubernetes.io/cluster-service: “true”

I tried to search about this in Documentation but could not find much information about it, hence thought of writing a small blog post about it.

When you add this label to any resource of type Kind: Service , it means it is part of cluster service, and the user needs to know when they are looking for cluster information. Hence it appears in the following command:

kubectl cluster-info

By default this command shows:

$ kubectl cluster-info
Kubernetes master is running at https://kubernetes.docker.internal:6443
KubeDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxyTo further debug and diagnose cluster problems, use ‘kubectl cluster-info dump’.

Now, we will deploy sample Nginx deployment and will try to add this to cluster info:

kubectl run nginx --image=nginx -n kube-system
kubectl expose deployment nginx --port 80 -n kube-system \
--labels kubernetes.io/cluster-service=true

Now you can see nginx service in kubectl cluster-info output,

$ kubectl cluster-info
Kubernetes master is running at https://kubernetes.docker.internal:6443
KubeDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
nginx is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/nginx/proxy

Note: This will work only for services in kube-system namespace.

You can check out the video tutorial for the same here:

Thanks 😇

--

--

Suraj Narwade
Suraj in Cloud

All things Cloud, Containers & Developer Experience