-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
33 lines (26 loc) · 1.32 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Create AWS EKS and then deploy app with ingress
create_all: create_tf_backend create_tf_infra deploy_kubernetes_app
## Delete all items in AWS and EKS that were created through the scripts
delete_all: delete_kubernetes_app delete_tf_infra delete_tf_backend
## Create bucket using AWS S3 for acting as Terraform backend
create_tf_backend:
terraform -chdir=modules/terraform-backend-s3 init && terraform -chdir=modules/terraform-backend-s3 apply -auto-approve
## Create infra using terraform, incl. EKS, subnets, VPC etc.
create_tf_infra:
terraform init && terraform apply -var-file="network.tfvars"
terraform output eks_kubeconfig > /tmp/.kubeconfig
sed -n -e "2,$$(($$(wc -l < /tmp/.kubeconfig) - 1))p" /tmp/.kubeconfig > .kubeconfig
## Create resources in kubernetes
deploy_kubernetes_app:
KUBECONFIG=.kubeconfig kubectl apply -f kubernetes/
sleep 30
albdns=$$(KUBECONFIG=.kubeconfig kubectl get ing 2048-ingress -n 2048-game -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2> /dev/null) && echo $$albdns
## Delete resources in kubernetes
delete_kubernetes_app:
KUBECONFIG=.kubeconfig kubectl delete -f kubernetes/
## Delete TF backend
delete_tf_backend:
terraform -chdir=modules/terraform-backend-s3 destroy
## delete all infra set up using terraform, incl. EKS, subnets, VPC etc.
delete_tf_infra:
terraform destroy