Skip to content

Commit

Permalink
modified k8s arch manifest composition
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycook123 committed Sep 6, 2023
1 parent 7be3a39 commit c333887
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 56 deletions.
28 changes: 10 additions & 18 deletions terraform/k8s/archs/arch1/app.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,15 @@ kubectl config set-context --current --namespace=cloudacademy

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

echo -e "\nSTEP2: create secret resource...\n"
echo -e "\nSTEP2: create Ingress resource...\n"

cp ./templates/1_secret.yaml ./manifests/
cp ./templates/1_ingress.yaml ./manifests/

kubectl apply -f ./manifests/1_secret.yaml
kubectl apply -f ./manifests/1_ingress.yaml

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

echo -e "\nSTEP3: create Ingress resource...\n"

cp ./templates/2_ingress.yaml ./manifests/

kubectl apply -f ./manifests/2_ingress.yaml

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

echo -e "\nSTEP4: patch Ingress resource...\n"
echo -e "\nSTEP3: patch Ingress resource...\n"

# shortcut to reuse the FQDN assigned to the nginx ingress controller ELB
# not recommended for production environments (proper DNS management should be used - R53 etc)
Expand All @@ -37,22 +29,22 @@ kubectl patch ingress public --type json -p "[{\"op\": \"replace\", \"path\": \"

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

echo -e "\nSTEP5: create API resources...\n"
echo -e "\nSTEP4: create API resources...\n"

sed \
-e "s/RDS_AURORA_ENDPOINT/$1/g" \
./templates/3_api.yaml > ./manifests/3_api.yaml
./templates/2_api.yaml > ./manifests/2_api.yaml

kubectl apply -f ./manifests/3_api.yaml
kubectl apply -f ./manifests/2_api.yaml

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

echo -e "\nSTEP6: create APP (frontend) compute resources...\n"
echo -e "\nSTEP5: create APP (frontend) compute resources...\n"

sed \
-e "s/INGRESS_FQDN/${INGRESS_LB_FQDN}/g" \
./templates/4_frontend.yaml > ./manifests/4_frontend.yaml
./templates/3_frontend.yaml > ./manifests/3_frontend.yaml

kubectl apply -f ./manifests/4_frontend.yaml
kubectl apply -f ./manifests/3_frontend.yaml

echo -e "\ndeployment finished\n"
9 changes: 0 additions & 9 deletions terraform/k8s/archs/arch1/templates/1_secret.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: db-creds
namespace: cloudacademy
type: Opaque
stringData:
DB_USER: root
DB_PASSWORD: followthewhiterabbit
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
28 changes: 10 additions & 18 deletions terraform/k8s/archs/arch2/app.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,15 @@ kubectl config set-context --current --namespace=cloudacademy

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

echo -e "\nSTEP2: create secret resource...\n"
echo -e "\nSTEP2: create Ingress resource...\n"

cp ./templates/1_secret.yaml ./manifests/
cp ./templates/1_ingress.yaml ./manifests/

kubectl apply -f ./manifests/1_secret.yaml
kubectl apply -f ./manifests/1_ingress.yaml

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

echo -e "\nSTEP3: create Ingress resource...\n"

cp ./templates/2_ingress.yaml ./manifests/

kubectl apply -f ./manifests/2_ingress.yaml

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

echo -e "\nSTEP4: patch Ingress resource...\n"
echo -e "\nSTEP3: patch Ingress resource...\n"

# shortcut to reuse the FQDN assigned to the nginx ingress controller ELB
# not recommended for production environments (proper DNS management should be used - R53 etc)
Expand All @@ -37,22 +29,22 @@ kubectl patch ingress public --type json -p "[{\"op\": \"replace\", \"path\": \"

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

echo -e "\nSTEP5: create API resources...\n"
echo -e "\nSTEP4: create API resources...\n"

sed \
-e "s/RDS_AURORA_ENDPOINT/$1/g" \
./templates/3_api.yaml > ./manifests/3_api.yaml
./templates/2_api.yaml > ./manifests/2_api.yaml

kubectl apply -f ./manifests/3_api.yaml
kubectl apply -f ./manifests/2_api.yaml

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

echo -e "\nSTEP6: create APP (frontend) compute resources...\n"
echo -e "\nSTEP5: create APP (frontend) compute resources...\n"

sed \
-e "s/INGRESS_FQDN/${INGRESS_LB_FQDN}/g" \
./templates/4_frontend.yaml > ./manifests/4_frontend.yaml
./templates/3_frontend.yaml > ./manifests/3_frontend.yaml

kubectl apply -f ./manifests/4_frontend.yaml
kubectl apply -f ./manifests/3_frontend.yaml

echo -e "\ndeployment finished\n"
9 changes: 0 additions & 9 deletions terraform/k8s/archs/arch2/templates/1_secret.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: db-creds
namespace: cloudacademy
type: Opaque
stringData:
DB_USER: root
DB_PASSWORD: followthewhiterabbit
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
4 changes: 2 additions & 2 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ resource "terraform_data" "deploy_app" {
interpreter = ["/bin/bash", "-c"]
working_dir = "${path.module}/k8s/archs/${local.k8s.stocks_app_architecture}"
command = <<EOT
echo setting up k8s auth...
echo "setting up k8s auth..."
aws eks update-kubeconfig --region ${local.region} --name ${module.eks.cluster_name}
echo deploying app...
echo "deploying *** ${local.k8s.stocks_app_architecture} *** pattern..."
rm -f ./manifests/*.yaml
tree
./app.install.sh ${module.aurora.db_endpoint}
Expand Down

0 comments on commit c333887

Please sign in to comment.