Reputation: 41
While using this command for RBAC "kubectl config set-cluster test --server=https://127.0.0.1:52807"
the IP here is from the kind-cluster that I am running after which I use "kubectl config set-context test --cluster=test"
followed by required credentials & switch to the context by "kubectl config use-context test"
and I am in the test context but with the first command I am configuring the config file I got that but m I making a cluster within a cluster what you guys understand please help me clear my doubt what is it actually doing?
Upvotes: 3
Views: 5518
Reputation: 92
kubectl config set-cluster
sets a cluster entry in your kubeconfig
file (usually found in $HOME/.kube/config
). The kubeconfig
file defines how your kubectl
is configured.
The cluster entry defines where kubectl
can find the kubernetes cluster to talk to. You can have multiple clusters defined in your kubeconfig
file.
kubectl config set-context
sets a context element, which is used to combine a cluster, namespace and user into a single element so that kubectl
has everything it needs to communicate with the cluster. You can have multiple contexts, for example one per kubernetes cluster that you're managing.
kubectl config use-context
sets your current context to be used in kubectl
.
So to walk through your commands:
kubectl config set-cluster test --server=https://127.0.0.1:52807
creates a new entry in kubeconfig
under the clusters
section with a cluster called test
pointing towards https://127.0.0.1:52807
kubectl config set-context test --cluster=test
creates a new context in kubeconfig
called test
and tells that context to point to a cluster called test
kubectl config use-context test
changes the the current context in kubeconfig
to a context called test
(which you just created).More docs on kubectl config
and kubeconfig
:
Upvotes: 6