While trying to import a redis custom resource to pulumi I'm getting an unknown resource type error.
Importing the resource should work
Trying to import the resource via the cli or json file always results in error and failure to import.
deploy directory and run kubectl apply -k deploy/redis instance - kubectl apply -f https://raw.githubusercontent.com/amaizfinance/redis-operator/master/example/k8s_v1alpha1_redis_cr.yamlpulumi - pulumi import kubernetes:k8s.amaiz.com/v1alpha1:Redis example exampleAlways throws the same error:
Previewing import (dev):
Type Name Plan Info
pulumi:pulumi:Stack redis-dev 1 error
= 鈹斺攢 kubernetes:k8s.amaiz.com/v1alpha1:Redis example import 1 error
Diagnostics:
kubernetes:k8s.amaiz.com/v1alpha1:Redis (example):
error: Preview failed: unknown resource type 'kubernetes:k8s.amaiz.com/v1alpha1:Redis'
pulumi:pulumi:Stack (redis-dev):
error: preview failed
This seems to happen just on import. While using crd2pulumi and creating a programmatic instance of redis, pulumi is able to create and manage the resource just fine.
pulumi version - v2.23.1
pulumi-kubernetes - 2.8.3
go - 1.16.2
@lblackstone any quick ideas what might be going on here? Is it that import can only import resources defined within the pulumi schema?
Is it that import can only import resources defined within the pulumi schema?
That would be my guess. I can't think a reason it shouldn't work in theory, but it would require extra logic for k8s CustomResources. I expect the part that's failing is the code-generation since the k8s provider doesn't have knowledge about the custom schema. This case seems fairly tricky to support, but the crd2pulumi tool includes most of the logic that would be required.
@lblackstone if this is caused by the code generation preview, is it possible to skip it during import? For example in the form of some flag for the import command
As far as I know, this isn't possible currently. I think you could still manually import the resource using the import option on the resource rather than using the pulumi import command. This blog post gives an example of this for a different resource type.
Can confirm that using that using the import option on the resource allows to import the resource properly to pulumi. Thanks for the help @lblackstone.
I would still love to see it working using the cli but programmatic import is a good solution as well
Most helpful comment
Can confirm that using that using the
importoption on the resource allows to import the resource properly topulumi. Thanks for the help @lblackstone.I would still love to see it working using the
clibut programmaticimportis a good solution as well