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

lemon-monkey-228

05/05/2021, 12:11 PM
What’s the go-to approach for looking up a Kubernetes resource? I tried
k8s.core.v1.Secrets.get
as an example but get my hand slapped by Pulumi when it runs in an update.
Copy code
/* Returns auth from a `ServiceAccount`'s associated secret */
export const getServiceAccountAuth = (serviceAccount: ServiceAccount): pulumi.Output<{ token: string, caCert: string}> =>
    pulumi.output(serviceAccount.secrets[0].name).apply(secretName => {
        const secret = k8s.core.v1.Secret.get(secretName, secretName)
        const { token, ['ca.crt']: caCert } = secret.data.get()
        return { token, caCert }
    })
p

proud-pizza-80589

05/06/2021, 5:51 AM
we deploy the secret out of a chart,s o that might be a bit different, but this is how we do it:
Copy code
const fabricCa = new FabricCaResource(this.name, caSettings, this.config, {
      ...this.opts,
      parent: this.k8sNamespace,
    });

    const tlsCertSecret = fabricCa.chart.getResource('v1/Secret', this.namespace, 'ca-tls-cert');

    // <https://www.pulumi.com/docs/intro/concepts/resources/#resource-get>
    const updatedTlsCertSecret = k8s.core.v1.Secret.get('tls-secret', tlsCertSecret.id, {
      ...this.opts,
      dependsOn: [fabricCa],
    });
i think get is not (name, name) but (name,id)
4 Views