https://pulumi.com logo
Title
f

flat-engineer-30260

01/06/2023, 12:25 PM
Hi all, How do you 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, and it's hard to parse the yaml to string and set with pulumi secret. 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. How did you do that? Confusing...
d

dry-keyboard-94795

01/06/2023, 12:33 PM
KUBECONFIG
should be set to the path of the config, ie
KUBECONFIG=~/.kube/config
If your
.kube/config
is setup already, then pulumi will use that https://www.pulumi.com/registry/packages/kubernetes/installation-configuration/#setup
f

flat-engineer-30260

01/06/2023, 12:38 PM
I knew what you mean. If we're running pulumi up in local environment, that's work. However, we deploy the codes by CI/CD pipeline, the initial contianer doesn't have ~/.kube/config there, you've pass it into container in some way. That's what block me a long time.
d

dry-keyboard-94795

01/06/2023, 12:47 PM
hmm, from the
--help
, looks like you can set a value through stdin. so this might work for you?
cat my/kubeconfig | config set --secret kubernetes:kubeconfig
f

flat-engineer-30260

01/06/2023, 12:54 PM
Brilliant! It works. Thank you for saving my time.
Configuration values can be accessed when a stack is being deployed and used to configure behavior.
If a value is not present on the command line, pulumi will prompt for the value. Multi-line values
may be set by piping a file to standard in.
My bad, I'm not go through the instruction carefully. 😂