sparse-intern-71089
05/17/2021, 6:52 PMbillowy-army-68599
apply()
enough-truck-34175
05/17/2021, 7:10 PMenough-truck-34175
05/17/2021, 7:12 PMKubeConfig
property of the Kubernetes Provider. I just don’t know the proper was to create an ApplyT
. Usually I am making them from a secret that already exists.billowy-army-68599
enough-truck-34175
05/17/2021, 7:45 PMError setting up kubeconfig
kubeconfig, exists := ctx.GetConfig("kubeconfig")
if !exists {
return nil, errors.New("Kubeconfig not found in context.")
}
return kubernetes.NewProvider(ctx, clusterName+"-kube-context-"+providerNameSuffix, &kubernetes.ProviderArgs{
Cluster: pulumi.StringPtr(clusterName),
Kubeconfig: pulumi.StringPtr(kubeconfig),
}, opts...)
enough-truck-34175
05/17/2021, 7:46 PMbillowy-army-68599
enough-truck-34175
05/17/2021, 7:55 PMmain()
and included other important functions.billowy-army-68599
NewProvider
argument takes an input - is there any reason you're not passing the kubeconfig from listmanagedcredentials directly to it?enough-truck-34175
05/17/2021, 8:09 PMcreds, err := containerservice.ListManagedClusterAdminCredentials(ctx, &containerservice.ListManagedClusterAdminCredentialsArgs{
ResourceName: clusterName,
ResourceGroupName: pulumi.StringPtr(params.ClusterName + "-aks"),
})
if err != nil {
return nil, errors.Wrap(err, "ListManagedClusterAdminCredentials failed to retrieve admin credentials")
}
configBytes, err := b64.StdEncoding.DecodeString(creds.Kubeconfigs[0].Value)
if err != nil {
return nil, errors.Wrap(err, "Could not base64 decode kubeconfig file")
}
return kubernetes.NewProvider(ctx, clusterName+"-kube-context-"+providerNameSuffix, &kubernetes.ProviderArgs{
Cluster: pulumi.StringPtr(clusterName),
Kubeconfig: pulumi.StringPtr(string(configBytes)),
}, opts...)
enough-truck-34175
05/17/2021, 10:48 PMpreview
to pass, but it fails on up
. Looks like Pulumi isn’t running my custom code on demand, only during compilation (or whatever that terminology would be).
This is a real bummer. I’m going to put in a feature request for this. If functions have dependsOn
functionality, it should solve this problem.
This is azure specific, but it could be a problem with other providers too. For example, DigitalOcean returns the kubeconfig file with the cluster response object. Maybe Pulumi would manages that situation better.billowy-army-68599
billowy-army-68599
listManagedClusterAdminCrdenetials
will indeed error if the cluster doesn't exist, but if you're running it inside an ApplyT
it will ALWAYS exists in that circumstance, because the Azure API has responded with the outputsbillowy-army-68599
billowy-army-68599
billowy-army-68599
billowy-army-68599
enough-truck-34175
05/18/2021, 10:32 PM