Hi folks- I’m trying to instantiate & use a ku...
# typescript
g
Hi folks- I’m trying to instantiate & use a kubernetes config from another stack and having trouble getting the argument types right. Can anyone point me in the right direction? code and error message follows in thread.
Code:
Copy code
let kubeConfig = new pulumi.StackReference("mikedougherty/megadoomer-core/main").getOutput("kubeconfig");
let kubernetes = new k8s.Provider("k8s", { kubeconfig: kubeConfig} );

const vpn = new k8s.helm.v2.Chart("openvpn", {
    repo: "stable",
    chart: "openvpn",
    values: {
        "openvpn.OVPN_K8S_POD_NETWORK": "10.1.0.0",
        "openvpn.OVPN_K8S_POD_SUBNET": "255.255.0.0",
        "openvpn.OVPN_NETWORK": "10.1.240.0",
        "openvpn.OVPN_SUBNET": "255.255.255.0",
        "openvpn.redirectGateway": false,
    },
}, { providers: [kubernetes] });
and i’ve tried a few other variations for the
{providers: ...}
map in the final argument as well.
Error message from preview portion of `pulumi up`:
Copy code
error: pulumi:providers:kubernetes resource 'k8s's property 'kubeconfig' value {map[...]} has a problem: provider property values must be strings
(map contents redacted / removed for brevity)
b
you try making it a string?
Copy code
let kubernetes = new k8s.Provider("k8s", { kubeconfig: JSON.stringify(kubeConfig)} );
s
The kubeconfig property wants the YAML version of the config - in AKS (for example) that is exposed via `kubeConfigRaw`(in typescript). I’m not 100% certain about how it’s exposed by others - but that’s the issue here.
g
@busy-umbrella-36067 your solution worked with a slight tweak:
Copy code
let kubernetes = new k8s.Provider("k8s", { kubeconfig: kubeConfig.apply(JSON.stringify) } );
. thanks! i thought that the problem was in the
new Chart
but I guess was looking in the wrong place. thanks very much!
🎉 1
@stocky-spoon-28903 thanks, i might check in on switching to AKS at some point and will keep that in mind