Kops / kubectl - how do I import state created on another server?

i set up a kubernetes cluster using kops, and I did it from the local machine. Therefore, my .kube directory is stored on my local computer, but I install kops to store state in s3 .

Im in the process of setting up my CI server now, and I want to run my kubectl from this field. How do I import an existing state into this server?

+2
kubernetes kubectl kops
source share
2 answers

One simple option:

1) install kops, kubectl on your CI server

2) configure AWS access credentials on your CI server (either through the IAM role or just env vars), make sure that it has access to your s3 state storage path

3) set env var for kops to access your cluster:

  export NAME=${YOUR_CLUSTER_NAME} export KOPS_STATE_STORE=s3://${YOUR_CLUSTER_KOPS_STATE_STORE} 

4) Use the export kops command to get the kubecfg needed to run kubectl

  kops export kubecfg ${YOUR_CLUSTER_NAME} 

see https://github.com/kubernetes/kops/blob/master/docs/cli/kops_export.md

After exporting the cube configuration file, you should use the kubectl command. Although ideally you should use a proper authentication mechanism (e.g. https://kubernetes.io/docs/admin/authentication/#using-kubectl )

+4
source share

.kube/config hardly a "state", it is just a client configuration, so you can just take its contents (or part of it if you have more contexts locally) and use it on another machine. That is, if you do not want to create a dedicated user (key / certificate) for CI, in this case you need to create separate credentials, and if you use the / cert key, they must be for another "subject" of the certificate, so users can be recognized as different.

0
source share

All Articles