Skip to content

Commit

Permalink
feat: load variables from script and cleanup vars (#94)
Browse files Browse the repository at this point in the history
* feat: add values.sh - rename vars

* feat: load vars from delete.sh
  • Loading branch information
tty47 authored May 25, 2023
1 parent 580da20 commit dd912fa
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 5 deletions.
12 changes: 12 additions & 0 deletions k8s/kops/delete_kops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ set -o pipefail
set -x
set -e

# =======================================================
TF_RESOURCES="../../terraform/kops-resources/"
# =======================================================

err_report() {
echo "Error on line $1"
}

trap 'err_report $LINENO' ERR

# =======================================================

# Load values form the file
if [ -f ./values.sh ];then
source ./values.sh
else
echo "[ERROR] Please, you need to fill the values in the script [values.sh]"
exit 1
fi

# =======================================================
echo "Create EFS resources & storageclasses..."
cd ${TF_RESOURCES}
Expand Down
10 changes: 10 additions & 0 deletions k8s/kops/install_k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ err_report() {
trap 'err_report $LINENO' ERR
# =======================================================
START_TIME=`date +%s`
# =======================================================

# Load values form the file
if [ -f ./values.sh ];then
source ./values.sh
else
echo "[ERROR] Please, you need to fill the values in the script [values.sh]"
exit 1
fi

# =======================================================
echo "Creating cluster for Testground..."
echo
Expand Down
27 changes: 27 additions & 0 deletions k8s/kops/values.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# =======================================================
# Description:
# This script is used to load the values.
# =======================================================

export CLUSTER_NAME=
export DEPLOYMENT_NAME=
export WORKER_NODE_TYPE=
export MASTER_NODE_TYPE=
export MIN_WORKER_NODES=
export MAX_WORKER_NODES=
export TEAM=
export PROJECT=
export AWS_REGION=
export KOPS_STATE_STORE=s3://
export ZONE_A=
export ZONE_B=
export PUBKEY=
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)

# Node types -> https://aws.amazon.com/es/ec2/instance-types/
# c5.2xlarge # 8CPU/16RAM
# c5.4xlarge # 16CPU/32RAM
# c5.9xlarge # 36CPU/72RAM
# c5a.24xlarge # 96CPU/192RAM
2 changes: 1 addition & 1 deletion terraform/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# tf-testground
# Terraform TestGround

We are deploying the resources in the region `eu-west-1` because is the one that has more resources available.
2 changes: 1 addition & 1 deletion terraform/backend.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
backend "s3" {
bucket = "testground-terraform-state"
key = "devops-2-tg"
key = "testground.k8s.local"
region = "eu-west-1"
}
}
2 changes: 2 additions & 0 deletions terraform/kops-resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.terraform
.terraform.lock.hcl
2 changes: 1 addition & 1 deletion terraform/kops-resources/backend.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
backend "s3" {
bucket = "testground-terraform-state"
key = "jose.k8s.local-tf-state-devops-tg"
key = "testground.k8s.local"
region = "eu-west-1"
}
}
3 changes: 1 addition & 2 deletions terraform/kops-resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//################################################################################
locals {
region = "eu-west-1"
//project_name = "testground-devops-k8s-local"
project_name = "tgdevops-k8s-local"
project_name = "testground-k8s-local"

azs = ["${local.region}a", "${local.region}b"]
vpc_id = data.aws_vpc.selected.id
Expand Down

0 comments on commit dd912fa

Please sign in to comment.