sparse-intern-71089
03/21/2020, 9:17 PMwhite-balloon-205
SomeResource.get(id)
.
If you want to adopt them under management of your Pulumi program to modify them, you can use { import: id }
.
But note that you can't currently also modify the resource in the same deployment you import it - so the somewhat common thing in this case of "I want to adopt the resource and change it to be different than what it is already", doesn't have a great 1st-class answer yet. We have a few places where we've seen shelling out to kubectl apply
work as a temporary solution. https://github.com/pulumi/pulumi-kubernetes/issues/264 is tracking this.
Do any of those match what you are trying to do?acoustic-leather-88378
03/22/2020, 6:54 PMIf you just want to read them in and reference state associated with them, you can useI've tried both.SomeResource.get(id)
.get
and import
in my example with limited success.
I'm using the https://github.com/zalando/postgres-operator to spin up a Postgres cluster and as part of that, a Secret
is created when the cluster is created containing the database credentials. The problem is whether I use .get
or import
:
const databaseSecret = kx.Secret.get("<http://test.test-cluster.credentials.postgresql.acid.zalan.do|test.test-cluster.credentials.postgresql.acid.zalan.do>",
"default/test.test-cluster.credentials.postgresql.acid.zalan.do");
this fails at preview with a "resource ... does not exist" error. If I skip preview (--skip-preview
) the first time it still fails with same missing error. If I cancel that and run again, it succeeds (because the Secret
is now created).
I believe it comes down to a timing issue. The Secret
hasn't been created by the operator by the time the code for .get
or import
tries to bring it into state.
Is there a way to retry for a period of time (like some other Kubernetes resources) to allow enough time for the operator to create the cluster and the resulting Secret
?acoustic-leather-88378
03/22/2020, 7:15 PM--skip-preview
by depending on the database cluster `CustomResource`:
...
const database = new CustomResource("test-cluster", {
apiVersion: "<http://acid.zalan.do/v1|acid.zalan.do/v1>",
kind: "postgresql",
metadata: {
name: "test-cluster"
},
spec: {
...
}
}
...
const databaseSecret = k8s.core.v1.Secret.get("<http://test.test-cluster.credentials.postgresql.acid.zalan.do|test.test-cluster.credentials.postgresql.acid.zalan.do>",
"default/test.test-cluster.credentials.postgresql.acid.zalan.do", {
dependsOn: database
});
and then the dependencies work out the timing issue.
However, I still have to --skip-preview
. Is there a way to preserve the preview?