The following steps guide you through the process of creating an EKS cluster on AWS, with the help of Pulumi IaC framework. It takes about 30 minutes to complete.
- Step 1: Create an EKS Cluster
The AWS CLI is a unified tool that provides a consistent interface for interacting with all parts of AWS. It is a command-line tool that allows you to control your AWS services from the command line. The AWS CLI can be used to create, manage, and delete AWS resources, as well as to view and download AWS service logs.
- https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
[aws-iam-authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)
: Amazon EKS uses IAM to provide secure authentication to your Kubernetes cluster.
Run this command to quickly set and view your credentials, region, and output format. The following example shows sample values.
$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE # <-- Replace with your own access key
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY # <-- Replace with your own secret key
Default region name [None]: ap-southeast-1
Default output format [None]: yaml
Pulumi is an open-source infrastructure as code software platform that helps developers safely and predictably create, manage, and improve infrastructure. It provides a unified experience for managing infrastructure across multiple clouds and providers. Pulumi is controlled primarily using the command line interface (CLI).
- Resources: A resource is a unit of cloud infrastructure that can be created, configured, and managed with Pulumi. Resources can be anything from virtual machines to databases to storage buckets.
- Programs: A program is a collection of resources that are managed together. Programs are written in a programming language that Pulumi supports, such as Python, JavaScript, or Go.
- Stack: A stack is an isolated, independently configurable instance of a Pulumi program. Stacks are commonly used to denote different phases of development (such as development, staging, and production) or feature branches (such as feature-x-dev). A stack has three main components:
- Environments: Environments can be used to isolate different sets of resources, such as development, staging, and production environments.
- Configuration: In many cases, different stacks for a single project will need differing values. For instance, you may want to use a different number of servers for your Kubernetes cluster between your development and production stacks. The Pulumi stack config file is a YAML file that contains configuration values for a specific stack. The file is named
Pulumi.<stack-name>.yaml
, where<stack-name>
is the name of the stack. - State: The state of a Pulumi stack is a snapshot of all the resources in that stack. The state is stored in local files or in a cloud service such as Pulumi's SaaS backend and AWS S3.
- A developer writes a Pulumi program that defines the desired state of their infrastructure.
- The Pulumi program is compiled and executed by a language host.
- The language host generates a representation of the desired state of the infrastructure.
- The Pulumi deployment engine compares the desired state with the current state of the infrastructure.
- The deployment engine creates, updates, or deletes resources as needed to bring the infrastructure into the desired state.
$ pulumi login --local
$ export PULUMI_CONFIG_PASSPHRASE="" # Set passphrase env to `""`. This passphrase is required by Pulumi and was created by Lab maintainer.
$ pulumi stack select default -c # Select the `default` stack.
$ pulumi up
Updating (default):
Type Name Status
+ pulumi:pulumi:Stack 1-create-an-eks-cluster-default created
+ └─ eks:index:Cluster my-eks created
... dozens of resources omitted ...
$ pulumi stack output kubeconfig > kubeconfig.yaml
$ export KUBECONFIG=$PWD/kubeconfig.yaml
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal Ready <none> 27m v1.27.1-eks-2f008fe
ip-xxx-xxx-xxx-xxx.us-west-2.compute.internal Ready <none> 27m v1.27.1-eks-2f008fe
$ export PULUMI_CONFIG_PASSPHRASE="" # Set passphrase env to `""`. This passphrase is required by Pulumi and was created by Lab maintainer.
$ pulumi destroy -r -y -s default