Disconnect with Azure ACS form Local Machine

2019-08-27 09:59发布

  • I had pull my azure acs credentials using below command and I can communicate with kubernetes machine on Azure from my local machine az acs kubernetes get-credentials --resource-group=<cluster-resource-group> --name=<cluster-name>
  • But Now I wanted to disconnect this connection so that my kubctl can connect with other machine , it can be local or any other machine (I am trying to connect with local).

  • But everytime I ran kubectl command it communicate with Azure ACS

1条回答
混吃等死
2楼-- · 2019-08-27 10:29

For your scenario, we can use kubectl config use-context CONTEXT_NAME to switch default cluster to others, in this way, we can switch to another k8s cluster.
We can use this command to list k8s contexts:

root@shui:~# kubectl config get-contexts
CURRENT   NAME               CLUSTER            AUTHINFO                 NAMESPACE
          jasontest321mgmt   jasontest321mgmt   jasontest321mgmt-admin   
*         jasonk8s321mgmt    jasonk8s321mgmt    jasonk8s321mgmt-admin   

Specify k8s cluster name, we can use this commandkubectl config use-context CONTEXT_NAME:

root@shui:~# kubectl config use-context -h
Sets the current-context in a kubeconfig file

Examples:
  # Use the context for the minikube cluster
  kubectl config use-context minikube

Usage:
  kubectl config use-context CONTEXT_NAME [options]

For example:

root@shui:~# kubectl config use-context jasontest321mgmt
Switched to context "jasontest321mgmt".
查看更多
登录 后发表回答