limited-dog-75903
09/07/2021, 4:10 AMlittle-cartoon-10569
09/07/2021, 4:43 AMlimited-dog-75903
09/07/2021, 8:52 AMdry-florist-5950
09/07/2021, 11:55 AMlimited-dog-75903
09/07/2021, 1:23 PMgreat-queen-39697
09/07/2021, 4:09 PMpulumi stack output kubeconfig --show-secrets > kubeconfig
Then you can export it to your local config so kubectl works:
export KUBECONFIG=$PWD/kubeconfig
limited-dog-75903
09/07/2021, 5:02 PMgreat-queen-39697
09/07/2021, 6:07 PMpulumi up
to start the instance)? If you didn't use Pulumi to configure the instance in the first place, Pulumi doesn't know anything about the instance. In that case, I think you would get better results by getting the kubeconfig directly using the SDK as mentioned earlier in the thread. Otherwise, you would have to import the infrastructure to Pulumi so the Pulumi system knows the current state, then export the kubeconfig from the stack as I noted.limited-dog-75903
09/08/2021, 4:09 AMgreat-queen-39697
09/08/2021, 4:50 PMpulumi up
to deploy to EC2, you created a stack. That stack's configuration and state is stored in Pulumi. Any time you create a Kubernetes cluster, there's a kubeconfig. The commands I noted above are terminal commands, not code. pulumi stack
is a command-line interface to manage the stack (see https://www.pulumi.com/docs/reference/cli/pulumi_stack/). If you create a Kubernetes cluster with Pulumi anywhere, not just on a managed service, you can get the kubeconfig from the stack output at the command line.limited-dog-75903
09/09/2021, 5:41 PMpulumi stack output kubeconfig
worksgreat-queen-39697
09/16/2021, 12:27 PMIf the kubeconfig file is not in either of these locations, Pulumi will not find it, and it will fail to authenticate against the cluster. (from https://www.pulumi.com/docs/intro/cloud-providers/kubernetes/setup/#steps)If you've successfully run
pulumi up
against the cluster and updated it, then it's already available. If you're saying that you used Ansible to set up EC2 with a Kubernetes cluster and now you want to use Pulumi to manage it from here but have not actually successfully connected, that's a different story, and you do need to use a different tool to get that kubeconfig file before Pulumi can authenticate and access the cluster.
If you can run kubectl
against the cluster on EC2, you can view the config with kubectl config view
. If you can't run kubectl
against that cluster, you need to connect to the instance and locate the configuration file(s) manually (e.g., if you want to do it through ssh, go through this guide from AWS).limited-dog-75903
09/17/2021, 5:18 AM