How to switch kubectl clusters between gcloud and minikube

后端 未结 14 1333
再見小時候
再見小時候 2021-01-29 19:01

I have Kubernetes working well in two different environments, namely in my local environment (MacBook running minikube) and as well as on Google\'s Container Engine (GCE, Kubern

14条回答
  •  萌比男神i
    2021-01-29 19:47

    Check also the latest (docker 19.03) docker context command.

    Ajeet Singh Raina ) illustrates it in "Docker 19.03.0 Pre-Release: Fast Context Switching, Rootless Docker, Sysctl support for Swarm Services"

    A context is essentially the configuration that you use to access a particular cluster.

    Say, for example, in my particular case, I have 4 different clusters – mix of Swarm and Kubernetes running locally and remotely.
    Assume that I have a default cluster running on my Desktop machine , 2 node Swarm Cluster running on Google Cloud Platform, 5-Node Cluster running on Play with Docker playground and a single-node Kubernetes cluster running on Minikube and that I need to access pretty regularly.

    Using docker context CLI I can easily switch from one cluster(which could be my development cluster) to test to production cluster in seconds.

    $ sudo docker context --help
    Usage:  docker context COMMAND
    Manage contexts
    Commands:
      create      Create a context
      export      Export a context to a tar or kubeconfig file
      import      Import a context from a tar file
      inspect     Display detailed information on one or more contexts
      ls          List contexts
      rm          Remove one or more contexts
      update      Update a context
      use         Set the current docker context
    Run 'docker context COMMAND --help' for more information on a command.
    

    For example:

    [:)Captain'sBay=>sudo docker context ls
    NAME                DESCRIPTION                               DOCKER ENDPOINT               KUBERNETES ENDPOINT                 ORCHESTRATOR
    default *           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   https://127.0.0.1:16443 (default)   swarm
    swarm-context1 
    

提交回复
热议问题