Amazon EKS Distro cluster
A minimal AWS TypeScript Pulumi program
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-ts-eks-distrocd pulumi-examples/aws-ts-eks-distroThis example deploys an Amazon EKS Distro cluster using a dynamic provider which utilizes kops.
Prerequisites#
Deploying the example#
After cloning this repo, from this working directory, run these commands:
-
Install the required Node.js packages:
Terminal window npm install -
Create a new stack, which is an isolated deployment target for this example:
Terminal window pulumi stack init -
Set the AWS region to deploy into:
Terminal window pulumi config set aws:region us-west-2 -
Stand up the EKS cluster, which will also deploy the Kubernetes Dashboard:
Terminal window pulumi up -
After 10-15 minutes, your cluster will be ready, and the kubeconfig JSON you’ll use to connect to the cluster will be available as an output. You can save this kubeconfig to a file like so:
Terminal window pulumi stack output kubeconfig --show-secrets >kubeconfig.jsonOnce you have this file in hand, you can interact with your new cluster as usual via
kubectl:Terminal window KUBECONFIG=./kubeconfig.json kubectl get nodes -
From there, feel free to experiment. Make edits and run
pulumi upto incrementally update your stack. For example, in order to deploy a Helm chart into your cluster, import the@pulumi/kubernetes/helmpackage, add aChartresource that targets the EKS cluster toindex.ts, and runpulumi up. Note that the Helm client must be set up in order for the chart to deploy.import * as helm from "@pulumi/kubernetes/helm";// ... existing code here ...const myk8s = new k8s.Provider("myk8s", {kubeconfig: cluster.kubeconfig.apply(JSON.stringify),});const postgres = new helm.v2.Chart("postgres", {// stable/postgresql@0.15.0repo: "stable",chart: "postgresql",version: "0.15.0",values: {// Use a stable password.postgresPassword: "some-password",// Expose the postgres server via a load balancer.service: {type: "LoadBalancer",},},}, { providers: { kubernetes: myk8s } });Once the chart has been deployed, you can find its public, load-balanced endpoint via the Kubernetes Dashboard.
Cleaning up#
Once you’ve finished experimenting, tear down your stack’s resources by destroying and removing it:
pulumi destroypulumi stack rm