I'm trying to create an EKS cluster and then deplo...
# general
e
I'm trying to create an EKS cluster and then deploy helm charts to it. The code for the cluster is in the same projects/file as for deploying the chart. However, when I do a
pulumi up
it says:
Copy code
Diagnostics:
  kubernetes:core:ConfigMap (kube-system/online-splunk-config):
    error: Unable to read kubectl config: invalid configuration: no configuration has been provided
Obviously the kubeconfig doesn't yet exist because the cluster isn't created. Once the cluster is created I need to write out the kubeconfig, copy it somewhere, then configure the local helm to use it. Is there an example of this workflow?
m
Yes: a
kubeconfig
that is usable with the cluster is exported by the EKS component.
So in the Pulumi program that stands up your EKS cluster, you can do the following:
Copy code
export const kubeconfig = cluster.kubeconfig;
(assuming you did
const cluster = new eks.Cluster(...);
earlier)
e
How does that feed into the helm chart deployment?
m
Once your stack has been created, you can run
pulumi stack output kubeconfig > eks-kubeconfig.json
and then set the
KUBECONFIG
environment variable to point to
eks-kubeconfig.json
Oh, hang on
e
Can this be done programmaticaly so I can just do
pulumi up
without running other commands?
m
I missed the first part of your question
i.e. that you're deploying the EKS cluster and the charts in the same Pulumi program
We do have first-class support for this
e
E.g. code the kubeconfig as the input to the helm chart: something like:
Copy code
// Deploy the Splunk forwarder to the cluster
const wordpress = new k8s.helm.v2.Chart("splunk-forwarder", {
    kubeconfig: cluster.kubeconfig,
    repo: "sdp-helm",
    version: "0.2.75",
    chart: "splunk-forwarder",
});
m
Copy code
// Deploy the Splunk forwarder to the cluster
const wordpress = new k8s.helm.v2.Chart("splunk-forwarder", {
    repo: "sdp-helm",
    version: "0.2.75",
    chart: "splunk-forwarder",
}, {providers: {kubernetes: cluster.provider}});
should do the trick
The critical piece being
{providers: {kubernetes: cluster.provider}}
e
ah, thanks!