Summary
Amazon Elastic Kubernetes Service (Amazon EKS) is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS and on-premise. This tutorial will guide you through creating an EKS cluster on AWS.
Prerequisites
Set Up AWS Command Line Interface (CLI)
Set Up Kubernetes Command Line Tool (kubectl)
Steps
Create an Amazon VPC with public and private subnets.
$ aws cloudformation create-stack \
--region us-east-1 \
--stack-name my-eks-vpc-stack \
--template-url https://amazon-eks.s3.us-west-2.amazonaws.com/cloudformation/2020-10-29/amazon-eks-vpc-private-subnets.yaml
Create a file named cluster-role-trust-policy.json with the following policy definition.
cluster-role-trust-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Create the AWS IAM role.
$ aws iam create-role \
--role-name myAmazonEKSClusterRole \
--assume-role-policy-document file://"cluster-role-trust-policy.json"
Attach the required Amazon EKS managed IAM policy to the role.
$ aws iam attach-role-policy \
--policy-arn arn:aws:iam::aws:policy/AmazonEKSClusterPolicy \
--role-name myAmazonEKSClusterRole
Open the Amazon EKS console at https://console.aws.amazon.com/eks/home#/clusters.
Make sure that the Region selected in the top right of your console is N.Virginia (us-east-1).
Select create cluster.
On the Configure cluster page enter a name for your cluster, such as my-cluster and select myAmazonEKSClusterRole for Cluster Service Role.
On the Specify networking page, select vpc-00x0000x000x0x000 | my-eks-vpc-stack-VPC from the VPC drop down list. Leave the remaining settings at their default values and select Next.
On the Configure logging page, select Next.
On the Review and create page, select Create.
To configure your computer to communicate with your cluster, Create or update a kubeconfig file for your cluster.
$ aws eks update-kubeconfig \
--region us-east-1 \
--name my-cluster
Test your configuration.
$ kubectl get svc
Top comments (0)