Hello! I couldn’t import the already deployed helm...
# kubernetes
n
Hello! I couldn’t import the already deployed helm release from my k8s cluster. I wonder its intended behavior. Could anyone help with this issue?
My test scenario is below: 1, I installed the nginx helm chart to my k8s cluster(in
default
namespace)
Copy code
helm repo add bitnami <https://charts.bitnami.com/bitnami>
helm install nx-test bitnami/nginx
2. I tried to import the upper release using the import feature.
Copy code
import * as k8s from "@pulumi/kubernetes";

const release = new k8s.helm.v3.Release("nx-test", {
    name: "nx-test",
    chart: "nginx",
    version: "9.8.0",
    repositoryOpts: {
        repo: "<https://charts.bitnami.com/bitnami>"
    },
    namespace: "default"
}, {
    import: `default/nx-test`
})
3. But, it was failed…
Copy code
$ pulumi up
Previewing update (tests):
     Type                              Name              Plan       Info
     pulumi:pulumi:Stack               test-tests             
 =   └─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test           import     [diff: +repositoryOpts]; 1 warning
 
Diagnostics:
  kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release> (nx-test):
    warning: inputs to import do not match the existing resource; importing this resource will fail
 

Do you want to perform this update? yes
Updating (tests):
     Type                              Name              Status                   Info
     pulumi:pulumi:Stack               test-tests  **failed**               1 error
 =   └─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test           **importing failed**     1 error
 
Diagnostics:
  pulumi:pulumi:Stack (test-tests):
    error: update failed
 
  kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release> (nx-test):
    error: inputs to import do not match the existing resource
 
Resources:
    1 unchanged

Duration: 7s
4. I uninstalled my
nx-test
release.
Copy code
helm uninstall nx-test
5. installed
nx-test
using pulumi. (using code in number 2, with removed CustomResourceOptions)
Copy code
$ pulumi up
Previewing update (tests):
     Type                              Name              Plan       
     pulumi:pulumi:Stack               test-tests             
 +   └─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test           create     
 
Resources:
    + 1 to create
    1 unchanged

Do you want to perform this update? yes
Updating (tests):
     Type                              Name              Status      
     pulumi:pulumi:Stack               test-tests              
 +   └─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test           created     
 
Resources:
    + 1 created
    1 unchanged

Duration: 33s
6. I removed
<http://helm.sh/v3:Release|helm.sh/v3:Release>
from state.
Copy code
$ pulumi stack --show-urns                                                                        
Current stack is tests:
    Managed by 
    Last updated: 1 minute ago (2022-02-24 19:37:54.659899 +0900 JST)
    Pulumi version: v3.25.0
Current stack resources (3):
    TYPE                              NAME
    pulumi:pulumi:Stack               test-tests
    │  URN: urn:pulumi:tests::test::pulumi:pulumi:Stack::test-tests
    ├─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test
    │     URN: urn:pulumi:tests::test::kubernetes:<http://helm.sh/v3:Release::nx-test|helm.sh/v3:Release::nx-test>
    └─ pulumi:providers:kubernetes    default_3_16_0
          URN: urn:pulumi:tests::test::pulumi:providers:kubernetes::default_3_16_0

Current stack outputs (0):
    No output values currently in this stack

Use `pulumi stack select` to change stack; `pulumi stack ls` lists known ones

$ pulumi state delete urn:pulumi:tests::test::kubernetes:<http://helm.sh/v3:Release::nx-test|helm.sh/v3:Release::nx-test>                                                                            
 warning: This command will edit your stack's state directly. Confirm? Yes
Resource deleted successfully
7. Ran the pulumi code in number 2. But it was failed too.
Copy code
$ pulumi up
Previewing update (tests):
     Type                              Name              Plan       Info
     pulumi:pulumi:Stack               test-tests             
 =   └─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test           import     [diff: +repositoryOpts]; 1 warning
 
Diagnostics:
  kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release> (nx-test):
    warning: inputs to import do not match the existing resource; importing this resource will fail
 

Do you want to perform this update? yes
Updating (tests):
     Type                              Name              Status                   Info
     pulumi:pulumi:Stack               test-tests.       **failed**               1 error
 =   └─ kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>  nx-test           **importing failed**     1 error
 
Diagnostics:
  kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release> (nx-test):
    error: inputs to import do not match the existing resource
 
  pulumi:pulumi:Stack (tests):
    error: update failed
 
Resources:
    1 unchanged

Duration: 7s
b
I'd try importing it with the Pulumi import command to see what code it generates to understand the delta.
aw thanks 1
n
Copy code
Do you want to perform this update? details
  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:tests::test::pulumi:pulumi:Stack::test-tests]
    = kubernetes:<http://helm.sh/v3:Release|helm.sh/v3:Release>: (import)
        [id=default/nx-test]
        [urn=urn:pulumi:tests::test::kubernetes:<http://helm.sh/v3:Release::nx-test|helm.sh/v3:Release::nx-test>]
        [provider=urn:pulumi:tests::test::pulumi:providers:kubernetes::default_3_16_0::e1c21ed6-e350-433d-ad13-7f2021b4234b]
      + repositoryOpts: {
          + repo    : "<https://charts.bitnami.com/bitnami|https://charts.bitnami.com/bitnami>"
        }
IMO, there is no
repositoryOpts
and
repoUrl
in the info of helm release.
Copy code
$ helm status nx-test
NAME: nx-test
LAST DEPLOYED: Thu Feb 24 19:37:34 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 9.8.0
APP VERSION: 1.21.6

** Please be patient while the chart is being deployed **

NGINX can be accessed through the following DNS name from within your cluster:

    nx-test-nginx.default.svc.cluster.local (port 80)

To access NGINX from outside the cluster, follow the steps below:

1. Get the NGINX URL by running these commands:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w nx-test-nginx'

    export SERVICE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].port}" services nx-test-nginx)
    export SERVICE_IP=$(kubectl get svc --namespace default nx-test-nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo "http://${SERVICE_IP}:${SERVICE_PORT}"
Hello, @bored-table-20691 Sorry to bother you… Is there any update about this issue?
b
Just FYI - I’m not a Pulumi employee/contributor, just another user.
The
helmv3.Release
resource does seem to have a
repositoryOpts
argument: https://www.pulumi.com/registry/packages/kubernetes/api-docs/helm/v3/release/#repositoryopts_nodejs
So you should be able to add this to your code.
n
Oh, thank you for your advise! I already added
repositoryOpts
in my code... I will research about this issue on pulumi code. Thank you for your help.
p
FWIW, I’m having the same issue. I think this is some kind of a bug, imports with Helm charts do not work, neither via import attribute nor via command-line directly.