pulumi-kubernetes icon indicating copy to clipboard operation
pulumi-kubernetes copied to clipboard

Pulumi fails to generate YAML for external-dns Helm chart

Open Dysproz opened this issue 3 years ago • 2 comments

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

I'm trying to deploy helm chart using pulumi to a EKS cluster. I successfully wrote code for a few charts now, but I have a problem with external-dns chart. Apparently, when I try to deploy it, it fails on rendering deployment template. with error:

running error: invocation of kubernetes:helm:template returned an error: failed to generate YAML for specified Helm chart: failed to create chart from template: execution error at (external-dns/templates/deployment.yaml:65:24): A provider is required to deploy the chart

Should I install some additional provider, or is it some problem in Helm implementation in pulumi itself?

Below code with ComponentResource - it takes as an argument classic AWS EKS cluster.

Steps to reproduce

import { all, ComponentResource, ComponentResourceOptions, Config, Input, output, Output } from "@pulumi/pulumi";
import { Chart } from '@pulumi/kubernetes/helm/v3';
import { Namespace } from '@pulumi/kubernetes/core/v1';
import { Cluster } from "@pulumi/aws/eks";
import { Provider } from "@pulumi/kubernetes";
import { generateKubeconfig } from "../../aws/eks/utils";

export interface TestHelmInputs {
    cluster: Cluster
}

export class TestHelm extends ComponentResource {

    ExternalDNSNamespace: Output<Namespace>;
    ExternalDNSChart: Output<Chart>;

    constructor(
        name: string,
        args: TestHelmInputs,
        opts?: ComponentResourceOptions
    ) {
        super("test:helm:dependencies:dependencies", name, {}, opts);
        let config = new Config();
        let cloud = config.require("cloud");
        let region = config.require(`region`);
        let env = config.require(`env`);

        const kubeconfig = output(generateKubeconfig(args.cluster.name, args.cluster.endpoint, args.cluster.certificateAuthority.data)).apply(JSON.stringify)
        const provider = new Provider("dependencies-custom-provider", { kubeconfig: kubeconfig });

        this.ExternalDNSNamespace = output(new Namespace("external-dns", {
            metadata: {
                name: "external-dns"
            }
        }, {
            provider: provider,
            dependsOn: args.cluster
        }))

        this.ExternalDNSChart = output(new Chart("external-dns-chart", {
            chart: "external-dns",
            namespace: "ingress-nginx",
            fetchOpts: {
                repo: "https://charts.bitnami.com/bitnami",
            },
            version: "v1.2.0",
            values: {
                extraArgs: [
                    "--aws-zone-type=public",
                    "--registry=txt",
                    `--txt-owner-id=${args.cluster.name}`,
                    "--annotation-filter=external-dns-ignore notin (true)",
                    `--domain-filter=${cloud}-${region}.test-${env}.net`,
                    "--events"
                ],
                env: [
                    {
                        name: "AWS_ACCESS_KEY_ID",
                        valueFrom: {
                            secretKeyRef: {
                                name: "dns-route53",
                                key: "accesskey"
                            }
                        }
                    },
                    {
                        name: "AWS_SECRET_ACCESS_KEY",
                        valueFrom: {
                            secretKeyRef: {
                                name: "dns-route53",
                                key: "secretkey"
                            }
                        }
                    }
                ],
                podAnnotations: {
                    "logging.starburstdata.io/es-index-group": "externaldns"
                },
                interval: "30m0s"
            },
        }, {
            provider: provider,
            dependsOn: [args.cluster, this.ExternalDNSNamespace]
        }))


        this.registerOutputs()
    }
}

  1. Create classic EKS cluster and try to deploy above component resource
  2. Try to create/update stack

Expected: Helm chart is properly deployed into the cluster Actual: Fails with error:

running error: invocation of kubernetes:helm:template returned an error: failed to generate YAML for specified Helm chart: failed to create chart from template: execution error at (external-dns/templates/deployment.yaml:65:24): A provider is required to deploy the chart

Dysproz avatar Mar 11 '22 13:03 Dysproz

Any chance you have disabled default providers? https://www.pulumi.com/docs/intro/concepts/resources/providers/#disabling-default-providers - we have work in progress to fix that in #1912.

viveklak avatar Mar 16 '22 05:03 viveklak

Not sure as I'm using automation API

    const pulumiProgram = async () => {
        return await createResource();
    }
    const args: InlineProgramArgs = {
      stackName: "stack",
      projectName: "project",
      program: pulumiProgram,
    };
    const stack = await LocalWorkspace.createOrSelectStack(args);
    console.info("successfully initialized stack");
    console.info("installing plugins...");
    await stack.workspace.installPlugin(cloud, "v4.0.0");
    await stack.workspace.installPlugin("eks", "v0.37.1");
    console.info("plugins installed");
    console.info("setting up config");
    await stack.setConfig(`${cloud}:region`, { value: regionConfig.region });
    console.info("config set");
    console.info("refreshing stack...");
    await stack.refresh({ onOutput: console.info });
    ...

I've noticed that I had to trigger installPlugin functions for aws and eks plugins. Should I maybe trigger it for some other plugins?

Dysproz avatar Mar 16 '22 12:03 Dysproz