Skip to content

Deploy K8S simple cluster on AWS using Terraform and Ansible

Notifications You must be signed in to change notification settings

Azraeht/aws-k8s-iac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create a Bare Metal K8S on AWS

Getting Started

  • Install Ansible
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible
  • Install Terraform
  • Install AWS CLI
pip install awscli
  • Configure environment
~/workspace/k8s-aws/ansible master*export AWS_ACCESS_KEY_ID='********************************'

~/workspace/k8s-aws/ansible master*export AWS_SECRET_ACCESS_KEY='**************************************'

# or

~/workspace/k8s-aws/terraform master*
❯ cat ~/.aws/credentials  
[default]
aws_access_key_id = **************************************
aws_secret_access_key = **************************************
[terraform]
aws_access_key_id = **************************************
aws_secret_access_key = **************************************
  • Replace all references of /home/bsantus/.aws to your path

Terraform the host

  • Prepare 3 hosts (1 master / 2 nodes)
~/workspace/k8s-aws/*cd terraform
~/workspace/k8s-aws/terraform*
❯ terraform init
~/workspace/k8s-aws/terraform*
❯ terraform apply -var-file=variables.tfvars

Deploy the cluster

  • Retrieve the Public IPs
~/workspace/k8s-aws master*
❯ aws ec2 describe-instances --query "Reservations[*].Instances[*].{Name:Tags[0].Value,IP:PublicIpAddress}" --output=text
35.180.131.122	controlpane
35.180.156.33	node
35.180.86.140	node
  • Update ./ansible-kubeadm/inventory
  • Deploy the cluster using Ansible
~/workspace/k8s-aws/ master*cd ansible-kubeadm
~/workspace/k8s-aws/ansible-kubeadm master*
❯ ansible-playbook -v site.yml

About

Deploy K8S simple cluster on AWS using Terraform and Ansible

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages