https://pulumi.com logo
#general
Title
# general
e

elegant-dress-88912

01/13/2020, 7:01 AM
Hello, I'm trying to import existing helm chart resources into Pulumi with:
Copy code
const redis = new k8s.helm.v2.Chart(
...
    transformations: [
      addNamespace(redisNamespace.metadata.name),
      args => {
        if (args.props.metadata && args.props.metadata.name) {
          return {
            props: args.props,
            opts: pulumi.mergeOptions(args.opts, {
              import: args.props.metadata.name
            })
          };
        }
        return undefined;
      }
    ]
  }
);
However, this fails with
Copy code
$ pulumi up

 +   ├─ kubernetes:helm.sh:Chart        redis                  create
 =   │  ├─ kubernetes:core:Service      redis-headless         import     1 error
 =   │  ├─ kubernetes:core:ConfigMap    redis                  import     [diff: +data~metadata]; 1 warning
 =   │  ├─ kubernetes:core:ConfigMap    redis-health           import     1 error
 =   │  ├─ kubernetes:core:Service      redis-master           import     1 error
 =   │  ├─ kubernetes:core:Secret       redis                  import     1 error
 =   │  └─ kubernetes:apps:StatefulSet  redis-master           import     1 error
 =   └─ kubernetes:core:Namespace       redis                  import

Diagnostics:
  kubernetes:core:Service (redis-master):
    error: Preview failed: resource 'redis-master' does not exist

  kubernetes:core:Service (redis-headless):
    error: Preview failed: resource 'redis-headless' does not exist

  kubernetes:core:ConfigMap (redis):
    warning: inputs to import do not match the existing resource; importing this resource will fail
...
Errors stating that resource does not exist are wrong - resources are here. The thing is that pulumi checks resources under
default
namespace - I verified it by creating cm
default/redis
and it shows different error for the resource. Another concern is "warning: inputs to import do not match the existing resource; importing this resource will fail" - how do I force pulumi to take over this resource? For now I have to deploy chart into a different namespace, export stack state into a file, edit it by replacing namespace name, destroy resources, and reimport modified state. I.e. I can't just use this import feature of pulumi.
25 Views