How do you connect to a e.g. AKS cluster after it ...
# kubernetes
p
How do you connect to a e.g. AKS cluster after it has been created by pulumi?
s
You have to use a function to pull the credentials, and then build a Kubeconfig from those credentials. Have a look at one of the
kubernetes-azure-*
templates in the Pulumi templates repository (https://github.com/pulumi/templates) for an example of how to do that.
Once you have the Kubeconfig, then you can build a Kubernetes provider that uses it, or pass it to
kubectl
for CLI access.
One additional note: by default, the Kubeconfig created by AKS uses a
devicelogin
configuration and won’t leverage the Azure CLI authentication. See this blog post to switch it (which makes it a tad easier IMO): https://blog.scottlowe.org/2022/10/06/streamlining-the-user-experience-for-accessing-aks-clusters/
p
Thanks Scott! We're currently connecting using the Command package that's in preview. And then calling
az aks get-credentials
through that. But that throws an error so maybe not the way to do it...
Thanks a lot for pointing at the templates. I wish we would've seen those a long time ago 🙂
s
You should be able to “steal” code from the templates to add to your own projects in order to generate a Kubeconfig. Let us know if you need some help in that direction.