Git Product home page Git Product logo

pulumi-eks's Introduction

Build Status

Pulumi Amazon Web Services (AWS) EKS Components

Pulumi's library for easily creating and managing EKS Kubernetes clusters.

Introduction

pulumi/eks provides a Pulumi component that creates and manages the resources necessary to run an EKS Kubernetes cluster in AWS.

This includes:

  • The EKS cluster control plane.
  • The cluster's worker nodes configured as node groups, which are managed by an auto scaling group.
  • The AWS CNI Plugin aws-k8s-cni to manage pod networking in Kubernetes.

References

Pre-Requisites

  1. Install Pulumi.
  2. Install Node.js.
  3. Install a package manager for Node.js, such as NPM or Yarn.
  4. Install and Configure the AWS CLI.
    • Use AWS CLI version >= 1.18.17.
    • See the AWS docs for more details.
  5. Install kubectl.

Installing

This package is available in JavaScript/TypeScript for use with Node.js. Install it using either npm or yarn.

npm:

$ npm install @pulumi/eks

yarn:

$ yarn add @pulumi/eks

Quick Examples

Create a Default EKS Cluster

The default cluster configuration will use the default VPC of the AWS user or role transiently signed in. It will create the EKS control plane and a default worker node group using an autoscaling group of two t2.medium EC2 instances.

import * as eks from "@pulumi/eks";

// Create an EKS cluster with the default configuration.
const cluster = new eks.Cluster("my-cluster");

// Export the cluster's kubeconfig.
export const kubeconfig = cluster.kubeconfig;

Once the cluster is created, you can deploy into the cluster using usual methods such as kubectl and Helm, or using the @pulumi/kubernetes SDK to deploy in various ways as shown below.

You can retrieve the new EKS cluster's kubeconfig from Pulumi by querying the stack for its output of exported variables if working with the kubectl or Helm tools directly.

pulumi stack output kubeconfig > kubeconfig.json
export KUBECONFIG=$PWD/kubeconfig.json

Deploying a Helm Chart

This example creates a EKS cluster and then deploys a Helm chart from the stable repo. We extract the cluster's kubeconfig from its Pulumi provider to specifically target this cluster for deployments with pulumi-kubernetes.

import * as eks from "@pulumi/eks";
import * as k8s from "@pulumi/kubernetes";

// Create an EKS cluster.
const cluster = new eks.Cluster("my-cluster");

// Deploy Wordpress into our cluster.
const wordpress = new k8s.helm.v2.Chart("wordpress", {
    repo: "stable",
    chart: "wordpress",
    values: {
        wordpressBlogName: "My Cool Kubernetes Blog!",
    },
}, { providers: { "kubernetes": cluster.provider } });

// Export the cluster's kubeconfig.
export const kubeconfig = cluster.kubeconfig;

Deploying a Workload

This example creates a EKS cluster and then deploys an NGINX Deployment and Service using the pulumi/kubernetes SDK, and the kubeconfig credentials from the cluster's Pulumi provider.

import * as eks from "@pulumi/eks";
import * as k8s from "@pulumi/kubernetes";

// Create an EKS cluster with the default configuration.
const cluster = new eks.Cluster("my-cluster");

// Create a NGINX Deployment and Service.
const appName = "my-app";
const appLabels = { appClass: appName };
const deployment = new k8s.apps.v1.Deployment(`${appName}-dep`, {
    metadata: { labels: appLabels },
    spec: {
        replicas: 2,
        selector: { matchLabels: appLabels },
        template: {
            metadata: { labels: appLabels },
            spec: {
                containers: [{
                    name: appName,
                    image: "nginx",
                    ports: [{ name: "http", containerPort: 80 }]
                }],
            }
        }
    },
}, { provider: cluster.provider });

const service = new k8s.core.v1.Service(`${appName}-svc`, {
    metadata: { labels: appLabels },
    spec: {
        type: "LoadBalancer",
        ports: [{ port: 80, targetPort: "http" }],
        selector: appLabels,
    },
}, { provider: cluster.provider });

// Export the URL for the load balanced service.
export const url = service.status.loadBalancer.ingress[0].hostname;

// Export the cluster's kubeconfig.
export const kubeconfig = cluster.kubeconfig;

Contributing

If you are interested in contributing, please see the contributing docs.

Code of Conduct

You can read the code of conduct here.

pulumi-eks's People

Contributors

beetahnator avatar ben-nagengast avatar cosminilie avatar cyrusnajmabadi avatar d-nishi avatar ellismg avatar hausdorff avatar houqp avatar jen20 avatar justinvp avatar lblackstone avatar lukehoban avatar metral avatar naineel avatar pgavlin avatar stack72 avatar timmyers avatar tirke avatar vranga000 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.