https://pulumi.com logo
#general
Title
# general
e

early-musician-41645

10/29/2018, 11:03 PM
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

microscopic-florist-22719

10/29/2018, 11:04 PM
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

early-musician-41645

10/29/2018, 11:05 PM
How does that feed into the helm chart deployment?
m

microscopic-florist-22719

10/29/2018, 11:05 PM
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

early-musician-41645

10/29/2018, 11:07 PM
Can this be done programmaticaly so I can just do
pulumi up
without running other commands?
m

microscopic-florist-22719

10/29/2018, 11:07 PM
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

early-musician-41645

10/29/2018, 11:07 PM
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

microscopic-florist-22719

10/29/2018, 11:08 PM
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

early-musician-41645

10/29/2018, 11:11 PM
ah, thanks!
3 Views