https://pulumi.com logo
#kubernetes
Title
# kubernetes
g

glamorous-australia-21342

05/26/2021, 2:16 PM
Anybody know how to import these custom resources (like these above)? I'm looking to just do them one by one on the CLI no code. I can import standard resources, but I'm not sure what the syntax is for the CLI for custom resources.
b

bumpy-summer-9075

05/26/2021, 2:52 PM
I had the same issue and was able to work around it by programatically importing the resources. https://pulumi-community.slack.com/archives/C84L4E3N1/p1618956726318400
g

glamorous-australia-21342

05/26/2021, 3:00 PM
Programmatically meaning you used the code option? So you hard-code in the imports then remove them after they are in the stack?
b

bumpy-summer-9075

05/26/2021, 3:00 PM
Yes exactly
g

glamorous-australia-21342

05/26/2021, 3:00 PM
Ugh I was hoping to not have to do that.
Pulumi support seems to think you can just do it via command line.
b

bumpy-summer-9075

05/26/2021, 3:01 PM
You technically should, but because of https://github.com/pulumi/pulumi-kubernetes/issues/1506 you can't.
g

glamorous-australia-21342

05/26/2021, 3:02 PM
Is the "solution" the blog post?
Custom resource stuff is confusing to me because I'm not sure which is the ID
Copy code
pulumi import kubernetes:<http://rbac.authorization.k8s.io/v1:ClusterRole|rbac.authorization.k8s.io/v1:ClusterRole> alb-aws-load-balancer-controller-role alb-aws-load-balancer-controller-role -s tqtezos/tqinfra/dev
Previewing import (tqtezos/dev)

View Live: <https://app.pulumi.com/tqtezos/asdfasdfasdf/dev/previews/213421342342342323>

     Type                                                    Name                                   Plan       Info
     pulumi:pulumi:Stack                                     asdfasdfasdf                                      1 error
 =   └─ kubernetes:<http://rbac.authorization.k8s.io/v1:ClusterRole|rbac.authorization.k8s.io/v1:ClusterRole>  alb-aws-load-balancer-controller-role  import     1 error; 1 warning

Diagnostics:
  kubernetes:<http://rbac.authorization.k8s.io/v1:ClusterRole|rbac.authorization.k8s.io/v1:ClusterRole> (alb-aws-load-balancer-controller-role):
    warning: configured Kubernetes cluster is unreachable: unable to load Kubernetes client configuration from kubeconfig file: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
    error: Preview failed: resource 'alb-aws-load-balancer-controller-role' does not exist

  pulumi:pulumi:Stack (asdfasdfasdf):
    error: preview failed
This is the same issue?
I'm not sure how to form the code - here is my try on it
Copy code
const rbac = new k8s.rbac("alb-aws-load-balancer-controller-leader-election-rolebinding".{
      import: "alb-aws-load-balancer-controller-leader-election-rolebinding"
    });
b

bumpy-summer-9075

05/26/2021, 3:47 PM
the import takes the format:
{namespace}/{metadata.name}
ClusterRole is not a custom resource so
pulumi import
should work
g

glamorous-australia-21342

05/26/2021, 3:56 PM
Copy code
pulumi import kubernetes:<http://rbac.authorization.k8s.io/v1:ClusterRole|rbac.authorization.k8s.io/v1:ClusterRole> alb-aws-load-balancer-controller-role alb-aws-load-balancer-controller-role
didnt seem to work
docs dont seem to have import notation for clusterrole
Copy code
const roleBinding = new k8s.rbac.v1.RoleBinding("alb-aws-load-balancer-controller-leader-election-rolebinding",{
  roleRef:{
    apiGroup: "<http://rbac.authorization.k8s.io|rbac.authorization.k8s.io>",
    kind: "Role",
    name: "alb-aws-load-balancer-controller-leader-election-role"
},
  subjects:[{
    kind: "ServiceAccount",
    name: "alb-aws-load-balancer-controller",
    namespace: "default"
  }]
},{
  import: "alb-aws-load-balancer-controller-leader-election-rolebinding"
});
i tried this
also tried
Copy code
import: "default/alb-aws-load-balancer-controller-leader-election-rolebinding"
and it keeps saying it doesnt exist
OK I ended up figuring it ou
had to prepend KUBECONFIG and AWS PROFILE to pulumi because it was importing using kube api instead of aws
4 Views