numerous-airport-64744
01/27/2020, 9:26 PMcluster.kubeConfigs[0].rawConfig
always returns the credentials from the time the cluster was actually created.
I tried to get the credentials by using a data source but I still have 2 problems with it:
• I’m unable to create a data source for the cluster from the generated name because GetKubernetesClusterArgs does not accept Output<string> as a name and my clusters name is dynamic.
• If I hard code the cluster name after it is being created the kubeconfig property of the k8s provider is changed on every pulumi up
-> pulumi:providers:kubernetes k8s updated [diff: ~kubeconfig]
Here are the relevant parts for clarification:
const cluster = new digitalocean.KubernetesCluster("cluster", {...});
const clusterDataSource = digitalocean.getKubernetesCluster({ name: cluster.name }); // error TS2322: Type 'Output<string>' is not assignable to type 'string'.
const kubeConfig = clusterDataSource.kubeConfigs[0].rawConfig;
const k8sProvider = new k8s.Provider("k8s", { kubeconfig: kubeConfig });
Any idea how to solve those two issues - primarily of course dynamic cluster name?gorgeous-egg-16927
01/27/2020, 11:14 PMconst clusterDataSource = cluster.name.apply(name => digitalocean.getKubernetesCluster({name}));
const kubeconfig = clusterDataSource.kubeConfigs[0].rawConfig;
certificate-authority-data
field changes on every update, but shouldn’t affect things otherwise AFAICTgetKubernetesCluster
if the cluster didn’t exist yet, but this should do the trick:
const cluster = new digitalocean.KubernetesCluster("do-cluster", {
region: digitalocean.Regions.SFO2,
version: digitalocean.getKubernetesVersions({versionPrefix: "1.16"}).then(p => p.latestVersion),
nodePool: {
name: "default",
size: digitalocean.DropletSlugs.DropletS2VCPU2GB,
nodeCount: 2,
},
});
const kubeconfig = cluster.status.apply(status => {
if (status === 'running') {
const clusterDataSource = cluster.name.apply(name => digitalocean.getKubernetesCluster({name}));
return clusterDataSource.kubeConfigs[0].rawConfig;
} else {
return cluster.kubeConfigs[0].rawConfig;
}
});
const provider = new k8s.Provider("k8s", {kubeconfig});
numerous-airport-64744
01/27/2020, 11:51 PMnew k8s.Provider("k8s", {kubeconfig}, { ignoreChanges: ["kubeconfig"] });
Not sure if this will have some side effects but for now it seems to work.gorgeous-egg-16927
01/27/2020, 11:56 PMignoreChanges
will bypass that checking. As long as you’re aware of that, should be fine