This message was deleted.
# kubernetes
s
This message was deleted.
p
import { local } from "@pulumi/command";
import * as eks from "@Pulumi/eks";
const cluster = new eks.Cluster("cluster", {});
const createKubernetesNamespace = new local.Command("createKubernetesNamespace", {
create: "kubectl create namespace test-namespace",
environment: {
KUBECONFIG: cluster.kubeconfig,
},
});
Diagnostics: commandlocalCommand (createKubernetesNamespace): error: 1 failures decoding: environment[KUBECONFIG] value: An error occurred decoding 'command.environment[KUBECONFIG] value': Cannot decode Object{} to type string; it isn't a struct, and no custom decoder exists
g
The
KUBECONFIG
env var is expecting a path, but the
.kubeconfig
property is returning the kubeconfig as an object. This worked for me locally:
Copy code
import { local } from "@pulumi/command";

new local.Command("createNamespace", {
    create: "kubectl create namespace test-namespace",
    delete: "kubectl delete namespace test-namespace",
    environment: {
        KUBECONFIG: `/Users/levi/.kube/config`,
    }
});
🙌 1
p
hi @gorgeous-egg-16927, Thank you again for earlier response! Looking to use the kubeconfig through the program and not have to refer it locally. The use case is to delete few Kubernetes resources which get created by default and hence try to use the Pulumi command to achieve that
Was trying this approach using the pulumi command however experiencing an error
const my_kubeconfig = '{"apiVersion":"v1","clusters":{"certificate-authority-data":****},{"name":"AWS_PROFILE","value":"default"}]}}}]}' const deleteTestNamespace = new local._Command_("deleteTestNamespace", { create:
kubectl --config <(echo ${my_kubeconfig}) delete namespace test-namespace
, });
Got the following error - error: /bin/sh: -c: line 0: syntax error near unexpected token `(' - error: exit status 2. Could you please let me know if this achievable ?