How to switch kubectl clusters between gcloud and minikube

后端 未结 14 1124
再見小時候
再見小時候 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条回答
  • 2021-01-29 20:06

    Cloning the YAML files across repos for different environments is definitely ideal. What you to do is templatize your YAML files - by extracting the parameters which differ from environment to environment.

    You can, of course, use some templating engine and separate the values in a YAML and produce the YAML for a specific environment. But this is easily doable if you adopt the Helm Charts. To take a look at some sample charts go to stable directory at this Github repo

    To take an example of the Wordpress chart, you could have two different commands for two environments:

    For Dev:

    helm install --name dev-release --set \ wordpressUsername=dev_admin, \ wordpressPassword=dev_password, \ mariadb.mariadbRootPassword=dev_secretpassword \ stable/wordpress

    It is not necessary to pass these values on CLI though, you can store the values in a file called aptly values.yml and you could have different files for different environments

    You will need some work in converting to Helm chart standards, but the effort will be worth it.

    0 讨论(0)
  • 2021-01-29 20:07

    You can switch from local (minikube) to gcloud and back with:

    kubectl config use-context CONTEXT_NAME

    to list all contexts:

    kubectl config get-contexts

    You can create different enviroments for local and gcloud and put it in separate yaml files.

    0 讨论(0)
提交回复
热议问题