Hi All, I have just started exploring pulumi IaC. ...
# getting-started
s
Hi All, I have just started exploring pulumi IaC. Iam stuck at a point please let me know if someone can help. Thanks.
b
What are you having problems with?
s
Iam trying to create a eks cluster and deploy some apps into but getting the below error kubernetescore/v1Service (dev-nginx-svc): error: configured Kubernetes cluster is unreachable: unable to load Kubernetes client configuration from kubeconfig file: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
b
When you create the cluster, what are you doing with the kubeconfig? Are you using it to create a provider, or adding it to your local ~/.kube/config ?
s
creating a provider
b
Can you share some code?
s
Copy code
const k8sProvider = new k8s.Provider("k8sProvider",{kubeconfig: "kubeconfig.json"});
Copy code
const appName = "dev-nginx";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: {
     namespace: "kube-system",
     labels: appLabels
     },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
},{provider: k8sProvider});
b
I think the issue is where the kubeconfig.json comes from. If you're setting up EKS with Pulumi, you can do something like this:
Copy code
import * as eks from "@pulumi/eks";
const cluster = new eks.Cluster("my-cluster");

const k8sProvider = new k8s.Provider("k8sProvider",{kubeconfig: cluster.kubeconfig});
And then go on from there
s
okay, I will try this
Hi, Thanks for helping it worked for me.🙂
Iam getting another error while trying to dpeloy elastic search, prometheus on the cluster through pulumi helmchart deployment.
error: 3 errors occurred: * resource kube-system/elasticsearch-master was successfully created, but the Kubernetes API server reported that it failed to fully initialize or become live: 'elasticsearch-mas ter' timed out waiting to be Ready * 0 out of 3 replicas succeeded readiness checks * StatefulSet controller failed to advance from revision "" to revision "" error: 2 errors occurred: * resource kube-system/elasticsearch-master-headless was successfully created, but the Kubernetes API server reported that it failed to fully initialize or become live: 'elastics earch-master-headless' timed out waiting to be Ready * Service does not target any Pods. Selected Pods may not be ready, or field '.spec.selector' may not match labels on any Pods
can you please help regarding the same
b
Can you share the code for this?
s
Copy code
const cluster = new eks.Cluster("my-cluster");

const k8sProvider = new k8s.Provider("k8sProvider",{kubeconfig: cluster.kubeconfig});
const elasticSearch = new k8s.helm.v2.Chart("elasticsearch",
  {
    repo: "elastic",
    chart: "elasticsearch",
    version: "7.13.0",
    namespace: "kube-system",
  },
  { provider: k8sProvider }
);
 const Prometheus = new k8s.helm.v2.Chart("prometheus", {
    repo: "stable",
    chart: "prometheus",
    namespace: "kube-system"
}, {providers: {kubernetes: k8sProvider}})
b
I've adapted your code slightly and this all deployed fine for me:
Copy code
const cluster = new eks.Cluster("my-cluster");
const k8sProvider = new k8s.Provider("k8sProvider",{kubeconfig: cluster.kubeconfig});
const elasticSearch = new k8s.helm.v3.Chart("elasticsearch",
  {
    repo: "elastic",
    chart: "elasticsearch",
    version: "7.13.0",
    namespace: "kube-system",
    fetchOpts: {
        repo: "<https://helm.elastic.co>"
    }
  },
  { provider: k8sProvider }
);
 const Prometheus = new k8s.helm.v3.Chart("prometheus", {
    repo: "stable",
    chart: "prometheus",
    namespace: "kube-system",
    fetchOpts: {
        repo: "<https://prometheus-community.github.io/helm-charts>"
    }
}, {provider: k8sProvider})
Give that a go
I've updated the provider for the prometheus helm chart, changed all the charts so they target v3 of the api and also added the
fetchops
(you might not need this last one, but I don't have helm charts on my local machine)
s
Thanks for the update will try and update you.
Hi, I used the code its throwing this error
Error: invocation of kuberneteshelmtemplate returned an error: failed to generate YAML for specified Helm chart: failed to pull chart: no cached repo found. (try 'helm repo update'): open C\Users\ST0072~1\AppData\Local\Temp\helm\repository\kiwigrid index.yaml The system cannot find the file specified.
its there something I must be missing ?
b
that might be because you've downloaded them separately. Try removing the
fetchOpts
input from each of the helm resources
s
Hi, I tried removing fetchOpts still giving the same error.