-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Hello there 👋
TLDR : I can't use the NewKubeconfig() output as input for kubernetes.NewProvider().
The long story :
I'm trying to bootstrap a Talos cluster with Pulumi (pulumi-proxmoxve for VM creation) and pulumi-talos to bootstrap the cluster.
Then, I want to automatically deploy helm chart on the cluster.
The Talos cluster is configured correctly with this extract of code (i'm using Go) :
// ...
secrets, err := machine.NewSecrets(ctx, "secrets", &machine.SecretsArgs{..})
// ...
for _, item := range kubernetesNodes {
configuration := machine.GetConfigurationOutput(ctx, machine.GetConfigurationOutputArgs{...})
// ...
configurationApply, err := machine.NewConfigurationApply(...)
// ...
}
//...
bootstrap, err := machine.NewBootstrap(...)
//...Then, I want to retrieve the kubeconfig file with :
// Create Kubeconfig resource
k, err := cluster.NewKubeconfig(ctx, "kubeconfig", &cluster.KubeconfigArgs{
ClientConfiguration: cluster.KubeconfigClientConfigurationArgs{
CaCertificate: secrets.ClientConfiguration.CaCertificate(),
ClientCertificate: secrets.ClientConfiguration.ClientCertificate(),
ClientKey: secrets.ClientConfiguration.ClientKey(),
},
Node: pulumi.String(item.Networks[0].Address),
}, pulumi.DependsOn([]pulumi.Resource{bootstrap}))
if err != nil {
return nil, fmt.Errorf("error while create kubeconfig on node %s, got %v", item.Name, err)
}Next, I use the k variable to create a kubernetes Provider with this code :
// Create kubernets provider based on kubeconfig
p, err := kubernetes.NewProvider(ctx, "kube-provider", &kubernetes.ProviderArgs{
Kubeconfig: k.KubeconfigRaw,
}, pulumi.DependsOn([]pulumi.Resource{k}))
if err != nil {
return errors.Wrap(err, "create kubernetes provider")
}
kopts := []pulumi.ResourceOption{}
kopts = append(kopts, pulumi.Provider(p))
kopts = append(kopts, pulumi.DependsOn([]pulumi.Resource{p}))Finally, I try to deploy helm chart using this code
a, err := helmv3.NewRelease(ctx, "metallb", &helmv3.ReleaseArgs{
Chart: pulumi.String("metallb"),
Name: pulumi.String("metallb"),
RepositoryOpts: helmv3.RepositoryOptsArgs{
Repo: pulumi.String("https://metallb.github.io/metallb"),
},
Namespace: pulumi.String("metallb-system"),
Version: pulumi.String("v0.14.9"),
Values: pulumi.Map{
"frr": pulumi.Map{
"enabled": pulumi.Bool(false),
},
},
}, kopts...)
if err != nil {
return nil, err
}But i got this error message :
error: can't create Helm Release with unreachable cluster: unable to load schema information from the API server: Get "https://cp.x.x.x:6443/openapi/v2?timeout=32s": dial tcp y.y.y.y:6443: connect: connection refused
k.KubeconfigRaw is also exported as Pulutmi output, and when I'm using it in file I can reach the cluster, so I don't think it's a network issue here. And the cluster is healthy with all Pod Running correctly.
I have no idea where this can came from, i tried with several wait between the apply and the bootstrap but I got the same error again and again. Any idea to debug ?