I am currently evaluating if Pulumi is something t...
# general
I am currently evaluating if Pulumi is something that we make use of for managing and bootstrapping our fleet of kubernetes cluster. idea is to bootstrap in common services (efk stack, ingress, namespaces, service account, etc...) i am doing something relatively simple in TypeScript because it has the kubernetes extension SDK, i wrote the same thing in Go and that's fine.
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";

const config = new pulumi.Config();
const provider = new k8s.Provider("kubernetes", { kubeconfig: config.require("cluster-config") });

const ta = new k8s.core.v1.ServiceAccount("test-account", {
    metadata: {
        name: "test-account",
        namespace: "default"
}, { provider });

export const tokenName = pulumi.interpolate `${ta.metadata.namespace}/${ta.secrets[0].name}`

type KubernetesData = { [key: string]: string }

export const token = k8s.core.v1.Secret.get(tokenName, tokenName).data.apply(v => {
    return (<KubernetesData>v)["token"]

// export const token = k8s.core.v1.Secret.get("default/test-account-token-7rz8w", "default/test-account-token-7rz8w").data.apply(v => {
//     return (<KubernetesData>v)["token"]
// });
1. Argument of type 'Output<string>' is not assignable to parameter of type 'string'.ts(2345) 2. Parameter 'v' implicitly has an 'any' type. however, if i use the call that is commented or this
Copy code
export const token = k8s.core.v1.Secret.get("harcoded-works", tokenName).data.apply(v => {
    return (<KubernetesData>v)["token"]
is this here a less verbose method to getting values from one resource and feed it into another?
If I understand your question correctly, it looks like you’re trying to extract the token value as a
and use that value elsewhere in your program. The reason you got the error is because the
methods return an
, which is a computed value (i.e. Promise). This means that the value isn’t known prior to running the update. Rather than trying to use the string value directly, you can pass the Output values around to other resources, and they will be resolved correctly during the update. https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs explains this in more detail We also have extensive k8s-specific examples here: https://www.pulumi.com/docs/guides/crosswalk/kubernetes/
the problem is the
which i interpolate into a string and pass that to the
method. if i change
it works
Ah, understood. Currently, the
methods only accept a
for the
arg, not an Output. I can’t recall if there’s a technical reason for that, but you’re welcome to open an issue on the pulumi-kubernetes repo. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/kubernetes/core/v1/#Secret-get