From 3ea8da2f257c26bfcb03e0a0d4004b091854ad2b Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Nakazone Batista Date: Mon, 12 Feb 2024 18:58:41 -0300 Subject: [PATCH] Adds Dependency Checking and Initial Implementation of Instalation via Helm --- deploy.sh | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/deploy.sh b/deploy.sh index c3adefe..ef2911a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,7 +1,26 @@ #!/bin/bash + +function check_for_dependencies() { + if ! command -v kubectl &> /dev/null; then + echo "kubectl could not be found" + exit 1 + fi + if ! command -v jq &> /dev/null; then + echo "jq could not be found" + exit 1 + fi + if ! command -v helm &> /dev/null; then + echo "helm could not be found" + exit 1 + fi +} + function configure_nginx_ingress() { - kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.9.0/deploy/static/provider/cloud/deploy.yaml + helm upgrade --install ingress-nginx ingress-nginx \ + --repo https://kubernetes.github.io/ingress-nginx \ + --namespace ingress-nginx --create-namespace + kubectl wait --namespace ingress-nginx \ --for=condition=ready pod \ --selector=app.kubernetes.io/component=controller \ @@ -22,11 +41,20 @@ function application_deploy() { kubectl apply -f ./deployment/portfolio-namespace.yaml - kubectl create secret generic backend-secret -n portfolio --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/backendSecret.json) - kubectl create secret generic frontend-secret -n portfolio --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/frontendSecret.json) - kubectl create secret generic postgres-secret -n portfolio --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/postgresSecret.json) - kubectl create secret generic redis-secret -n portfolio --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/redisSecret.json) - kubectl create secret generic storage-secret -n portfolio --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/storageSecret.json) + kubectl create secret generic backend-secret -n portfolio \ + --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/backendSecret.json); + + kubectl create secret generic frontend-secret -n portfolio \ + --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/frontendSecret.json); + + kubectl create secret generic postgres-secret -n portfolio \ + --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/postgresSecret.json); + + kubectl create secret generic redis-secret -n portfolio \ + --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/redisSecret.json); + + kubectl create secret generic storage-secret -n portfolio \ + --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" ./deployment/secrets/storageSecret.json); kubectl apply -f ./deployment/postgres kubectl wait --for=condition=available \ @@ -67,13 +95,15 @@ function application_deploy() { function main() { + check_for_dependencies + if [[ $1 == "--local" || $1 == "-l" ]]; then function kubectl { minikube kubectl -- $@ } - minikube start --driver kvm2 --cpus 3 --memory 3Gib + minikube start --driver kvm2 --cpus 4 --memory 3Gib minikube addons enable ingress-dns minikube addons enable ingress @@ -81,7 +111,8 @@ function main() { configure_cert_manager - kubectl apply -f ./deployment/cert-manager/cert-manager-issuer-dev.yaml + kubectl apply -f \ + ./deployment/cert-manager/cert-manager-issuer-dev.yaml kubectl apply -f \ ./deployment/cert-manager/cert-manager-certificate.yaml