Hi, How do we correctly import kubeconfig of exter...
# pulumi-deployments
f
Hi, How do we correctly import kubeconfig of external kubernetes which isn't created via pulumi into pulumi deployment container? We had tried to put kubeconfig content as environment variable KUBECONFIG, it doesn't work. In the meantime,
pulumi config set --secret kubernetes:kubeconfig   --path ~/.kube/config
, something like this, it won't load the file content. The only worked way is to read it from the local file
pulumi_k8s = kubernetes.Provider("pulumi_k8s", kubeconfig=(lambda path: open(path).read())("kubeconfig"))
, but it is not secure to store kubeconfig file in github.
r
You can read from a file to set the config value like this:
Copy code
pulumi config set --secret kubernetes:kubeconfig < ~/.kube/config
We had tried to put kubeconfig content as environment variable KUBECONFIG, it doesn't work.
Can you say more about what doesn't work? Do you get an error?
f
We had resolved this issue by
cat ~/.kube/config | pulumi config set --secret kubernetes:kubeconfig
.
I think KUBECONFIG can only pass the kubeconfig path(In pulumi deployment's container, there is no kubeconfig file at all, you'd to pass in) , but not the content of ~/.kube/config, The error is like:
++ kubernetes:apps/v1:Deployment nginx creating replacement (0s) [diff: ~metadata]; error: configured Kubernetes cluster is unreachable: unable to load Kubernetes client configuration from kubeconfig file. Make sure you have:
15
++ kubernetes:apps/v1:Deployment nginx **creating failed** [diff: ~metadata]; error: configured Kubernetes cluster is unreachable: unable to load Kubernetes client configuration from kubeconfig file. Make sure you have:
16
pulumi:pulumi:Stack kubernetes-python-dev running error: update failed
17
pulumi:pulumi:Stack kubernetes-python-dev **failed** 1 error; 2 messages