Kubernetes master node restrict to show

1/22/2019

I have a kubernetes cluster

In Master node,

If I give the command kubectl get nodes it should show all the nodes.

But, If I give the same command in nodes it should not show the master node.

Is it possible in kubernetes?

Please help anyone. Thanks in advance.

-- az rnd
kubectl
kubernetes

1 Answer

1/22/2019

No, this is not possible. The kubernetes API will always respond to the same queries in the same way. kubectl get nodes is asking for information about all nodes, and the api will always answer an authorized user with all of the nodes.

With RBAC it is possible to limit what a particular user or account has access to view or edit, but the nodes resource is not namespaced, and does not give granularity to restrict access to certain nodes.

You can, however, filter the results of kubectl get nodes any way you like. This question has some good examples of showing only worker nodes using the -l argument to kubectl.

-- captncraig
Source: StackOverflow