In this repository, you can create kubernetes cluster using only terraform apply in AWS.
- Configure on your docker $ docker run -it graykode/aws-kubeadm-terraform:0.3 /bin/bash Export your own AWS Access / Secret keys
$ export AWS_ACCESS_KEY_ID= $ export AWS_SECRET_ACCESS_KEY=
-
Deploy the infrastructure using Terraform
terraform init terraform plan terraform apply
-
Destroy infrastructure
terraform destroy
-
Prepare the requirements and run the app using the
docker-compose
on the local ;cd app pip install pipreqs pipreqs . # docker-compose up
-
Go to the browser and open the
http://localhost:3000/
-
Destroy the docker containers;
docker-compose down
cd app
aws ecr get-login-password \
--region eu-central-1 \
--profile myAccount \
| docker login \
--username AWS \
--password-stdin 927869708525.dkr.ecr.eu-central-1.amazonaws.com
docker build -t 927869708525.dkr.ecr.eu-central-1.amazonaws.com/demo:0.1 .
docker push 927869708525.dkr.ecr.eu-central-1.amazonaws.com/demo:0.1
##########
Terraform code to create a kube cluster using ec2. To be used with kubeadm
- Terraform >= 1.0 # This can be updated in
provider.tf
usingrequired_version
key
-
1 VPC (Uses AWS VPC module)
- 3 private subnets and 3 public subnets (Configurable)
- Single NAT GW
-
1 Master Node
- t2.micro
-
1 Worker node - Can be configured using
worker-count
key invariables.tf
- t2.micro
-
3 Security groups
-
Configured using kubernetes documentation
-
Only the user/system from which the
terraform apply
is run, can connect to the instances created.
-
The worker nodes do not have public IPs default (Can be changed).
In order to connect to them, use ssh forwarding concept
-
Update the
key_name
key undervariables.tf
or pass the value at run time, to make use of an already existing ssh to connect to the instances. -
To initialise
terraform init
-
To run a plan
terraform plan
-
To deploy infrastructure
terraform apply
-
To destroy infrastructure
terraform destroy
If automating, pass --auto-approve
flag to apply and destroy commands
```ubuntu@ip-10-0-103-105:~$ ./get_helm.sh
Downloading https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz
Preparing to install helm and tiller into /usr/local/bin
helm installed into /usr/local/bin/helm
tiller installed into /usr/local/bin/tiller
```Run 'helm init' to configure helm.
ubuntu@ip-10-0-103-105:~$ wget https://git.io/get_helm.sh
get_helm.sh 100%[===================>] 6.51K --.-KB/s in 0s
```ubuntu@ip-10-0-103-105:~$ chmod 700 get_helm.sh
ubuntu@ip-10-0-103-105:~$ ./get_helm.sh