pulumi / pulumi-kubernetes-operator

A Kubernetes Operator that automates the deployment of Pulumi Stacks
Apache License 2.0
220 stars 54 forks source link

kubeconfig content string in kubernetes provider is not working with operator #557

Open geowalrus4gh opened 7 months ago

geowalrus4gh commented 7 months ago

What happened?

I declared a k8s provider in the Pulumi YAML as below.

   k8sProvider:
        type: pulumi:providers:kubernetes
        properties:
          cluster: kubernetes
          context: aws
          kubeconfig: |
            apiVersion: v1
            clusters:
            - cluster:
                server: <server-url>
                certificate-authority-data: <cert-data>
              name: kubernetes
            contexts:
            - context:
                cluster: kubernetes
                user: aws
              name: aws
            current-context: aws
            kind: Config
            preferences: {}
            users:
            - name: aws
              user:
                exec:
                  apiVersion: client.authentication.k8s.io/v1beta1
                  command: aws-iam-authenticator
                  args:
                    - "token"
                    - "-i"
                    - "pl-native"

It works fine with Pulumi CLI. But the same did not work with pulumi-kubernetes-operator. I included the same provider in a program/stack pair.

Here is the error i am getting.

pulumi:providers:kubernetes k8sProvider error: rpc error: code = Unknown desc = failed to parse kubeconfig: json: cannot unmarshal string into Go struct field ExecConfig.users.user.exec.args of type []string

Example

Extract from the the program/stack

  apiVersion: pulumi.com/v1
  kind: Program
  metadata:
    name: pl-program-eks
  program:
    variables:
      providers:
        - ${k8sProvider}
    resources:
      k8sProvider:
      type: pulumi:providers:kubernetes
      properties:
        cluster: kubernetes
        context: aws
        kubeconfig: |
          apiVersion: v1
          clusters:
          - cluster:
              server: <server-url>
              certificate-authority-data: <cert-data>
            name: kubernetes
          contexts:
          - context:
              cluster: kubernetes
              user: aws
            name: aws
          current-context: aws
          kind: Config
          preferences: {}
          users:
          - name: aws
            user:
              exec:
                apiVersion: client.authentication.k8s.io/v1beta1
                command: aws-iam-authenticator
                args:
                  - "token"
                  - "-i"
                  - "pl-native"

Output of pulumi about

CLI Version 3.107.0 Go Version go1.22.0 Go Compiler gc

Plugins NAME VERSION kubernetes 4.9.0 yaml unknown

Host OS amazon Version 2 Arch x86_64

This project is written in yaml

No dependencies found

Pulumi locates its logs in /tmp by default warning: Failed to get information about the current stack: No current stack

Additional context

No response

Contributing

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).

mjeffryes commented 6 months ago

thanks for the issue report @geowalrus4gh; it migyht be helpful to compare the version of the pulumi-yaml plugin that's being used locally vs in the operator.