Skip to content

A fast way to deploy a kubernetes cluster on AWS with EC2, terraform, ansible and kubeadm

Notifications You must be signed in to change notification settings

darklight147/kubernetes-the-easier-way

Repository files navigation

image

Kubernetes Cluster with Terraform and Ansible on AWS with Kubeadm

Quality Gate Status

Skaffold a full Kubernetes Cluster with nothing but Terraform and ansible, and deploy a sample application on it.

Prerequisites

  • Terraform (tested with 1.3.9)
  • Ansible (tested core with 2.14.4)
  • AWS CLI configured with your credentials (tested with 2.10.1)

Refer to the AWS IAM User Configuration for more information on how to configure your AWS credentials.

Clone the repository

$ git clone https://github.com/darklight147/kubernetes-the-easier-way.git
$ cd kubernetes-the-easier-way

Infrastructure preparation

Create a new S3 bucket

$ aws s3api create-bucket --bucket YOUR_BUCKET_NAME --region us-east-1

Create a new DynamoDB table

$ aws dynamodb create-table --table-name YOUR_DYNAMODB_TABLE_NAME --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1

Create a new Terraform backend configuration file

$ cat > backend.tfvars <<EOF
bucket = "YOUR_BUCKET_NAME"
dynamodb_table = "YOUR_DYNAMODB_TABLE_NAME"
region = "YOUR_AWS_REGION"
key = "terraform.tfstate"
EOF

Structure

Finally, here is the structure of the project you just ended up with:

.
├── IAM.md
├── README.md
├── ansible
│   └── k8s.yml
├── backend.tfvars
├── main.tf
├── outputs.tf
├── providers.tf
└── variables.tf

2 directories, 11 files

Usage

  1. Initialize Terraform
$ terraform init -backend-config=backend.tfvars
  1. Create the infrastructure
$ terraform apply
  1. Say yes to the prompt and wait for the infrastructure to be created.

  2. Done! You now have a fully functional Kubernetes cluster with 1 master and 1 worker.

About

A fast way to deploy a kubernetes cluster on AWS with EC2, terraform, ansible and kubeadm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages