From ff9af7f38e427d7a66d9a84b726f9ff32b617e62 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Thu, 2 Sep 2021 13:07:08 -0300 Subject: [PATCH 01/25] Created aws eks deploy formula --- vkpr/aws/eks/deploy/README.md | 13 +++++++ vkpr/aws/eks/deploy/build.sh | 11 ++++++ vkpr/aws/eks/deploy/config.json | 15 ++++++++ vkpr/aws/eks/deploy/metadata.json | 18 ++++++++++ vkpr/aws/eks/deploy/src/main.sh | 6 ++++ .../eks/deploy/src/unix/formula/formula.sh | 8 +++++ vkpr/aws/eks/destroy/README.md | 13 +++++++ vkpr/aws/eks/destroy/build.sh | 11 ++++++ vkpr/aws/eks/destroy/config.json | 15 ++++++++ vkpr/aws/eks/destroy/metadata.json | 18 ++++++++++ vkpr/aws/eks/destroy/src/main.sh | 6 ++++ .../eks/destroy/src/unix/formula/formula.sh | 8 +++++ vkpr/aws/eks/up/README.md | 13 +++++++ vkpr/aws/eks/up/build.sh | 11 ++++++ vkpr/aws/eks/up/config.json | 34 +++++++++++++++++++ vkpr/aws/eks/up/metadata.json | 18 ++++++++++ vkpr/aws/eks/up/src/main.sh | 17 ++++++++++ vkpr/aws/eks/up/src/unix/formula/formula.sh | 10 ++++++ 18 files changed, 245 insertions(+) create mode 100755 vkpr/aws/eks/deploy/README.md create mode 100755 vkpr/aws/eks/deploy/build.sh create mode 100755 vkpr/aws/eks/deploy/config.json create mode 100755 vkpr/aws/eks/deploy/metadata.json create mode 100755 vkpr/aws/eks/deploy/src/main.sh create mode 100755 vkpr/aws/eks/deploy/src/unix/formula/formula.sh create mode 100755 vkpr/aws/eks/destroy/README.md create mode 100755 vkpr/aws/eks/destroy/build.sh create mode 100755 vkpr/aws/eks/destroy/config.json create mode 100755 vkpr/aws/eks/destroy/metadata.json create mode 100755 vkpr/aws/eks/destroy/src/main.sh create mode 100755 vkpr/aws/eks/destroy/src/unix/formula/formula.sh create mode 100755 vkpr/aws/eks/up/README.md create mode 100755 vkpr/aws/eks/up/build.sh create mode 100755 vkpr/aws/eks/up/config.json create mode 100755 vkpr/aws/eks/up/metadata.json create mode 100755 vkpr/aws/eks/up/src/main.sh create mode 100755 vkpr/aws/eks/up/src/unix/formula/formula.sh diff --git a/vkpr/aws/eks/deploy/README.md b/vkpr/aws/eks/deploy/README.md new file mode 100755 index 00000000..79368789 --- /dev/null +++ b/vkpr/aws/eks/deploy/README.md @@ -0,0 +1,13 @@ +# Description + +Formula description + +## Command + +```bash +rit vkpr aws eks deploy +``` + +## Requirements + +## Demonstration diff --git a/vkpr/aws/eks/deploy/build.sh b/vkpr/aws/eks/deploy/build.sh new file mode 100755 index 00000000..3f067481 --- /dev/null +++ b/vkpr/aws/eks/deploy/build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +BIN_FOLDER=bin +BINARY_NAME_UNIX=run.sh +ENTRY_POINT_UNIX=main.sh + +#bash-build: + mkdir -p $BIN_FOLDER + cp -r src/* $BIN_FOLDER + mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX diff --git a/vkpr/aws/eks/deploy/config.json b/vkpr/aws/eks/deploy/config.json new file mode 100755 index 00000000..cfde09aa --- /dev/null +++ b/vkpr/aws/eks/deploy/config.json @@ -0,0 +1,15 @@ +{ + "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", + "inputs": [ + { + "name": "gitlab_token", + "type": "CREDENTIAL_GITLAB_TOKEN" + }, + { + "name": "gitlab_username", + "type": "CREDENTIAL_GITLAB_USERNAME" + } + ], + "template": "shell-bat", + "templateRelease:": "2.16.2" +} \ No newline at end of file diff --git a/vkpr/aws/eks/deploy/metadata.json b/vkpr/aws/eks/deploy/metadata.json new file mode 100755 index 00000000..81ad3a2e --- /dev/null +++ b/vkpr/aws/eks/deploy/metadata.json @@ -0,0 +1,18 @@ +{ + "execution": [ + "local" + ], + "os": { + "deps": [], + "support": [ + "mac", + "linux" + ] + }, + "tags": [ + "vkpr", + "aws", + "eks", + "deploy" + ] +} diff --git a/vkpr/aws/eks/deploy/src/main.sh b/vkpr/aws/eks/deploy/src/main.sh new file mode 100755 index 00000000..736f5ce4 --- /dev/null +++ b/vkpr/aws/eks/deploy/src/main.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# shellcheck source=/dev/null +. "$(dirname "$0")"/unix/formula/formula.sh --source-only + +runFormula diff --git a/vkpr/aws/eks/deploy/src/unix/formula/formula.sh b/vkpr/aws/eks/deploy/src/unix/formula/formula.sh new file mode 100755 index 00000000..f1eccf1f --- /dev/null +++ b/vkpr/aws/eks/deploy/src/unix/formula/formula.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +runFormula() { + PROJECT_ID=$(curl https://gitlab.com/api/v4/users/$GITLAB_USERNAME/projects | jq '.[0] | .id') + PIPELINE_ID=$(curl https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines | jq '.[0] | .id') + DEPLOY_ID=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[1] | .id') + curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" -X POST -s https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs/$DEPLOY_ID/play > /dev/null +} \ No newline at end of file diff --git a/vkpr/aws/eks/destroy/README.md b/vkpr/aws/eks/destroy/README.md new file mode 100755 index 00000000..e7074f83 --- /dev/null +++ b/vkpr/aws/eks/destroy/README.md @@ -0,0 +1,13 @@ +# Description + +Formula description + +## Command + +```bash +rit vkpr aws eks destroy +``` + +## Requirements + +## Demonstration diff --git a/vkpr/aws/eks/destroy/build.sh b/vkpr/aws/eks/destroy/build.sh new file mode 100755 index 00000000..3f067481 --- /dev/null +++ b/vkpr/aws/eks/destroy/build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +BIN_FOLDER=bin +BINARY_NAME_UNIX=run.sh +ENTRY_POINT_UNIX=main.sh + +#bash-build: + mkdir -p $BIN_FOLDER + cp -r src/* $BIN_FOLDER + mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX diff --git a/vkpr/aws/eks/destroy/config.json b/vkpr/aws/eks/destroy/config.json new file mode 100755 index 00000000..cfde09aa --- /dev/null +++ b/vkpr/aws/eks/destroy/config.json @@ -0,0 +1,15 @@ +{ + "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", + "inputs": [ + { + "name": "gitlab_token", + "type": "CREDENTIAL_GITLAB_TOKEN" + }, + { + "name": "gitlab_username", + "type": "CREDENTIAL_GITLAB_USERNAME" + } + ], + "template": "shell-bat", + "templateRelease:": "2.16.2" +} \ No newline at end of file diff --git a/vkpr/aws/eks/destroy/metadata.json b/vkpr/aws/eks/destroy/metadata.json new file mode 100755 index 00000000..b60a6c06 --- /dev/null +++ b/vkpr/aws/eks/destroy/metadata.json @@ -0,0 +1,18 @@ +{ + "execution": [ + "local" + ], + "os": { + "deps": [], + "support": [ + "mac", + "linux" + ] + }, + "tags": [ + "vkpr", + "aws", + "eks", + "destroy" + ] +} diff --git a/vkpr/aws/eks/destroy/src/main.sh b/vkpr/aws/eks/destroy/src/main.sh new file mode 100755 index 00000000..736f5ce4 --- /dev/null +++ b/vkpr/aws/eks/destroy/src/main.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# shellcheck source=/dev/null +. "$(dirname "$0")"/unix/formula/formula.sh --source-only + +runFormula diff --git a/vkpr/aws/eks/destroy/src/unix/formula/formula.sh b/vkpr/aws/eks/destroy/src/unix/formula/formula.sh new file mode 100755 index 00000000..b7e60474 --- /dev/null +++ b/vkpr/aws/eks/destroy/src/unix/formula/formula.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +runFormula() { + PROJECT_ID=$(curl https://gitlab.com/api/v4/users/$GITLAB_USERNAME/projects | jq '.[0] | .id') + PIPELINE_ID=$(curl https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines | jq '.[0] | .id') + DESTROY_ID=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[0] | .id') + curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" -X POST -s https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs/$DESTROY_ID/play > /dev/null +} \ No newline at end of file diff --git a/vkpr/aws/eks/up/README.md b/vkpr/aws/eks/up/README.md new file mode 100755 index 00000000..b77f7784 --- /dev/null +++ b/vkpr/aws/eks/up/README.md @@ -0,0 +1,13 @@ +# Description + +Formula description + +## Command + +```bash +rit vkpr aws eks up +``` + +## Requirements + +## Demonstration diff --git a/vkpr/aws/eks/up/build.sh b/vkpr/aws/eks/up/build.sh new file mode 100755 index 00000000..3f067481 --- /dev/null +++ b/vkpr/aws/eks/up/build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +BIN_FOLDER=bin +BINARY_NAME_UNIX=run.sh +ENTRY_POINT_UNIX=main.sh + +#bash-build: + mkdir -p $BIN_FOLDER + cp -r src/* $BIN_FOLDER + mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX diff --git a/vkpr/aws/eks/up/config.json b/vkpr/aws/eks/up/config.json new file mode 100755 index 00000000..df9345a5 --- /dev/null +++ b/vkpr/aws/eks/up/config.json @@ -0,0 +1,34 @@ +{ + "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", + "inputs": [ + { + "name": "aws_access_key", + "type": "CREDENTIAL_AWS_ACCESSKEYID" + }, + { + "name": "aws_secret_key", + "type": "CREDENTIAL_AWS_SECRETACCESSKEY" + }, + { + "name": "aws_region", + "label": "Type your aws region: ", + "type": "text", + "default": "us-east-1", + "cache": { + "active": true, + "qty": 2, + "newLabel": "Type another region: " + } + }, + { + "name": "gitlab_token", + "type": "CREDENTIAL_GITLAB_TOKEN" + }, + { + "name": "gitlab_username", + "type": "CREDENTIAL_GITLAB_USERNAME" + } + ], + "template": "shell-bat", + "templateRelease:": "2.16.2" +} \ No newline at end of file diff --git a/vkpr/aws/eks/up/metadata.json b/vkpr/aws/eks/up/metadata.json new file mode 100755 index 00000000..b9615a24 --- /dev/null +++ b/vkpr/aws/eks/up/metadata.json @@ -0,0 +1,18 @@ +{ + "execution": [ + "local" + ], + "os": { + "deps": [], + "support": [ + "mac", + "linux" + ] + }, + "tags": [ + "vkpr", + "aws", + "eks", + "up" + ] +} diff --git a/vkpr/aws/eks/up/src/main.sh b/vkpr/aws/eks/up/src/main.sh new file mode 100755 index 00000000..9697102d --- /dev/null +++ b/vkpr/aws/eks/up/src/main.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ ! -d ~/.vkpr/global ]; then + echo "Doesn't initializated the vkpr... Call again the function" + rit vkpr init + exit; +fi + +source ~/.vkpr/global/log.sh +source ~/.vkpr/global/var.sh +source ~/.vkpr/global/helper.sh +source ~/.vkpr/global/.env + +# shellcheck source=/dev/null +. "$(dirname "$0")"/unix/formula/formula.sh --source-only + +runFormula diff --git a/vkpr/aws/eks/up/src/unix/formula/formula.sh b/vkpr/aws/eks/up/src/unix/formula/formula.sh new file mode 100755 index 00000000..f4a6a388 --- /dev/null +++ b/vkpr/aws/eks/up/src/unix/formula/formula.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +runFormula() { + $VKPR_GLAB auth login -h "gitlab.com" -t "$GITLAB_TOKEN" + $VKPR_GLAB repo fork vkpr/aws-eks + $VKPR_GLAB variable set "AWS_ACCESS_KEY" -m -v "$AWS_ACCESS_KEY" -R $GITLAB_USERNAME/aws-eks + $VKPR_GLAB variable set "AWS_SECRET_KEY" -m -v "$AWS_SECRET_KEY" -R $GITLAB_USERNAME/aws-eks + $VKPR_GLAB variable set "AWS_REGION" -m -v "$AWS_REGION" -R $GITLAB_USERNAME/aws-eks + $VKPR_GLAB ci run -R $GITLAB_USERNAME/aws-eks +} From 0feb1b90ae768527ef50c2d25c824ced2ae2f0e1 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Thu, 2 Sep 2021 13:22:46 -0300 Subject: [PATCH 02/25] Deleted unused variable --- vkpr/aws/eks/deploy/src/unix/formula/formula.sh | 1 - vkpr/aws/eks/destroy/src/unix/formula/formula.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/vkpr/aws/eks/deploy/src/unix/formula/formula.sh b/vkpr/aws/eks/deploy/src/unix/formula/formula.sh index f1eccf1f..e826e265 100755 --- a/vkpr/aws/eks/deploy/src/unix/formula/formula.sh +++ b/vkpr/aws/eks/deploy/src/unix/formula/formula.sh @@ -2,7 +2,6 @@ runFormula() { PROJECT_ID=$(curl https://gitlab.com/api/v4/users/$GITLAB_USERNAME/projects | jq '.[0] | .id') - PIPELINE_ID=$(curl https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines | jq '.[0] | .id') DEPLOY_ID=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[1] | .id') curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" -X POST -s https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs/$DEPLOY_ID/play > /dev/null } \ No newline at end of file diff --git a/vkpr/aws/eks/destroy/src/unix/formula/formula.sh b/vkpr/aws/eks/destroy/src/unix/formula/formula.sh index b7e60474..f6404f91 100755 --- a/vkpr/aws/eks/destroy/src/unix/formula/formula.sh +++ b/vkpr/aws/eks/destroy/src/unix/formula/formula.sh @@ -2,7 +2,6 @@ runFormula() { PROJECT_ID=$(curl https://gitlab.com/api/v4/users/$GITLAB_USERNAME/projects | jq '.[0] | .id') - PIPELINE_ID=$(curl https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines | jq '.[0] | .id') DESTROY_ID=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[0] | .id') curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" -X POST -s https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs/$DESTROY_ID/play > /dev/null } \ No newline at end of file From 1fe36abbfb862b7c329359d4009705fe4532647c Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 3 Sep 2021 09:33:01 -0300 Subject: [PATCH 03/25] Created an interval to check if the build was concluded --- vkpr/aws/eks/deploy/src/main.sh | 11 +++++++++++ vkpr/aws/eks/deploy/src/unix/formula/formula.sh | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/vkpr/aws/eks/deploy/src/main.sh b/vkpr/aws/eks/deploy/src/main.sh index 736f5ce4..24e26cf6 100755 --- a/vkpr/aws/eks/deploy/src/main.sh +++ b/vkpr/aws/eks/deploy/src/main.sh @@ -1,5 +1,16 @@ #!/bin/bash +if [ ! -d ~/.vkpr/global ]; then + echo "Doesn't initializated the vkpr... Call again the function" + rit vkpr init + exit; +fi + +source ~/.vkpr/global/log.sh +source ~/.vkpr/global/var.sh +source ~/.vkpr/global/.env +source ~/.vkpr/global/helper.sh + # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/aws/eks/deploy/src/unix/formula/formula.sh b/vkpr/aws/eks/deploy/src/unix/formula/formula.sh index e826e265..01dadc0b 100755 --- a/vkpr/aws/eks/deploy/src/unix/formula/formula.sh +++ b/vkpr/aws/eks/deploy/src/unix/formula/formula.sh @@ -2,6 +2,14 @@ runFormula() { PROJECT_ID=$(curl https://gitlab.com/api/v4/users/$GITLAB_USERNAME/projects | jq '.[0] | .id') + BUILD_COMPLETE=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[2] | .status') + SECONDS=0 + while [[ $BUILD_COMPLETE != '"success"' ]]; do + echoColor "yellow" "Pipeline still executing, await more... ${SECONDS}s passed" + sleep 30 + let "SECONDS+30" + BUILD_COMPLETE=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[2] | .status') + done DEPLOY_ID=$(curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs | jq '.[1] | .id') curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" -X POST -s https://gitlab.com/api/v4/projects/$PROJECT_ID/jobs/$DEPLOY_ID/play > /dev/null } \ No newline at end of file From 95a241d285fa3ce9f2deb6f02214c57e6e337737 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 3 Sep 2021 09:43:35 -0300 Subject: [PATCH 04/25] Install glab script in vkpr init --- vkpr/init/src/unix/formula/formula.sh | 12 ++++++++++++ vkpr/init/src/utils/var.sh | 1 + 2 files changed, 13 insertions(+) diff --git a/vkpr/init/src/unix/formula/formula.sh b/vkpr/init/src/unix/formula/formula.sh index 17d37ea0..d15c9d58 100755 --- a/vkpr/init/src/unix/formula/formula.sh +++ b/vkpr/init/src/unix/formula/formula.sh @@ -26,6 +26,7 @@ runFormula() { mkdir -p $VKPR_HOME/bats installArkade + installGlab installTool "kubectl" installTool "helm" installTool "k3d" @@ -69,6 +70,17 @@ installArkade() { fi } +installGlab() { + if [[ -f "$VKPR_HOME/bin/glab" ]]; then + echoColor "yellow" "Glab already installed. Skipping." + else + echoColor "green" "Installing Glab..." + curl -sLS https://j.mp/glab-cli > /tmp/glab.sh + chmod +x /tmp/glab.sh + /tmp/glab.sh $VKPR_HOME/bin + fi +} + installGlobals() { mkdir -p $VKPR_GLOBALS createPackagesFiles diff --git a/vkpr/init/src/utils/var.sh b/vkpr/init/src/utils/var.sh index 1198661c..6a716d23 100644 --- a/vkpr/init/src/utils/var.sh +++ b/vkpr/init/src/utils/var.sh @@ -3,6 +3,7 @@ VKPR_HOME=~/.vkpr VKPR_GLOBALS=$VKPR_HOME/global +VKPR_GLAB=$VKPR_HOME/bin/glab VKPR_K3D=$VKPR_HOME/bin/k3d VKPR_ARKADE=$VKPR_HOME/bin/arkade VKPR_KUBECTL=$VKPR_HOME/bin/kubectl From feda7e6767b69dabb53768ad6fe9c27e38e9964b Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 3 Sep 2021 11:27:55 -0300 Subject: [PATCH 05/25] Enabled ingress --- vkpr/keycloak/install/config.json | 4 ++++ vkpr/keycloak/install/src/unix/formula/formula.sh | 4 ++-- vkpr/keycloak/install/src/utils/keycloak.yaml | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vkpr/keycloak/install/config.json b/vkpr/keycloak/install/config.json index 291bede4..62d8b904 100755 --- a/vkpr/keycloak/install/config.json +++ b/vkpr/keycloak/install/config.json @@ -28,6 +28,10 @@ "label": "Type the user Password:", "name": "admin_password", "type": "password" + }, + { + "name": "password", + "type": "CREDENTIAL_POSTGRES_PASSWORD" } ], "template": "shell-bat", diff --git a/vkpr/keycloak/install/src/unix/formula/formula.sh b/vkpr/keycloak/install/src/unix/formula/formula.sh index f21f23e4..e0a7c9f0 100755 --- a/vkpr/keycloak/install/src/unix/formula/formula.sh +++ b/vkpr/keycloak/install/src/unix/formula/formula.sh @@ -20,7 +20,7 @@ runFormula() { fi addRepoKeycloak - if [[ $(verifyExistingPostgres) -eq "true" ]]; then + if [[ $(verifyExistingPostgres) = "true" ]]; then echoColor "yellow" "Initializing Keycloak with Postgres already created" VKPR_KEYCLOAK_YAML=$(dirname "$0")/utils/keycloak-db.yaml if [[ ! -n $PG_EXISTING_DATABASE ]]; then @@ -40,7 +40,7 @@ addRepoKeycloak(){ verifyExistingPostgres(){ POSTGRES=$($VKPR_KUBECTL wait --for=condition=Ready pod/postgres-postgresql-0 -o name | cut -d "/" -f2) - if [[ $POSTGRES -eq "postgres-postgresql-0" ]]; then + if [[ $POSTGRES = "postgres-postgresql-0" ]]; then echo "true" else echo "false" diff --git a/vkpr/keycloak/install/src/utils/keycloak.yaml b/vkpr/keycloak/install/src/utils/keycloak.yaml index a21135dc..6b4acae6 100644 --- a/vkpr/keycloak/install/src/utils/keycloak.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak.yaml @@ -1,9 +1,9 @@ ingress: - enabled: false + enabled: true annotations: kubernetes.io/ingress.class: nginx path: "/" - tls: true + tls: false readinessProbe: enabled: false rbac: From 42349e604ea0ef8c974cdbd7fc83ccead2337839 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 3 Sep 2021 15:57:59 -0300 Subject: [PATCH 06/25] Refactoring code to accept globals --- vkpr/keycloak/install/README.md | 17 ++--- vkpr/keycloak/install/config.json | 21 +++--- vkpr/keycloak/install/metadata.json | 2 +- vkpr/keycloak/install/src/main.sh | 13 ++-- .../install/src/unix/formula/formula.sh | 66 +++++++++---------- .../install/src/utils/keycloak-db.yaml | 31 +++++---- vkpr/keycloak/install/src/utils/keycloak.yaml | 13 +++- vkpr/keycloak/remove/README.md | 0 vkpr/keycloak/remove/src/main.sh | 13 ++-- 9 files changed, 89 insertions(+), 87 deletions(-) mode change 100755 => 100644 vkpr/keycloak/remove/README.md diff --git a/vkpr/keycloak/install/README.md b/vkpr/keycloak/install/README.md index 36b85ba3..cdbb929b 100755 --- a/vkpr/keycloak/install/README.md +++ b/vkpr/keycloak/install/README.md @@ -1,13 +1,6 @@ -# Description +# Globals file -Formula description - -## Command - -```bash -rit vkpr keycloak install -``` - -## Requirements - -## Demonstration +.global.keycloak.domain +.global.keycloak.secure +.global.keycloak.admin_user +.global.keycloak.admin_password diff --git a/vkpr/keycloak/install/config.json b/vkpr/keycloak/install/config.json index 62d8b904..8d57eca2 100755 --- a/vkpr/keycloak/install/config.json +++ b/vkpr/keycloak/install/config.json @@ -1,33 +1,32 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [ { - "default": "login.localhost", "label": "Type the Keycloak domain:", "name": "domain", - "type": "text" + "type": "text", + "default": "keycloak.localhost" }, { + "label": "Secure?", + "name": "secure", + "type": "bool", "default": "false", "items": [ "true", "false" - ], - "label": "Secure?", - "name": "secure", - "type": "bool" + ] }, { - "default": "admin", "label": "Type the Admin user:", "name": "admin_user", - "type": "text" + "type": "text", + "default": "admin" }, { - "default": "vkpr123", "label": "Type the user Password:", "name": "admin_password", - "type": "password" + "type": "password", + "default": "vkpr123" }, { "name": "password", diff --git a/vkpr/keycloak/install/metadata.json b/vkpr/keycloak/install/metadata.json index 258ab43e..080472b1 100755 --- a/vkpr/keycloak/install/metadata.json +++ b/vkpr/keycloak/install/metadata.json @@ -14,4 +14,4 @@ "keycloak", "install" ] -} +} \ No newline at end of file diff --git a/vkpr/keycloak/install/src/main.sh b/vkpr/keycloak/install/src/main.sh index 24e26cf6..b417dc84 100755 --- a/vkpr/keycloak/install/src/main.sh +++ b/vkpr/keycloak/install/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_GLOBALS=~/.vkpr/global -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_GLOBALS/log.sh +source $VKPR_GLOBALS/var.sh +source $VKPR_GLOBALS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/keycloak/install/src/unix/formula/formula.sh b/vkpr/keycloak/install/src/unix/formula/formula.sh index e0a7c9f0..3689b450 100755 --- a/vkpr/keycloak/install/src/unix/formula/formula.sh +++ b/vkpr/keycloak/install/src/unix/formula/formula.sh @@ -4,33 +4,15 @@ runFormula() { PG_USER="postgres" PG_PASSWORD=$($VKPR_JQ -r '.credential.password' ~/.rit/credentials/default/postgres) PG_DATABASE_NAME="keycloak" - PG_EXISTING_DATABASE=$(checkExistingDatabase $PG_USER $PG_PASSWORD $PG_DATABASE_NAME $PG_DATABASE_NAME) - VKPR_KEYCLOAK_YAML=$(dirname "$0")/utils/keycloak.yaml - - - if [ -z $(cat $VKPR_GLOBALS/.env | grep KEYCLOAK_ADMIN_USER) ] || [ -z $(cat $VKPR_GLOBALS/.env | grep KEYCLOAK_ADMIN_PASSWORD) ]; then - VKPR_ENV_KEYCLOAK_ADMIN_USER=$ADMIN_USER - VKPR_ENV_KEYCLOAK_ADMIN_PASSWORD=$ADMIN_PASSWORD - VKPR_ENV_SECURE=$SECURE - VKPR_ENV_DOMAIN=$DOMAIN - verifyExistingEnv 'KEYCLOAK_ADMIN_USER' "$VKPR_ENV_KEYCLOAK_ADMIN_USER" \ - 'KEYCLOAK_ADMIN_PASSWORD' "$VKPR_ENV_KEYCLOAK_ADMIN_PASSWORD" \ - 'SECURE' "$VKPR_ENV_SECURE" 'DOMAIN' "$VKPR_ENV_DOMAIN" - fi + + checkGlobalConfig $DOMAIN "keycloak.localhost" "keycloak.domain" "KEYCLOAK_DOMAIN" + checkGlobalConfig $SECURE "false" "keycloak.secure" "KEYCLOAK_SECURE" # Unused Variable TODO: See if is secure and then enable the cert-manager and TLS + checkGlobalConfig $ADMIN_USER "admin" "keycloak.admin_user" "KEYCLOAK_ADMIN_USER" + checkGlobalConfig $ADMIN_PASSWORD "vkpr123" "keycloak.admin_password" "KEYCLOAK_ADMIN_PASSWORD" addRepoKeycloak - if [[ $(verifyExistingPostgres) = "true" ]]; then - echoColor "yellow" "Initializing Keycloak with Postgres already created" - VKPR_KEYCLOAK_YAML=$(dirname "$0")/utils/keycloak-db.yaml - if [[ ! -n $PG_EXISTING_DATABASE ]]; then - createDatabase $PG_USER $PG_PASSWORD $PG_DATABASE_NAME - fi - installKeycloakDB - else - echoColor "yellow" "There is no Postgres installed, Keycloak will generate one for your use" - installKeycloak - fi + installKeycloak } addRepoKeycloak(){ @@ -39,26 +21,44 @@ addRepoKeycloak(){ } verifyExistingPostgres(){ - POSTGRES=$($VKPR_KUBECTL wait --for=condition=Ready pod/postgres-postgresql-0 -o name | cut -d "/" -f2) - if [[ $POSTGRES = "postgres-postgresql-0" ]]; then - echo "true" - else - echo "false" + EXISTING_POSTGRES=$($VKPR_KUBECTL get po/postgres-postgresql-0 -o name --ignore-not-found | cut -d "/" -f2) + if [[ $EXISTING_POSTGRES = "postgres-postgresql-0" ]]; then + POSTGRES=$($VKPR_KUBECTL wait --for=condition=Ready po/postgres-postgresql-0 -o name | cut -d "/" -f2) + if [[ $POSTGRES = "postgres-postgresql-0" ]]; then + echo "true" + return + fi fi + echo "false" } -installKeycloak(){ - $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_DOMAIN'" | +settingKeycloak(){ + $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_KEYCLOAK_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_KEYCLOAK_DOMAIN'" | .auth.adminUser = "'$VKPR_ENV_KEYCLOAK_ADMIN_USER'" | .auth.adminPassword = "'$VKPR_ENV_KEYCLOAK_ADMIN_PASSWORD'"' "$VKPR_KEYCLOAK_YAML" \ | $VKPR_HELM upgrade -i -f - keycloak bitnami/keycloak } -installKeycloakDB(){ - $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_DOMAIN'" | +settingKeycloakDB(){ + $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_KEYCLOAK_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_KEYCLOAK_DOMAIN'" | .externalDatabase.host = "postgres-postgresql" | .externalDatabase.port = "5432" | .externalDatabase.user = "'$PG_USER'" | .externalDatabase.password = "'$PG_PASSWORD'" | .externalDatabase.database = "'$PG_DATABASE_NAME'" | .auth.adminUser = "'$VKPR_ENV_KEYCLOAK_ADMIN_USER'" | .auth.adminPassword = "'$VKPR_ENV_KEYCLOAK_ADMIN_PASSWORD'"' "$VKPR_KEYCLOAK_YAML" \ | $VKPR_HELM upgrade -i -f - keycloak bitnami/keycloak +} + +installKeycloak(){ + if [[ $(verifyExistingPostgres) = "true" ]]; then + echoColor "yellow" "Initializing Keycloak with Postgres already created" + VKPR_KEYCLOAK_YAML=$(dirname "$0")/utils/keycloak-db.yaml + PG_EXISTING_DATABASE=$(checkExistingDatabase $PG_USER $PG_PASSWORD $PG_DATABASE_NAME $PG_DATABASE_NAME) + if [[ ! -n $PG_EXISTING_DATABASE ]]; then + createDatabase $PG_USER $PG_PASSWORD $PG_DATABASE_NAME + fi + settingKeycloakDB + else + echoColor "yellow" "There is no Postgres installed, Keycloak will generate one for your use" + settingKeycloak + fi } \ No newline at end of file diff --git a/vkpr/keycloak/install/src/utils/keycloak-db.yaml b/vkpr/keycloak/install/src/utils/keycloak-db.yaml index b6cfbb9e..92413d78 100644 --- a/vkpr/keycloak/install/src/utils/keycloak-db.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak-db.yaml @@ -1,19 +1,20 @@ -postgresql: - enabled: false -externalDatabase: - host: "" - port: "" - user: "" - password: "" - database: "" +resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 100m + memory: 512Mi ingress: - enabled: true + enabled: false annotations: kubernetes.io/ingress.class: nginx + hostname: keycloak.localhost certManager: false - hostname: login.localhost path: "/" - tls: true + servicePort: 80 + tls: false + existingSecret: "keycloak-cert" readinessProbe: enabled: false rbac: @@ -21,6 +22,14 @@ rbac: auth: adminUser: "" adminPassword: "" +postgresql: + enabled: false +externalDatabase: + host: "" + port: "" + user: "" + password: "" + database: "" proxyAddressForwarding: true extraEnv: | - name: JAVA_OPTS diff --git a/vkpr/keycloak/install/src/utils/keycloak.yaml b/vkpr/keycloak/install/src/utils/keycloak.yaml index 6b4acae6..39d832a7 100644 --- a/vkpr/keycloak/install/src/utils/keycloak.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak.yaml @@ -1,9 +1,20 @@ +resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 100m + memory: 512Mi ingress: - enabled: true + enabled: false annotations: kubernetes.io/ingress.class: nginx + hostname: keycloak.localhost + certManager: false path: "/" + servicePort: 80 tls: false + existingSecret: "keycloak-cert" readinessProbe: enabled: false rbac: diff --git a/vkpr/keycloak/remove/README.md b/vkpr/keycloak/remove/README.md old mode 100755 new mode 100644 diff --git a/vkpr/keycloak/remove/src/main.sh b/vkpr/keycloak/remove/src/main.sh index 9697102d..b417dc84 100755 --- a/vkpr/keycloak/remove/src/main.sh +++ b/vkpr/keycloak/remove/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_GLOBALS=~/.vkpr/global -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/helper.sh -source ~/.vkpr/global/.env +source $VKPR_GLOBALS/log.sh +source $VKPR_GLOBALS/var.sh +source $VKPR_GLOBALS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only From 68c70f7a383a59792d9941dde1f58b410595e8ad Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Wed, 8 Sep 2021 14:20:57 -0300 Subject: [PATCH 07/25] Adding ingress and TLS to keycloak --- vkpr/keycloak/install/src/utils/keycloak-db.yaml | 4 ++-- vkpr/keycloak/install/src/utils/keycloak.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vkpr/keycloak/install/src/utils/keycloak-db.yaml b/vkpr/keycloak/install/src/utils/keycloak-db.yaml index 92413d78..a9bf03b1 100644 --- a/vkpr/keycloak/install/src/utils/keycloak-db.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak-db.yaml @@ -6,14 +6,14 @@ resources: cpu: 100m memory: 512Mi ingress: - enabled: false + enabled: true annotations: kubernetes.io/ingress.class: nginx hostname: keycloak.localhost certManager: false path: "/" servicePort: 80 - tls: false + tls: true existingSecret: "keycloak-cert" readinessProbe: enabled: false diff --git a/vkpr/keycloak/install/src/utils/keycloak.yaml b/vkpr/keycloak/install/src/utils/keycloak.yaml index 39d832a7..81a02569 100644 --- a/vkpr/keycloak/install/src/utils/keycloak.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak.yaml @@ -6,14 +6,14 @@ resources: cpu: 100m memory: 512Mi ingress: - enabled: false + enabled: true annotations: kubernetes.io/ingress.class: nginx hostname: keycloak.localhost certManager: false path: "/" servicePort: 80 - tls: false + tls: true existingSecret: "keycloak-cert" readinessProbe: enabled: false From 31bc48e017811e0fa78eaf09e464b3636c9a073d Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Wed, 8 Sep 2021 14:27:23 -0300 Subject: [PATCH 08/25] Update the formula to use globals --- vkpr/init/src/unix/formula/formula.sh | 14 ++---------- vkpr/init/src/utils/helper.sh | 33 +++++++++++++++++---------- vkpr/init/src/utils/var.sh | 1 - 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/vkpr/init/src/unix/formula/formula.sh b/vkpr/init/src/unix/formula/formula.sh index 17d37ea0..710a7d21 100755 --- a/vkpr/init/src/unix/formula/formula.sh +++ b/vkpr/init/src/unix/formula/formula.sh @@ -17,10 +17,8 @@ runFormula() { echo "VKPR initialization" - # VKPR home is "~/.vkpr" VKPR_HOME=~/.vkpr VKPR_GLOBALS=$VKPR_HOME/global - # required paths mkdir -p $VKPR_HOME/bin mkdir -p $VKPR_HOME/config mkdir -p $VKPR_HOME/bats @@ -34,14 +32,6 @@ runFormula() { installTool "k9s" installGlobals installBats - # if [ "$RIT_INPUT_BOOLEAN" = "true" ]; then - # echoColor "blue" "I've already created formulas using Ritchie." - # else - # echoColor "red" "I'm excited in creating new formulas using Ritchie." - # fi - - # echoColor "yellow" "Today, I want to automate $RIT_INPUT_LIST." - # echoColor "cyan" "My secret is $RIT_INPUT_PASSWORD." } installTool() { @@ -91,8 +81,8 @@ installBats(){ } createPackagesFiles() { - touch $VKPR_GLOBALS/.env - cp $(dirname "$0")/utils/* $VKPR_GLOBALS + touch global-values.yaml + cp $(dirname "$0")/utils/*.sh $VKPR_GLOBALS } echoColor() { diff --git a/vkpr/init/src/utils/helper.sh b/vkpr/init/src/utils/helper.sh index 57bdb274..a1d4f45c 100644 --- a/vkpr/init/src/utils/helper.sh +++ b/vkpr/init/src/utils/helper.sh @@ -1,24 +1,33 @@ #!/bin/bash -verifyExistingEnv(){ - aux=0 - for i in "$@" - do - if [ -z $(cat $VKPR_GLOBALS/.env | grep $i) ]; then - if (( $aux % 2 == 0 )); then - printf "VKPR_ENV_${i}=" >> $VKPR_GLOBALS/.env - else - printf "${i}\n" >> $VKPR_GLOBALS/.env - fi - let "aux++" +# Create a variable by Global Scope +# $1: Global variable / $2: Default value of the global variable / $3: Label from config file / $4: Name of env +checkGlobalConfig(){ + CONFIG_FILE=~/.vkpr/global-config.yaml + FILE_LABEL=".global.$3" + local NAME_ENV=VKPR_ENV_$4 + if [ -f "$CONFIG_FILE" ] && [ $1 == $2 ] && [ $($VKPR_YQ eval $FILE_LABEL $CONFIG_FILE) != "null" ]; then + echoColor "yellow" "Setting value from config file" + eval $NAME_ENV=$($VKPR_YQ eval $FILE_LABEL $CONFIG_FILE) + else + if [ $1 == $2 ]; then + echoColor "yellow" "Setting value from default value" + eval $NAME_ENV=$1 + else + echoColor "yellow" "Setting value from user input" + eval $NAME_ENV=$1 fi - done + fi } +# Create a new instance of DB in Postgres; +# $1: Postgres User / $2: Postgres Password / $3: Name of DB to create createDatabase(){ $VKPR_KUBECTL run init-db --rm -it --restart="Never" --image docker.io/bitnami/postgresql:11.13.0-debian-10-r0 --env="PGUSER=$1" --env="PGPASSWORD=$2" --env="PGHOST=postgres-postgresql" --env="PGPORT=5432" --env="PGDATABASE=postgres" --command -- psql --command="CREATE DATABASE $3" } +# Check if exist some instace of DB with specified name in Postgres +# $1: Postgres User / $2: Postgres Password / $3: Name of DB to search checkExistingDatabase(){ $VKPR_KUBECTL run check-db --rm -it --restart='Never' --image docker.io/bitnami/postgresql:11.13.0-debian-10-r12 --env="PGUSER=$1" --env="PGPASSWORD=$2" --env="PGHOST=postgres-postgresql" --env="PGPORT=5432" --env="PGDATABASE=postgres" --command -- psql -lqt | cut -d \| -f 1 | grep $3 | sed -e 's/^[ \t]*//' } \ No newline at end of file diff --git a/vkpr/init/src/utils/var.sh b/vkpr/init/src/utils/var.sh index 1198661c..e6831282 100644 --- a/vkpr/init/src/utils/var.sh +++ b/vkpr/init/src/utils/var.sh @@ -1,7 +1,6 @@ #!/bin/bash VKPR_HOME=~/.vkpr -VKPR_GLOBALS=$VKPR_HOME/global VKPR_K3D=$VKPR_HOME/bin/k3d VKPR_ARKADE=$VKPR_HOME/bin/arkade From ae927f4b1346e39e521205271b9c135a0d5699f2 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Thu, 9 Sep 2021 13:31:44 -0300 Subject: [PATCH 09/25] Change init and globals set --- vkpr/cert-manager/install/src/main.sh | 13 ++++--------- vkpr/cert-manager/remove/src/main.sh | 13 ++++--------- vkpr/create/formula/src/main.sh | 13 ++++--------- vkpr/external-dns/install/src/main.sh | 13 ++++--------- vkpr/external-dns/remove/src/main.sh | 13 ++++--------- vkpr/globals/set/src/main.sh | 13 +++++-------- vkpr/infra/down/src/main.sh | 13 ++++--------- vkpr/infra/up/src/main.sh | 13 ++++--------- vkpr/ingress/install/src/main.sh | 13 ++++--------- vkpr/ingress/remove/src/main.sh | 13 ++++--------- vkpr/init/src/utils/helper.sh | 6 +++--- vkpr/init/src/utils/var.sh | 1 + vkpr/keycloak/install/src/main.sh | 8 ++++---- vkpr/keycloak/remove/src/main.sh | 8 ++++---- vkpr/postgres/install/src/main.bat | 3 --- vkpr/postgres/install/src/main.sh | 6 ++++++ vkpr/postgres/remove/src/main.bat | 3 --- vkpr/postgres/remove/src/main.sh | 6 ++++++ vkpr/template/config/src/main.bat | 3 --- vkpr/template/config/src/main.sh | 13 ++++--------- vkpr/template/config/src/unix/formula/formula.sh | 2 +- vkpr/whoami/install/src/main.sh | 13 ++++--------- vkpr/whoami/remove/src/main.sh | 6 ++++++ 23 files changed, 80 insertions(+), 128 deletions(-) delete mode 100755 vkpr/postgres/install/src/main.bat delete mode 100755 vkpr/postgres/remove/src/main.bat delete mode 100755 vkpr/template/config/src/main.bat diff --git a/vkpr/cert-manager/install/src/main.sh b/vkpr/cert-manager/install/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/cert-manager/install/src/main.sh +++ b/vkpr/cert-manager/install/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/cert-manager/remove/src/main.sh b/vkpr/cert-manager/remove/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/cert-manager/remove/src/main.sh +++ b/vkpr/cert-manager/remove/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/create/formula/src/main.sh b/vkpr/create/formula/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/create/formula/src/main.sh +++ b/vkpr/create/formula/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/external-dns/install/src/main.sh b/vkpr/external-dns/install/src/main.sh index 24e26cf6..cf647088 100644 --- a/vkpr/external-dns/install/src/main.sh +++ b/vkpr/external-dns/install/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/external-dns/remove/src/main.sh b/vkpr/external-dns/remove/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/external-dns/remove/src/main.sh +++ b/vkpr/external-dns/remove/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/globals/set/src/main.sh b/vkpr/globals/set/src/main.sh index 994db848..8a7d61d5 100755 --- a/vkpr/globals/set/src/main.sh +++ b/vkpr/globals/set/src/main.sh @@ -1,13 +1,10 @@ #!/bin/bash -if [ ! -d $CURRENT_PWD/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi - -source $CURRENT_PWD/global/log.sh -source $CURRENT_PWD/global/var.sh +VKPR_SCRIPTS=~/.vkpr/src + +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/infra/down/src/main.sh b/vkpr/infra/down/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/infra/down/src/main.sh +++ b/vkpr/infra/down/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/infra/up/src/main.sh b/vkpr/infra/up/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/infra/up/src/main.sh +++ b/vkpr/infra/up/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/ingress/install/src/main.sh b/vkpr/ingress/install/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/ingress/install/src/main.sh +++ b/vkpr/ingress/install/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/ingress/remove/src/main.sh b/vkpr/ingress/remove/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/ingress/remove/src/main.sh +++ b/vkpr/ingress/remove/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/init/src/utils/helper.sh b/vkpr/init/src/utils/helper.sh index a1d4f45c..4fd9a2b5 100644 --- a/vkpr/init/src/utils/helper.sh +++ b/vkpr/init/src/utils/helper.sh @@ -3,12 +3,12 @@ # Create a variable by Global Scope # $1: Global variable / $2: Default value of the global variable / $3: Label from config file / $4: Name of env checkGlobalConfig(){ - CONFIG_FILE=~/.vkpr/global-config.yaml + VALUES_FILE=~/.vkpr/global-values.yaml FILE_LABEL=".global.$3" local NAME_ENV=VKPR_ENV_$4 - if [ -f "$CONFIG_FILE" ] && [ $1 == $2 ] && [ $($VKPR_YQ eval $FILE_LABEL $CONFIG_FILE) != "null" ]; then + if [ -f "$VALUES_FILE" ] && [ $1 == $2 ] && [ $($VKPR_YQ eval $FILE_LABEL $VALUES_FILE) != "null" ]; then echoColor "yellow" "Setting value from config file" - eval $NAME_ENV=$($VKPR_YQ eval $FILE_LABEL $CONFIG_FILE) + eval $NAME_ENV=$($VKPR_YQ eval $FILE_LABEL $VALUES_FILE) else if [ $1 == $2 ]; then echoColor "yellow" "Setting value from default value" diff --git a/vkpr/init/src/utils/var.sh b/vkpr/init/src/utils/var.sh index e6831282..68c3b45b 100644 --- a/vkpr/init/src/utils/var.sh +++ b/vkpr/init/src/utils/var.sh @@ -1,6 +1,7 @@ #!/bin/bash VKPR_HOME=~/.vkpr +VKPR_GLOBAL=$VKPR_HOME/global-values.yaml VKPR_K3D=$VKPR_HOME/bin/k3d VKPR_ARKADE=$VKPR_HOME/bin/arkade diff --git a/vkpr/keycloak/install/src/main.sh b/vkpr/keycloak/install/src/main.sh index b417dc84..cf647088 100755 --- a/vkpr/keycloak/install/src/main.sh +++ b/vkpr/keycloak/install/src/main.sh @@ -1,10 +1,10 @@ #!/bin/bash -VKPR_GLOBALS=~/.vkpr/global +VKPR_SCRIPTS=~/.vkpr/src -source $VKPR_GLOBALS/log.sh -source $VKPR_GLOBALS/var.sh -source $VKPR_GLOBALS/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/keycloak/remove/src/main.sh b/vkpr/keycloak/remove/src/main.sh index b417dc84..cf647088 100755 --- a/vkpr/keycloak/remove/src/main.sh +++ b/vkpr/keycloak/remove/src/main.sh @@ -1,10 +1,10 @@ #!/bin/bash -VKPR_GLOBALS=~/.vkpr/global +VKPR_SCRIPTS=~/.vkpr/src -source $VKPR_GLOBALS/log.sh -source $VKPR_GLOBALS/var.sh -source $VKPR_GLOBALS/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/postgres/install/src/main.bat b/vkpr/postgres/install/src/main.bat deleted file mode 100755 index 4100614f..00000000 --- a/vkpr/postgres/install/src/main.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -call windows\formula\formula.bat runFormula diff --git a/vkpr/postgres/install/src/main.sh b/vkpr/postgres/install/src/main.sh index 736f5ce4..cf647088 100755 --- a/vkpr/postgres/install/src/main.sh +++ b/vkpr/postgres/install/src/main.sh @@ -1,5 +1,11 @@ #!/bin/bash +VKPR_SCRIPTS=~/.vkpr/src + +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh + # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/postgres/remove/src/main.bat b/vkpr/postgres/remove/src/main.bat deleted file mode 100755 index 4100614f..00000000 --- a/vkpr/postgres/remove/src/main.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -call windows\formula\formula.bat runFormula diff --git a/vkpr/postgres/remove/src/main.sh b/vkpr/postgres/remove/src/main.sh index 736f5ce4..cf647088 100755 --- a/vkpr/postgres/remove/src/main.sh +++ b/vkpr/postgres/remove/src/main.sh @@ -1,5 +1,11 @@ #!/bin/bash +VKPR_SCRIPTS=~/.vkpr/src + +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh + # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/template/config/src/main.bat b/vkpr/template/config/src/main.bat deleted file mode 100755 index 4100614f..00000000 --- a/vkpr/template/config/src/main.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -call windows\formula\formula.bat runFormula diff --git a/vkpr/template/config/src/main.sh b/vkpr/template/config/src/main.sh index 9697102d..cf647088 100755 --- a/vkpr/template/config/src/main.sh +++ b/vkpr/template/config/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/helper.sh -source ~/.vkpr/global/.env +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/template/config/src/unix/formula/formula.sh b/vkpr/template/config/src/unix/formula/formula.sh index d3fb2e44..3b3ed109 100755 --- a/vkpr/template/config/src/unix/formula/formula.sh +++ b/vkpr/template/config/src/unix/formula/formula.sh @@ -6,5 +6,5 @@ runFormula() { } outputGlobalTemplate(){ - $VKPR_YQ eval $VKPR_GLOBALS/global-values.yaml + $VKPR_YQ eval $VKPR_HOME/global-values.yaml } diff --git a/vkpr/whoami/install/src/main.sh b/vkpr/whoami/install/src/main.sh index 9697102d..cf647088 100755 --- a/vkpr/whoami/install/src/main.sh +++ b/vkpr/whoami/install/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/helper.sh -source ~/.vkpr/global/.env +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/whoami/remove/src/main.sh b/vkpr/whoami/remove/src/main.sh index 736f5ce4..cf647088 100755 --- a/vkpr/whoami/remove/src/main.sh +++ b/vkpr/whoami/remove/src/main.sh @@ -1,5 +1,11 @@ #!/bin/bash +VKPR_SCRIPTS=~/.vkpr/src + +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh + # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only From 9560e5080413045e61c2fc781859a0e3619f59c1 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Thu, 9 Sep 2021 13:33:18 -0300 Subject: [PATCH 10/25] Update the function to create globals --- vkpr/init/src/unix/formula/formula.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vkpr/init/src/unix/formula/formula.sh b/vkpr/init/src/unix/formula/formula.sh index 710a7d21..56c2e9f5 100755 --- a/vkpr/init/src/unix/formula/formula.sh +++ b/vkpr/init/src/unix/formula/formula.sh @@ -18,10 +18,12 @@ runFormula() { echo "VKPR initialization" VKPR_HOME=~/.vkpr - VKPR_GLOBALS=$VKPR_HOME/global + VKPR_SCRIPTS=$VKPR_HOME/src + mkdir -p $VKPR_HOME/bin mkdir -p $VKPR_HOME/config mkdir -p $VKPR_HOME/bats + mkdir -p $VKPR_HOME/src installArkade installTool "kubectl" @@ -60,7 +62,6 @@ installArkade() { } installGlobals() { - mkdir -p $VKPR_GLOBALS createPackagesFiles } @@ -81,10 +82,11 @@ installBats(){ } createPackagesFiles() { - touch global-values.yaml - cp $(dirname "$0")/utils/*.sh $VKPR_GLOBALS + touch $VKPR_HOME/global-values.yaml + cp $(dirname "$0")/utils/*.sh $VKPR_SCRIPTS } + echoColor() { case $1 in red) @@ -102,5 +104,7 @@ echoColor() { cyan) echo "$(printf '\033[36m')$2$(printf '\033[0m')" ;; + bold) + echo "$(printf '\033[1m')$2$(printf '\033[0m')" esac } \ No newline at end of file From f204efea78acd69538423844dacb8853be99a67b Mon Sep 17 00:00:00 2001 From: jpeedroza Date: Thu, 9 Sep 2021 14:03:23 -0300 Subject: [PATCH 11/25] Updated the config yaml --- .../install/src/utils/keycloak-db.yaml | 40 +++++++++---------- vkpr/keycloak/install/src/utils/keycloak.yaml | 33 ++++++++------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/vkpr/keycloak/install/src/utils/keycloak-db.yaml b/vkpr/keycloak/install/src/utils/keycloak-db.yaml index b6cfbb9e..32d38e69 100644 --- a/vkpr/keycloak/install/src/utils/keycloak-db.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak-db.yaml @@ -1,28 +1,28 @@ +auth: + adminUser: "" + adminPassword: "" + managementPassword: "senha" +containerPorts: + http: 8080 + https: 8443 +service: + type: ClusterIP +ingress: + enabled: true + certManager: false + hostname: keycloak.localhost + ingressClassName: "nginx" + path: / + tls: false +rbac: + create: true postgresql: enabled: false + persistence: + enabled: false externalDatabase: host: "" port: "" user: "" password: "" database: "" -ingress: - enabled: true - annotations: - kubernetes.io/ingress.class: nginx - certManager: false - hostname: login.localhost - path: "/" - tls: true -readinessProbe: - enabled: false -rbac: - create: true -auth: - adminUser: "" - adminPassword: "" -proxyAddressForwarding: true -extraEnv: | - - name: JAVA_OPTS - value: >- - -Dkeycloak.migration.file=/realm/realm.json diff --git a/vkpr/keycloak/install/src/utils/keycloak.yaml b/vkpr/keycloak/install/src/utils/keycloak.yaml index a21135dc..934ed309 100644 --- a/vkpr/keycloak/install/src/utils/keycloak.yaml +++ b/vkpr/keycloak/install/src/utils/keycloak.yaml @@ -1,18 +1,21 @@ -ingress: - enabled: false - annotations: - kubernetes.io/ingress.class: nginx - path: "/" - tls: true -readinessProbe: - enabled: false -rbac: - create: true auth: adminUser: "" adminPassword: "" -proxyAddressForwarding: true -extraEnv: | - - name: JAVA_OPTS - value: >- - -Dkeycloak.migration.file=/realm/realm.json + managementPassword: "senha" +containerPorts: + http: 8080 + https: 8443 +service: + type: ClusterIP +ingress: + enabled: true + certManager: false + hostname: keycloak.localhost + ingressClassName: "nginx" + path: / + tls: false +rbac: + create: true +postgresql: + persistence: + enabled: false From 1138df46600b0076ba791d4935e7d8b41ea038eb Mon Sep 17 00:00:00 2001 From: jpeedroza Date: Thu, 9 Sep 2021 15:58:19 -0300 Subject: [PATCH 12/25] Created test to keycloak --- vkpr-test/keycloak-test.bats | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 vkpr-test/keycloak-test.bats diff --git a/vkpr-test/keycloak-test.bats b/vkpr-test/keycloak-test.bats new file mode 100644 index 00000000..7da1e92e --- /dev/null +++ b/vkpr-test/keycloak-test.bats @@ -0,0 +1,60 @@ + +VKPR_HOME=~/.vkpr + +setup_file() { + load 'common-setup' + _common_setup + if [ "$VKPR_TEST_SKIP_SETUP" == "true" ]; then + echo "setup: skipping setup due to VKPR_TEST_SKIP_SETUP=true" >&3 + else + echo "setup: installing ingress...." >&3 + rit vkpr ingress install + kubectl wait --for=condition=ready --timeout=1m pod --all + echo "setup: installing keycloak...." >&3 + rit vkpr keycloak install --default + kubectl wait --for=condition=ready --timeout=1m pod --all + sleep 2 + fi +} + +setup() { + load $VKPR_HOME/bats/bats-support/load.bash + load $VKPR_HOME/bats/bats-assert/load.bash +} + +@test "Check if keycloak is up" { + run curlKeycloak + actual="${lines[3]}" + trim "$actual" + actual="$TRIMMED" + expected='"realm":"master"' + assert_equal "$actual" "$expected" +} + +teardown_file() { + if [ "$VKPR_TEST_SKIP_TEARDOWN" == "true" ]; then + echo "teardown: skipping teardown due to VKPR_TEST_SKIP_TEARDOWN=true" >&3 + else + echo "teardown: uninstalling ingress...." >&3 + rit vkpr keycloak remove + sleep 5 + rit vkpr ingress remove + sleep 5 + rit vkpr infra down + sleep 5 + fi +} + +curlKeycloak(){ + content=$(curl -H "Host: keycloak.localhost" http://127.0.0.1:8000/auth/realms/master) + echo ${content:1:16} +} + +trim() { + local var="$*" + # remove leading whitespace characters + var="${var#"${var%%[![:space:]]*}"}" + # remove trailing whitespace characters + var="${var%"${var##*[![:space:]]}"}" + TRIMMED="$var" +} \ No newline at end of file From 8d8e5422de21cce33dd8e2e797649ecfe0c83ef2 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 11:40:16 -0300 Subject: [PATCH 13/25] Merged test branches --- vkpr-test/postgres.bats | 41 +++++++++++++++++++++++++++++++++ vkpr-test/whoami.bats | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 vkpr-test/postgres.bats create mode 100644 vkpr-test/whoami.bats diff --git a/vkpr-test/postgres.bats b/vkpr-test/postgres.bats new file mode 100644 index 00000000..99098417 --- /dev/null +++ b/vkpr-test/postgres.bats @@ -0,0 +1,41 @@ + +VKPR_HOME=~/.vkpr + +setup_file() { + load 'common-setup' + _common_setup + if [ "$VKPR_TEST_SKIP_SETUP" == "true" ]; then + echo "setup: skipping setup due to VKPR_TEST_SKIP_SETUP=true" >&3 + else + echo "setup: installing postgres...." >&3 + rit vkpr postgres install + kubectl wait --for=condition=ready --timeout=1m pod --all + sleep 2 + fi +} + +setup() { + load $VKPR_HOME/bats/bats-support/load.bash + load $VKPR_HOME/bats/bats-assert/load.bash +} + +@test "Ping in DB and must show if is accepting connections" { + run ping_db + actual="${lines[0]}" + expected="postgres-postgresql:5432 - accepting connections" + assert_equal "$actual" "$expected" +} + +teardown_file() { + if [ "$VKPR_TEST_SKIP_TEARDOWN" == "true" ]; then + echo "teardown: skipping teardown due to VKPR_TEST_SKIP_TEARDOWN=true" >&3 + else + echo "teardown: uninstalling postgres...." >&3 + rit vkpr postgres remove + rit vkpr infra down + fi +} + +ping_db(){ + $VKPR_HOME/bin/kubectl run test-db --rm -it --restart='Never' --image docker.io/bitnami/postgresql:11.13.0-debian-10-r12 --env="PGUSER=postgres" --env="PGPASSWORD=123" --env="PGHOST=postgres-postgresql" --env="PGPORT=5432" --command -- pg_isready +} \ No newline at end of file diff --git a/vkpr-test/whoami.bats b/vkpr-test/whoami.bats new file mode 100644 index 00000000..d62425c5 --- /dev/null +++ b/vkpr-test/whoami.bats @@ -0,0 +1,50 @@ + +VKPR_HOME=~/.vkpr + +setup_file() { + load 'common-setup' + _common_setup + if [ "$VKPR_TEST_SKIP_SETUP" == "true" ]; then + echo "setup: skipping setup due to VKPR_TEST_SKIP_SETUP=true" >&3 + else + echo "setup: installing ingress...." >&3 + rit vkpr ingress install + kubectl wait --for=condition=ready --timeout=1m pod --all + echo "setup: installing whoami...." >&3 + rit vkpr whoami install --default + kubectl wait --for=condition=ready --timeout=1m pod --all + sleep 20 + fi +} + +setup() { + load $VKPR_HOME/bats/bats-support/load.bash + load $VKPR_HOME/bats/bats-assert/load.bash +} + +@test "Curl to Whoami and must return Hostname" { + run curlWhoami + actual="${lines[3]}" + expected=$(podName) + assert_equal "$actual" "$expected" +} + +teardown_file() { + if [ "$VKPR_TEST_SKIP_TEARDOWN" == "true" ]; then + echo "teardown: skipping teardown due to VKPR_TEST_SKIP_TEARDOWN=true" >&3 + else + echo "teardown: uninstalling ingress...." >&3 + rit vkpr ingress remove + rit vkpr infra down + fi +} + +podName(){ + local pod=$($VKPR_HOME/bin/kubectl get po -o name | grep whoami | cut -d "/" -f 2) + echo "Hostname: ${pod}" +} + +curlWhoami(){ + curl -k -H "Host: whoami.localhost" https://127.0.0.1:8001 | sed 's/<\/*[^>]*>//g' + sleep 5 +} \ No newline at end of file From f92bb0acd255ebf5ce4e96ce7d6de9ef389bcaa7 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:28:29 -0300 Subject: [PATCH 14/25] Whoami refactored code and formula documentation update --- vkpr/whoami/install/README.md | 45 ++++++++++++++++--- .../install/src/unix/formula/formula.sh | 7 +-- vkpr/whoami/install/src/utils/whoami.yaml | 4 +- vkpr/whoami/remove/README.md | 12 +++-- vkpr/whoami/remove/build.sh | 2 - .../whoami/remove/src/unix/formula/formula.sh | 31 +++---------- 6 files changed, 57 insertions(+), 44 deletions(-) diff --git a/vkpr/whoami/install/README.md b/vkpr/whoami/install/README.md index 4b91f82e..a82308d0 100755 --- a/vkpr/whoami/install/README.md +++ b/vkpr/whoami/install/README.md @@ -1,13 +1,48 @@ # Description -Formula description +Install whoami into cluster. Uses [whoami](https://artifacthub.io/packages/helm/cowboysysop/whoami) Helm chart. -## Command +## Commands + +Interactive inputs: + +```bash +vkpr whoami install +``` + +Non-interactive: + +```bash +vkpr whoami install --domain="whoami.localhost" \ + --secure=false +``` + +Non-interactive without setting values: + +```bash +vkpr whoami install --default +``` + +## Parameters ```bash -rit vkpr whoami install + --domain= Define the domain of whoami. Default: whoami.localhost + --secure= Define https on the whoami. Default: false + --default= Set all values with default. +``` + +## Globals File Parameters + +```yaml +global: + whoami: + domain: + secure: ``` -## Requirements +### Content installed on the Cluster -## Demonstration +- Deployment +- Service +- Ingress +- Secret (certificate) diff --git a/vkpr/whoami/install/src/unix/formula/formula.sh b/vkpr/whoami/install/src/unix/formula/formula.sh index d5ac3c3f..9821ef0b 100755 --- a/vkpr/whoami/install/src/unix/formula/formula.sh +++ b/vkpr/whoami/install/src/unix/formula/formula.sh @@ -3,7 +3,8 @@ runFormula() { VKPR_WHOAMI_VALUES=$(dirname "$0")/utils/whoami.yaml - verifyExistingEnv 'SECURE' "${SECURE}" 'DOMAIN' "${DOMAIN}" + checkGlobalConfig $DOMAIN "whoami.localhost" "whoami.domain" "WHOAMI_DOMAIN" + checkGlobalConfig $SECURE "false" "whoami.secure" "WHOAMI_SECURE" # Unused Variable TODO: See if is secure and then enable the cert-manager and TLS addRepoWhoami installWhoami } @@ -15,6 +16,6 @@ addRepoWhoami(){ installWhoami(){ echoColor "yellow" "Installing whoami..." - $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_DOMAIN'"' "$VKPR_WHOAMI_VALUES" \ - | $VKPR_HELM upgrade -i -f - whoami cowboysysop/whoami + $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_WHOAMI_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_WHOAMI_DOMAIN'"' "$VKPR_WHOAMI_VALUES" \ + | $VKPR_HELM upgrade -i -f - vkpr-whoami cowboysysop/whoami } \ No newline at end of file diff --git a/vkpr/whoami/install/src/utils/whoami.yaml b/vkpr/whoami/install/src/utils/whoami.yaml index e0ab3960..0eb982af 100644 --- a/vkpr/whoami/install/src/utils/whoami.yaml +++ b/vkpr/whoami/install/src/utils/whoami.yaml @@ -4,10 +4,10 @@ ingress: kubernetes.io/ingress.class: nginx kubernetes.io/tls-acme: "true" hosts: - - host: domain + - host: "" paths: ["/"] pathType: Prefix tls: - hosts: - - domain + - "" secretName: whoami-cert diff --git a/vkpr/whoami/remove/README.md b/vkpr/whoami/remove/README.md index 3d34af7e..5666c5d3 100755 --- a/vkpr/whoami/remove/README.md +++ b/vkpr/whoami/remove/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Uninstall all the contet of whoami from the cluster. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr whoami remove +vkpr whoami remove ``` - -## Requirements - -## Demonstration diff --git a/vkpr/whoami/remove/build.sh b/vkpr/whoami/remove/build.sh index 341574b7..cfabf0a0 100755 --- a/vkpr/whoami/remove/build.sh +++ b/vkpr/whoami/remove/build.sh @@ -2,9 +2,7 @@ BIN_FOLDER=bin BINARY_NAME_UNIX=run.sh -#BINARY_NAME_WINDOWS=run.bat ENTRY_POINT_UNIX=main.sh -#ENTRY_POINT_WINDOWS=main.bat #bash-build: mkdir -p $BIN_FOLDER diff --git a/vkpr/whoami/remove/src/unix/formula/formula.sh b/vkpr/whoami/remove/src/unix/formula/formula.sh index e355e18b..cacfa5d6 100755 --- a/vkpr/whoami/remove/src/unix/formula/formula.sh +++ b/vkpr/whoami/remove/src/unix/formula/formula.sh @@ -1,33 +1,14 @@ #!/bin/sh runFormula() { - VKPR_HOME=~/.vkpr - uninstallWhoami } uninstallWhoami(){ echoColor "yellow" "Removendo Whoami..." - $VKPR_HOME/bin/helm uninstall whoami - $VKPR_HOME/bin/kubectl delete secret whoami-cert -} - -echoColor() { - case $1 in - red) - echo "$(printf '\033[31m')$2$(printf '\033[0m')" - ;; - green) - echo "$(printf '\033[32m')$2$(printf '\033[0m')" - ;; - yellow) - echo "$(printf '\033[33m')$2$(printf '\033[0m')" - ;; - blue) - echo "$(printf '\033[34m')$2$(printf '\033[0m')" - ;; - cyan) - echo "$(printf '\033[36m')$2$(printf '\033[0m')" - ;; - esac -} + $VKPR_HELM uninstall vkpr-whoami + EXISTING_CERT=$($VKPR_KUBECTL get secret/vkpr-whoami-cert -o name --ignore-not-found | cut -d "/" -f2) + if [[ $EXISTING_CERT = "vkpr-whoami-cert" ]]; then + $VKPR_KUBECTL delete secret vkpr-whoami-cert + fi +} \ No newline at end of file From 8516a60046436f9c3cacfbdf826c4bfc0464a4c0 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:28:53 -0300 Subject: [PATCH 15/25] Template refactored code and formula documentation update --- vkpr/template/config/README.md | 12 +++++------- vkpr/template/config/build.sh | 4 ---- vkpr/template/config/config.json | 3 +-- vkpr/template/config/set_umask.sh | 3 --- vkpr/template/config/src/unix/formula/formula.sh | 6 +++++- 5 files changed, 11 insertions(+), 17 deletions(-) delete mode 100755 vkpr/template/config/set_umask.sh diff --git a/vkpr/template/config/README.md b/vkpr/template/config/README.md index 15d02cf2..5f8ad7cf 100755 --- a/vkpr/template/config/README.md +++ b/vkpr/template/config/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Show the values setted on the global-values. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr template config +vkpr template config ``` - -## Requirements - -## Demonstration diff --git a/vkpr/template/config/build.sh b/vkpr/template/config/build.sh index e0c86872..3f067481 100755 --- a/vkpr/template/config/build.sh +++ b/vkpr/template/config/build.sh @@ -9,7 +9,3 @@ ENTRY_POINT_UNIX=main.sh cp -r src/* $BIN_FOLDER mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX - -#bat-build: - -#docker: diff --git a/vkpr/template/config/config.json b/vkpr/template/config/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/template/config/config.json +++ b/vkpr/template/config/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/template/config/set_umask.sh b/vkpr/template/config/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/template/config/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/template/config/src/unix/formula/formula.sh b/vkpr/template/config/src/unix/formula/formula.sh index 3b3ed109..e88229d2 100755 --- a/vkpr/template/config/src/unix/formula/formula.sh +++ b/vkpr/template/config/src/unix/formula/formula.sh @@ -6,5 +6,9 @@ runFormula() { } outputGlobalTemplate(){ - $VKPR_YQ eval $VKPR_HOME/global-values.yaml + if [[ ! -s $VKPR_GLOBAL ]]; then + echoColor "red" "Doesnt have any values in global config file." + else + $VKPR_YQ eval $VKPR_GLOBAL + fi } From e6686498cc60c9ea356b79fc1cab9ef43eb53f03 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:29:14 -0300 Subject: [PATCH 16/25] Postgres refactored code and formula documentation update --- vkpr/postgres/install/README.md | 22 ++++++++++--- vkpr/postgres/install/build.sh | 6 +--- vkpr/postgres/install/config.json | 3 +- vkpr/postgres/install/metadata.json | 2 +- vkpr/postgres/install/set_umask.sh | 3 -- .../install/src/unix/formula/formula.sh | 27 ++-------------- vkpr/postgres/remove/README.md | 12 +++---- vkpr/postgres/remove/build.sh | 6 +--- vkpr/postgres/remove/config.json | 3 +- vkpr/postgres/remove/set_umask.sh | 3 -- .../remove/src/unix/formula/formula.sh | 32 +++---------------- 11 files changed, 33 insertions(+), 86 deletions(-) delete mode 100755 vkpr/postgres/install/set_umask.sh delete mode 100755 vkpr/postgres/remove/set_umask.sh diff --git a/vkpr/postgres/install/README.md b/vkpr/postgres/install/README.md index 4c6bfe34..af7a7775 100755 --- a/vkpr/postgres/install/README.md +++ b/vkpr/postgres/install/README.md @@ -1,13 +1,25 @@ # Description -Formula description +Install Postgres into cluster. Uses [postgresql](https://artifacthub.io/packages/helm/bitnami/postgresql) Helm chart. -## Command +## Commands + +Interactive input: + +```bash +vkpr postgres install +``` + +Non-interactive: ```bash -rit vkpr postgres install +rit set credential --provider="postgres" --fields="password" --values="" +vkpr postgres install ``` -## Requirements +### Content installed on the Cluster -## Demonstration +- Statefulset +- Service +- Secret +- PV and PVC diff --git a/vkpr/postgres/install/build.sh b/vkpr/postgres/install/build.sh index e0c86872..cfabf0a0 100755 --- a/vkpr/postgres/install/build.sh +++ b/vkpr/postgres/install/build.sh @@ -8,8 +8,4 @@ ENTRY_POINT_UNIX=main.sh mkdir -p $BIN_FOLDER cp -r src/* $BIN_FOLDER mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX - chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX - -#bat-build: - -#docker: + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX \ No newline at end of file diff --git a/vkpr/postgres/install/config.json b/vkpr/postgres/install/config.json index 8031960a..12a31fb5 100755 --- a/vkpr/postgres/install/config.json +++ b/vkpr/postgres/install/config.json @@ -1,5 +1,4 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [ { "name": "password", @@ -8,4 +7,4 @@ ], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/postgres/install/metadata.json b/vkpr/postgres/install/metadata.json index 2f65cdef..1201cdd2 100755 --- a/vkpr/postgres/install/metadata.json +++ b/vkpr/postgres/install/metadata.json @@ -14,4 +14,4 @@ "postgres", "install" ] -} +} \ No newline at end of file diff --git a/vkpr/postgres/install/set_umask.sh b/vkpr/postgres/install/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/postgres/install/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/postgres/install/src/unix/formula/formula.sh b/vkpr/postgres/install/src/unix/formula/formula.sh index bb7bf63a..1024d5e0 100755 --- a/vkpr/postgres/install/src/unix/formula/formula.sh +++ b/vkpr/postgres/install/src/unix/formula/formula.sh @@ -1,13 +1,10 @@ #!/bin/sh runFormula() { - VKPR_HOME=~/.vkpr - VKPR_HELM=$VKPR_HOME/bin/helm VKPR_POSTGRES_VALUES=$(dirname "$0")/utils/postgres.yaml addRepoPostgres installPostgres - } addRepoPostgres(){ @@ -17,25 +14,5 @@ addRepoPostgres(){ installPostgres(){ echoColor "yellow" "Installing postgres..." - $VKPR_HELM upgrade -i --set global.postgresql.postgresqlPassword=$PASSWORD postgres bitnami/postgresql -} - -echoColor() { - case $1 in - red) - echo "$(printf '\033[31m')$2$(printf '\033[0m')" - ;; - green) - echo "$(printf '\033[32m')$2$(printf '\033[0m')" - ;; - yellow) - echo "$(printf '\033[33m')$2$(printf '\033[0m')" - ;; - blue) - echo "$(printf '\033[34m')$2$(printf '\033[0m')" - ;; - cyan) - echo "$(printf '\033[36m')$2$(printf '\033[0m')" - ;; - esac -} + $VKPR_HELM upgrade -i --set global.postgresql.postgresqlPassword=$PASSWORD vkpr-postgres bitnami/postgresql +} \ No newline at end of file diff --git a/vkpr/postgres/remove/README.md b/vkpr/postgres/remove/README.md index f3c18fa3..a56c15ca 100755 --- a/vkpr/postgres/remove/README.md +++ b/vkpr/postgres/remove/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Uninstall all the contet of Postgres from the cluster. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr postgres remove +vkpr postgres remove ``` - -## Requirements - -## Demonstration diff --git a/vkpr/postgres/remove/build.sh b/vkpr/postgres/remove/build.sh index e0c86872..cfabf0a0 100755 --- a/vkpr/postgres/remove/build.sh +++ b/vkpr/postgres/remove/build.sh @@ -8,8 +8,4 @@ ENTRY_POINT_UNIX=main.sh mkdir -p $BIN_FOLDER cp -r src/* $BIN_FOLDER mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX - chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX - -#bat-build: - -#docker: + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX \ No newline at end of file diff --git a/vkpr/postgres/remove/config.json b/vkpr/postgres/remove/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/postgres/remove/config.json +++ b/vkpr/postgres/remove/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/postgres/remove/set_umask.sh b/vkpr/postgres/remove/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/postgres/remove/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/postgres/remove/src/unix/formula/formula.sh b/vkpr/postgres/remove/src/unix/formula/formula.sh index 322eecac..a7429f83 100755 --- a/vkpr/postgres/remove/src/unix/formula/formula.sh +++ b/vkpr/postgres/remove/src/unix/formula/formula.sh @@ -1,40 +1,16 @@ #!/bin/sh runFormula() { - VKPR_HOME=~/.vkpr - VKPR_HELM=$VKPR_HOME/bin/helm - removePostgres removePVC - } removePostgres(){ echoColor "green" "Removing Postgres..." - $VKPR_HELM uninstall postgres + $VKPR_HELM uninstall vkpr-postgres } removePVC(){ - echoColor "green" "Removing PVC..." - kubectl delete pvc -l app.kubernetes.io/instance=postgres -} - -echoColor() { - case $1 in - red) - echo "$(printf '\033[31m')$2$(printf '\033[0m')" - ;; - green) - echo "$(printf '\033[32m')$2$(printf '\033[0m')" - ;; - yellow) - echo "$(printf '\033[33m')$2$(printf '\033[0m')" - ;; - blue) - echo "$(printf '\033[34m')$2$(printf '\033[0m')" - ;; - cyan) - echo "$(printf '\033[36m')$2$(printf '\033[0m')" - ;; - esac -} + echoColor "green" "Removing PVC..." + $VKPR_KUBECTL delete pvc -l app.kubernetes.io/instance=vkpr-postgres +} \ No newline at end of file From 4143ef9e7080b38b0e7b625ca2171b810051c2eb Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:29:36 -0300 Subject: [PATCH 17/25] Keycloak refactored code and formula documentation update --- vkpr/keycloak/install/README.md | 65 +++++++++++++++++-- .../install/src/unix/formula/formula.sh | 12 ++-- vkpr/keycloak/remove/README.md | 12 ++-- .../remove/src/unix/formula/formula.sh | 2 +- 4 files changed, 72 insertions(+), 19 deletions(-) diff --git a/vkpr/keycloak/install/README.md b/vkpr/keycloak/install/README.md index cdbb929b..3c1ac3d1 100755 --- a/vkpr/keycloak/install/README.md +++ b/vkpr/keycloak/install/README.md @@ -1,6 +1,61 @@ -# Globals file +# Description -.global.keycloak.domain -.global.keycloak.secure -.global.keycloak.admin_user -.global.keycloak.admin_password +Install keycloak into cluster. Uses [keycloak](https://artifacthub.io/packages/helm/bitnami/keycloak) Helm chart. + +## Commands + +Interactive inputs: + +```bash +vkpr keycloak install +``` + +Non-interactive: + +```bash +vkpr keycloak install --domain="keycloak.localhost" \ + --secure=false \ + --admin_user="admin" \ + --admin_password="vkpr123" +``` + +Non-interactive without setting values: + +```bash +vkpr keycloak install --default +``` + +## Parameters + +```bash + --domain= Define the domain of whoami. Default: keycloak.localhost + --secure= Define https on the keycloak. Default: false + --admin_user= Define RBAC Admin user on the keycloak. Default: admin + --admin_password= Define RBAC Admin password keycloak. Default: vkpr123 + --default= Set all values with default. +``` + +**Note:** Require credential of Password Postgres to create the postgres + +## Globals File Parameters + +```yaml +global: + keycloak: + domain: + secure: + admin_user: + admin_password: +``` + +### Content installed on the Cluster + +- Statefulset +- Service +- Ingress +- Secret (certificate) +- ConfigMap +- Job +- Role +- RoleBinding +- ServiceAccount diff --git a/vkpr/keycloak/install/src/unix/formula/formula.sh b/vkpr/keycloak/install/src/unix/formula/formula.sh index 3689b450..061159bd 100755 --- a/vkpr/keycloak/install/src/unix/formula/formula.sh +++ b/vkpr/keycloak/install/src/unix/formula/formula.sh @@ -21,10 +21,10 @@ addRepoKeycloak(){ } verifyExistingPostgres(){ - EXISTING_POSTGRES=$($VKPR_KUBECTL get po/postgres-postgresql-0 -o name --ignore-not-found | cut -d "/" -f2) - if [[ $EXISTING_POSTGRES = "postgres-postgresql-0" ]]; then - POSTGRES=$($VKPR_KUBECTL wait --for=condition=Ready po/postgres-postgresql-0 -o name | cut -d "/" -f2) - if [[ $POSTGRES = "postgres-postgresql-0" ]]; then + EXISTING_POSTGRES=$($VKPR_KUBECTL get po/vkpr-postgres-postgresql-0 -o name --ignore-not-found | cut -d "/" -f2) + if [[ $EXISTING_POSTGRES = "vkpr-postgres-postgresql-0" ]]; then + POSTGRES=$($VKPR_KUBECTL wait --for=condition=Ready po/vkpr-postgres-postgresql-0 -o name | cut -d "/" -f2) + if [[ $POSTGRES = "vkpr-postgres-postgresql-0" ]]; then echo "true" return fi @@ -36,7 +36,7 @@ settingKeycloak(){ $VKPR_YQ eval '.ingress.hosts[0].host = "'$VKPR_ENV_KEYCLOAK_DOMAIN'" | .ingress.tls[0].hosts[0] = "'$VKPR_ENV_KEYCLOAK_DOMAIN'" | .auth.adminUser = "'$VKPR_ENV_KEYCLOAK_ADMIN_USER'" | .auth.adminPassword = "'$VKPR_ENV_KEYCLOAK_ADMIN_PASSWORD'"' "$VKPR_KEYCLOAK_YAML" \ - | $VKPR_HELM upgrade -i -f - keycloak bitnami/keycloak + | $VKPR_HELM upgrade -i -f - vkpr-keycloak bitnami/keycloak } settingKeycloakDB(){ @@ -45,7 +45,7 @@ settingKeycloakDB(){ .externalDatabase.user = "'$PG_USER'" | .externalDatabase.password = "'$PG_PASSWORD'" | .externalDatabase.database = "'$PG_DATABASE_NAME'" | .auth.adminUser = "'$VKPR_ENV_KEYCLOAK_ADMIN_USER'" | .auth.adminPassword = "'$VKPR_ENV_KEYCLOAK_ADMIN_PASSWORD'"' "$VKPR_KEYCLOAK_YAML" \ - | $VKPR_HELM upgrade -i -f - keycloak bitnami/keycloak + | $VKPR_HELM upgrade -i -f - vkpr-keycloak bitnami/keycloak } installKeycloak(){ diff --git a/vkpr/keycloak/remove/README.md b/vkpr/keycloak/remove/README.md index d698d195..78dd5e68 100644 --- a/vkpr/keycloak/remove/README.md +++ b/vkpr/keycloak/remove/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Uninstall all the contet of Keycloak from the cluster. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr keycloak remove +vkpr keycloak remove ``` - -## Requirements - -## Demonstration diff --git a/vkpr/keycloak/remove/src/unix/formula/formula.sh b/vkpr/keycloak/remove/src/unix/formula/formula.sh index ebaf6883..3f554bff 100755 --- a/vkpr/keycloak/remove/src/unix/formula/formula.sh +++ b/vkpr/keycloak/remove/src/unix/formula/formula.sh @@ -2,5 +2,5 @@ runFormula() { echoColor "green" "Removing keycloak..." - $VKPR_HELM uninstall keycloak + $VKPR_HELM uninstall vkpr-keycloak } \ No newline at end of file From 35b6e640e0cc59a874198ef17cda725e97bb3381 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:29:47 -0300 Subject: [PATCH 18/25] Init refactored code and formula documentation update --- vkpr/init/README.md | 15 +++++---------- vkpr/init/build.sh | 10 +--------- vkpr/init/config.json | 3 +-- vkpr/init/metadata.json | 5 +++-- vkpr/init/src/utils/global-values.yaml | 2 -- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/vkpr/init/README.md b/vkpr/init/README.md index ba9b96ea..65402bef 100755 --- a/vkpr/init/README.md +++ b/vkpr/init/README.md @@ -1,16 +1,11 @@ # Description -Formula description +Initializate all necessary tools to run the VKPR. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr init +vkpr init ``` - -## Requirements - -None. - -## Demonstration - diff --git a/vkpr/init/build.sh b/vkpr/init/build.sh index 4f5571d0..cfabf0a0 100755 --- a/vkpr/init/build.sh +++ b/vkpr/init/build.sh @@ -2,18 +2,10 @@ BIN_FOLDER=bin BINARY_NAME_UNIX=run.sh -#BINARY_NAME_WINDOWS=run.bat ENTRY_POINT_UNIX=main.sh -#ENTRY_POINT_WINDOWS=main.bat #bash-build: mkdir -p $BIN_FOLDER cp -r src/* $BIN_FOLDER mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX - chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX - -#bat-build: -# mv $BIN_FOLDER/$ENTRY_POINT_WINDOWS $BIN_FOLDER/$BINARY_NAME_WINDOWS - -#docker: -# cp Dockerfile set_umask.sh $BIN_FOLDER + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX \ No newline at end of file diff --git a/vkpr/init/config.json b/vkpr/init/config.json index 67926700..1de9a971 100755 --- a/vkpr/init/config.json +++ b/vkpr/init/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.1" -} +} \ No newline at end of file diff --git a/vkpr/init/metadata.json b/vkpr/init/metadata.json index ee99c903..9ca544c1 100755 --- a/vkpr/init/metadata.json +++ b/vkpr/init/metadata.json @@ -10,6 +10,7 @@ ] }, "tags": [ - "vkpr", "init" + "vkpr", + "init" ] -} +} \ No newline at end of file diff --git a/vkpr/init/src/utils/global-values.yaml b/vkpr/init/src/utils/global-values.yaml index eb24a5dc..e69de29b 100644 --- a/vkpr/init/src/utils/global-values.yaml +++ b/vkpr/init/src/utils/global-values.yaml @@ -1,2 +0,0 @@ -global: - domain: vkpr-dev.vertigo.com.br \ No newline at end of file From b6958315b4a95fe277784d3b63d35a49b2c75923 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:30:06 -0300 Subject: [PATCH 19/25] Ingress refactored code and formula documentation update --- vkpr/ingress/install/README.md | 20 ++++++++++++------- vkpr/ingress/install/config.json | 3 +-- vkpr/ingress/install/metadata.json | 6 ++++-- vkpr/ingress/install/set_umask.sh | 3 --- .../install/src/unix/formula/formula.sh | 2 +- vkpr/ingress/remove/README.md | 12 +++++------ vkpr/ingress/remove/config.json | 3 +-- vkpr/ingress/remove/metadata.json | 6 ++++-- vkpr/ingress/remove/set_umask.sh | 3 --- 9 files changed, 29 insertions(+), 29 deletions(-) delete mode 100755 vkpr/ingress/install/set_umask.sh delete mode 100755 vkpr/ingress/remove/set_umask.sh diff --git a/vkpr/ingress/install/README.md b/vkpr/ingress/install/README.md index a6c01191..aacca424 100755 --- a/vkpr/ingress/install/README.md +++ b/vkpr/ingress/install/README.md @@ -1,10 +1,6 @@ # Description -Install ingress controller into cluster. Uses [ingress-nginx](https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx) Helm chart. - -Requires these global definitions: - -- domain +Install nginx-ingress controller into cluster. Uses [ingress-nginx](https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx) Helm chart. ## Command @@ -12,6 +8,16 @@ Requires these global definitions: rit vkpr ingress install ``` -## Requirements +### Content installed on the Cluster -## Demonstration +- Deployment +- Service +- Daemonset +- Secret (certificate) +- ConfigMap +- Job +- ClusterRole +- Role +- RoleBinding +- ServiceAccount +- ValidatingWebhookConfiguration diff --git a/vkpr/ingress/install/config.json b/vkpr/ingress/install/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/ingress/install/config.json +++ b/vkpr/ingress/install/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/ingress/install/metadata.json b/vkpr/ingress/install/metadata.json index bced356b..db5546f2 100755 --- a/vkpr/ingress/install/metadata.json +++ b/vkpr/ingress/install/metadata.json @@ -10,6 +10,8 @@ ] }, "tags": [ - "vkpr", "ingress", "install" + "vkpr", + "ingress", + "install" ] -} +} \ No newline at end of file diff --git a/vkpr/ingress/install/set_umask.sh b/vkpr/ingress/install/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/ingress/install/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/ingress/install/src/unix/formula/formula.sh b/vkpr/ingress/install/src/unix/formula/formula.sh index 014c02e3..f6385d3f 100755 --- a/vkpr/ingress/install/src/unix/formula/formula.sh +++ b/vkpr/ingress/install/src/unix/formula/formula.sh @@ -2,5 +2,5 @@ runFormula() { echo "VKPR Ingress install" - $VKPR_HOME/bin/arkade install ingress-nginx + $VKPR_ARKADE install ingress-nginx } diff --git a/vkpr/ingress/remove/README.md b/vkpr/ingress/remove/README.md index 058d7780..252878e5 100755 --- a/vkpr/ingress/remove/README.md +++ b/vkpr/ingress/remove/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Uninstall all the contet of nginx-ingress controller from the cluster. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr ingress remove +vkpr ingress remove ``` - -## Requirements - -## Demonstration diff --git a/vkpr/ingress/remove/config.json b/vkpr/ingress/remove/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/ingress/remove/config.json +++ b/vkpr/ingress/remove/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/ingress/remove/metadata.json b/vkpr/ingress/remove/metadata.json index 5c101857..9e4d1a42 100755 --- a/vkpr/ingress/remove/metadata.json +++ b/vkpr/ingress/remove/metadata.json @@ -11,6 +11,8 @@ ] }, "tags": [ - "vkpr", "ingress", "remove" + "vkpr", + "ingress", + "remove" ] -} +} \ No newline at end of file diff --git a/vkpr/ingress/remove/set_umask.sh b/vkpr/ingress/remove/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/ingress/remove/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 From 0b03acd2140b37eb7c01cc652e1b64b9279d2194 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:30:20 -0300 Subject: [PATCH 20/25] Infra refactored code and formula documentation update --- vkpr/infra/down/README.md | 12 +++++------ vkpr/infra/down/config.json | 3 +-- vkpr/infra/down/metadata.json | 6 ++++-- vkpr/infra/down/set_umask.sh | 3 --- vkpr/infra/down/src/unix/formula/formula.sh | 2 +- vkpr/infra/up/README.md | 13 +++++++----- vkpr/infra/up/build.sh | 10 +--------- vkpr/infra/up/config.json | 3 +-- vkpr/infra/up/metadata.json | 6 ++++-- vkpr/infra/up/set_umask.sh | 3 --- vkpr/infra/up/src/unix/formula/formula.sh | 22 +++++++++++---------- 11 files changed, 37 insertions(+), 46 deletions(-) delete mode 100755 vkpr/infra/down/set_umask.sh delete mode 100755 vkpr/infra/up/set_umask.sh diff --git a/vkpr/infra/down/README.md b/vkpr/infra/down/README.md index 83079fba..52d0c0df 100755 --- a/vkpr/infra/down/README.md +++ b/vkpr/infra/down/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Drop all the cluster. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr infra down +vkpr infra down ``` - -## Requirements - -## Demonstration diff --git a/vkpr/infra/down/config.json b/vkpr/infra/down/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/infra/down/config.json +++ b/vkpr/infra/down/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/infra/down/metadata.json b/vkpr/infra/down/metadata.json index a70d96dc..7477114d 100755 --- a/vkpr/infra/down/metadata.json +++ b/vkpr/infra/down/metadata.json @@ -10,6 +10,8 @@ ] }, "tags": [ - "vkpr", "infra", "down" + "vkpr", + "infra", + "down" ] -} +} \ No newline at end of file diff --git a/vkpr/infra/down/set_umask.sh b/vkpr/infra/down/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/infra/down/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/infra/down/src/unix/formula/formula.sh b/vkpr/infra/down/src/unix/formula/formula.sh index 11af07ec..64c1c986 100755 --- a/vkpr/infra/down/src/unix/formula/formula.sh +++ b/vkpr/infra/down/src/unix/formula/formula.sh @@ -8,7 +8,7 @@ runFormula() { stopCluster() { # local registry - if $(k3d cluster list | grep -q "vkpr-local"); then + if $($VKPR_K3D cluster list | grep -q "vkpr-local"); then $VKPR_K3D cluster delete vkpr-local else echoColor "red" "Cluster vkpr-local not running, skipping." diff --git a/vkpr/infra/up/README.md b/vkpr/infra/up/README.md index ff298468..21bca46b 100755 --- a/vkpr/infra/up/README.md +++ b/vkpr/infra/up/README.md @@ -1,13 +1,16 @@ # Description -Formula description +Create a k3d cluster to test the applications. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr infra up +vkpr infra up ``` -## Requirements +### Ports -## Demonstration +- 8000: http +- 8001: https diff --git a/vkpr/infra/up/build.sh b/vkpr/infra/up/build.sh index 4f5571d0..cfabf0a0 100755 --- a/vkpr/infra/up/build.sh +++ b/vkpr/infra/up/build.sh @@ -2,18 +2,10 @@ BIN_FOLDER=bin BINARY_NAME_UNIX=run.sh -#BINARY_NAME_WINDOWS=run.bat ENTRY_POINT_UNIX=main.sh -#ENTRY_POINT_WINDOWS=main.bat #bash-build: mkdir -p $BIN_FOLDER cp -r src/* $BIN_FOLDER mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX - chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX - -#bat-build: -# mv $BIN_FOLDER/$ENTRY_POINT_WINDOWS $BIN_FOLDER/$BINARY_NAME_WINDOWS - -#docker: -# cp Dockerfile set_umask.sh $BIN_FOLDER + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX \ No newline at end of file diff --git a/vkpr/infra/up/config.json b/vkpr/infra/up/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/infra/up/config.json +++ b/vkpr/infra/up/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/infra/up/metadata.json b/vkpr/infra/up/metadata.json index 5b106e3a..14fccb10 100755 --- a/vkpr/infra/up/metadata.json +++ b/vkpr/infra/up/metadata.json @@ -10,6 +10,8 @@ ] }, "tags": [ - "vkpr", "infra", "up" + "vkpr", + "infra", + "up" ] -} +} \ No newline at end of file diff --git a/vkpr/infra/up/set_umask.sh b/vkpr/infra/up/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/infra/up/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/infra/up/src/unix/formula/formula.sh b/vkpr/infra/up/src/unix/formula/formula.sh index 5b2ac28f..2849d11c 100755 --- a/vkpr/infra/up/src/unix/formula/formula.sh +++ b/vkpr/infra/up/src/unix/formula/formula.sh @@ -11,6 +11,8 @@ runFormula() { echoColor "yellow" "Volumes used:" echo "Two local unamed docker volumes" + VKPR_CONFIG_REGISTRY=$VKPR_HOME/config/registry.yaml + # TODO: test dependencies # VKPR home is "~/.vkpr" @@ -24,7 +26,7 @@ runFormula() { configRegistry() { #HOST_IP="172.17.0.1" # linux native HOST_IP="host.k3d.internal" - cat > $VKPR_HOME/config/registry.yaml << EOF + cat > $VKPR_CONFIG_REGISTRY << EOF mirrors: "docker.io": endpoint: @@ -34,31 +36,31 @@ EOF startCluster() { # local registry - if ! $(k3d cluster list | grep -q "vkpr-local"); then - k3d cluster create vkpr-local \ + if ! $($VKPR_K3D cluster list | grep -q "vkpr-local"); then + $VKPR_K3D cluster create vkpr-local \ -p "8000:80@loadbalancer" \ -p "8001:443@loadbalancer" \ --k3s-server-arg '--no-deploy=traefik' \ --registry-use k3d-registry.localhost \ - --registry-config $VKPR_HOME/config/registry.yaml + --registry-config $VKPR_CONFIG_REGISTRY else echoColor "yellow" "Cluster vkpr-local already started, skipping." fi # use cluster - $VKPR_HOME/bin/kubectl config use-context k3d-vkpr-local - $VKPR_HOME/bin/kubectl cluster-info + $VKPR_KUBECTL config use-context k3d-vkpr-local + $VKPR_KUBECTL cluster-info } startRegistry() { # local registry - if ! $(k3d registry list | grep -q "k3d-registry\.localhost"); then - k3d registry create registry.localhost -p 5000 + if ! $($VKPR_K3D registry list | grep -q "k3d-registry\.localhost"); then + $VKPR_K3D registry create registry.localhost -p 5000 else echoColor "yellow" "Registry already started, skipping." fi # docker hub mirror - if ! $(k3d registry list | grep -q "k3d-mirror\.localhost"); then - k3d registry create mirror.localhost -i vertigo/registry-mirror -p 5001 + if ! $($VKPR_K3D registry list | grep -q "k3d-mirror\.localhost"); then + $VKPR_K3D registry create mirror.localhost -i vertigo/registry-mirror -p 5001 else echoColor "yellow" "Mirror already started, skipping." fi From b6840de61e1bddb24ea351ada791837ba0bcaaee Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:30:35 -0300 Subject: [PATCH 21/25] External-dns refactored code and formula documentation update --- vkpr/external-dns/install/README.md | 46 +++++++++++++++++-- vkpr/external-dns/install/set_umask.sh | 3 -- .../install/src/unix/formula/formula.sh | 2 +- vkpr/external-dns/remove/README.md | 12 ++--- vkpr/external-dns/remove/config.json | 3 +- vkpr/external-dns/remove/metadata.json | 6 ++- vkpr/external-dns/remove/set_umask.sh | 3 -- .../remove/src/unix/formula/formula.sh | 3 +- 8 files changed, 53 insertions(+), 25 deletions(-) delete mode 100644 vkpr/external-dns/install/set_umask.sh delete mode 100755 vkpr/external-dns/remove/set_umask.sh diff --git a/vkpr/external-dns/install/README.md b/vkpr/external-dns/install/README.md index 68b1eb53..727319ca 100644 --- a/vkpr/external-dns/install/README.md +++ b/vkpr/external-dns/install/README.md @@ -1,13 +1,49 @@ # Description -Formula description +Install external-dns into cluster. Uses [external-dns](https://artifacthub.io/packages/helm/bitnami/external-dns) Helm chart. -## Command +## Commands + +Interactive inputs: + +```bash +vkpr external-dns install +``` + +Non-interactive: + +```bash +rit set credential --provider="digitalocean" --fields="token" --values="" +vkpr external-dns install --provider="digitalocean" +``` + +Non-interactive without setting values: + +```bash +vkpr external-dns install --default +``` + +## Parameters ```bash -rit vkpr external-dns install + --provider= Define the provider from external-dns. Default: digitalocean + --default= Set all values with default. +``` + +## Globals File Parameters + +```yaml +global: + external-dns: + provider: ``` -## Requirements +### Content installed on the Cluster -## Demonstration +- Deployment +- Service +- Secret (certificate) +- Job +- ServiceAccount +- ClusterRole +- ClusterRoleBinding diff --git a/vkpr/external-dns/install/set_umask.sh b/vkpr/external-dns/install/set_umask.sh deleted file mode 100644 index 091c13d6..00000000 --- a/vkpr/external-dns/install/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/external-dns/install/src/unix/formula/formula.sh b/vkpr/external-dns/install/src/unix/formula/formula.sh index 2bd17d0f..a5b1400d 100755 --- a/vkpr/external-dns/install/src/unix/formula/formula.sh +++ b/vkpr/external-dns/install/src/unix/formula/formula.sh @@ -18,7 +18,7 @@ add_repo_external_dns() { } install_external_dns() { - $VKPR_HOME/bin/helm upgrade -i vkpr -f $VKPR_EXTERNAL_DNS_VALUES bitnami/external-dns + $VKPR_HOME/bin/helm upgrade -i vkpr-external-dns -f $VKPR_EXTERNAL_DNS_VALUES bitnami/external-dns } get_credentials() { diff --git a/vkpr/external-dns/remove/README.md b/vkpr/external-dns/remove/README.md index 68b1eb53..7b082fa0 100755 --- a/vkpr/external-dns/remove/README.md +++ b/vkpr/external-dns/remove/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Uninstall all the contet of external-dns from the cluster. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr external-dns install +vkpr external-dns remove ``` - -## Requirements - -## Demonstration diff --git a/vkpr/external-dns/remove/config.json b/vkpr/external-dns/remove/config.json index c3d6c6c2..257f1ebe 100755 --- a/vkpr/external-dns/remove/config.json +++ b/vkpr/external-dns/remove/config.json @@ -1,6 +1,5 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/external-dns/remove/metadata.json b/vkpr/external-dns/remove/metadata.json index 89a145bb..1ff70eaa 100755 --- a/vkpr/external-dns/remove/metadata.json +++ b/vkpr/external-dns/remove/metadata.json @@ -11,6 +11,8 @@ ] }, "tags": [ - "vkpr", "external-dns", "install" + "vkpr", + "external-dns", + "install" ] -} +} \ No newline at end of file diff --git a/vkpr/external-dns/remove/set_umask.sh b/vkpr/external-dns/remove/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/external-dns/remove/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/external-dns/remove/src/unix/formula/formula.sh b/vkpr/external-dns/remove/src/unix/formula/formula.sh index c6c2a288..3b88bd21 100755 --- a/vkpr/external-dns/remove/src/unix/formula/formula.sh +++ b/vkpr/external-dns/remove/src/unix/formula/formula.sh @@ -2,6 +2,5 @@ runFormula() { echoColor "yellow" "Removendo external-dns..." - rm -rf $VKPR_HOME/values/external-dns - helm delete vkpr + $VKPR_HELM uninstall vkpr-external-dns } From 429b0a578166bfacb65a3b865d4d574ec8128e89 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:30:55 -0300 Subject: [PATCH 22/25] Create Formula refactored code and formula documentation update --- vkpr/create/formula/README.md | 7 +------ vkpr/create/formula/config.json | 3 +-- vkpr/create/formula/metadata.json | 6 ++++-- vkpr/create/formula/set_umask.sh | 3 --- vkpr/create/formula/src/unix/formula/formula.sh | 3 +++ 5 files changed, 9 insertions(+), 13 deletions(-) delete mode 100755 vkpr/create/formula/set_umask.sh diff --git a/vkpr/create/formula/README.md b/vkpr/create/formula/README.md index 248d36a4..549280e1 100755 --- a/vkpr/create/formula/README.md +++ b/vkpr/create/formula/README.md @@ -7,6 +7,7 @@ Files/folders removed: - build.bat - Dockerfile - Makefile +- set_umask.sh - src/windows/ - src/main.bat @@ -29,9 +30,3 @@ Non-interactive: ```bash vkpr create formula --vkpr_formula="vkpr object verb" ``` - - -## Requirements - -## Demonstration - diff --git a/vkpr/create/formula/config.json b/vkpr/create/formula/config.json index 6930fdda..ae8faaf1 100755 --- a/vkpr/create/formula/config.json +++ b/vkpr/create/formula/config.json @@ -1,5 +1,4 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [ { "label": "Enter the new formula command (must begin with 'vkpr'): ", @@ -33,4 +32,4 @@ ], "template": "shell-bat", "templateRelease:": "2.16.2" -} +} \ No newline at end of file diff --git a/vkpr/create/formula/metadata.json b/vkpr/create/formula/metadata.json index 183c4922..44011cf7 100755 --- a/vkpr/create/formula/metadata.json +++ b/vkpr/create/formula/metadata.json @@ -10,6 +10,8 @@ ] }, "tags": [ - "vkpr", "create", "formula" + "vkpr", + "create", + "formula" ] -} +} \ No newline at end of file diff --git a/vkpr/create/formula/set_umask.sh b/vkpr/create/formula/set_umask.sh deleted file mode 100755 index 091c13d6..00000000 --- a/vkpr/create/formula/set_umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -umask 0011 -$1 diff --git a/vkpr/create/formula/src/unix/formula/formula.sh b/vkpr/create/formula/src/unix/formula/formula.sh index 444495a3..3b5cbb56 100755 --- a/vkpr/create/formula/src/unix/formula/formula.sh +++ b/vkpr/create/formula/src/unix/formula/formula.sh @@ -36,10 +36,13 @@ cleanupFormula() { echoColor "red" "cleanupFormula: This is not a formula path (no 'config.json' file), bailing out." exit 1 fi + # create file + touch "$formulaPath/help.json" # delete files rm -f "$formulaPath/build.bat" rm -f "$formulaPath/Dockerfile" rm -f "$formulaPath/Makefile" + rm -f "$formulaPath/set_umask.sh" rm -Rf "$formulaPath/src/windows" # change files sed -i.bak '/BINARY_NAME_WINDOWS/d' "$formulaPath/build.sh" # sao duas From e68a79a6251e6647a109d16ec3fc133223aa423b Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:31:10 -0300 Subject: [PATCH 23/25] Cert-manager refactored code and formula documentation update --- vkpr/cert-manager/install/README.md | 39 ++++++++++++++++--- .../install/src/unix/formula/formula.sh | 2 +- vkpr/cert-manager/remove/README.md | 12 +++--- .../remove/src/unix/formula/formula.sh | 2 +- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/vkpr/cert-manager/install/README.md b/vkpr/cert-manager/install/README.md index 84322983..67e70c25 100755 --- a/vkpr/cert-manager/install/README.md +++ b/vkpr/cert-manager/install/README.md @@ -1,13 +1,42 @@ # Description -Formula description +Install cert-manager into cluster. Uses [cert-manager](https://artifacthub.io/packages/helm/cert-manager/cert-manager) Helm chart. -## Command +## Commands + +Interactive inputs: + +```bash +vkpr cert-manager install +``` + +Non-interactive: + +```bash +rit set credential --provider="digitalocean" --fields="token" --values="" +vkpr cert-manager install --email="your-email@your-provider.com" +``` + +## Parameters ```bash -rit vkpr cert-manager install + --email= Define the email to use on Lets Encrypt. Default: none +``` + +## Globals File Parameters + +```yaml +global: + cert-manager: + email: ``` -## Requirements +### Content installed on the Cluster -## Demonstration +- Deployment +- Service +- Secret (certificate) +- ServiceAccount +- MutatingWebhookConfiguration +- ValidatingWebhookConfiguration +- CRDS diff --git a/vkpr/cert-manager/install/src/unix/formula/formula.sh b/vkpr/cert-manager/install/src/unix/formula/formula.sh index 2f75c6f8..7c2a1499 100755 --- a/vkpr/cert-manager/install/src/unix/formula/formula.sh +++ b/vkpr/cert-manager/install/src/unix/formula/formula.sh @@ -35,7 +35,7 @@ install_certmanager() { $VKPR_HELM upgrade -i -f $VKPR_CERT_VALUES \ -n cert-manager --create-namespace \ --version "$VKPR_CERT_VERSION" \ - cert-manager jetstack/cert-manager + vkpr-cert-manager jetstack/cert-manager } get_cert_values() { diff --git a/vkpr/cert-manager/remove/README.md b/vkpr/cert-manager/remove/README.md index 9033c37a..cc1d4375 100755 --- a/vkpr/cert-manager/remove/README.md +++ b/vkpr/cert-manager/remove/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Uninstall all the content of cert-manager from the cluster. (Doesnt uninstall the crds) -## Command +## Commands + +Non-interactive: ```bash -rit vkpr cert-manager remove +vkpr cert-manager remove ``` - -## Requirements - -## Demonstration diff --git a/vkpr/cert-manager/remove/src/unix/formula/formula.sh b/vkpr/cert-manager/remove/src/unix/formula/formula.sh index 1a1e6bb1..89b5960a 100755 --- a/vkpr/cert-manager/remove/src/unix/formula/formula.sh +++ b/vkpr/cert-manager/remove/src/unix/formula/formula.sh @@ -4,6 +4,6 @@ runFormula() { echoColor "yellow" "Removing cert-manager..." rm -rf $VKPR_HOME/configs/cert-manager/ $VKPR_HOME/values/cert-manager/ $VKPR_KUBECTL delete clusterissuer letsencrypt-staging - $VKPR_HELM uninstall cert-manager -n cert-manager + $VKPR_HELM uninstall vkpr-cert-manager -n cert-manager $VKPR_KUBECTL delete ns cert-manager } From ba42af04f7f2bf35c233182215eb5f45b1358e5b Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:35:41 -0300 Subject: [PATCH 24/25] AWS EKS formula documentation and helpers update --- vkpr/aws/eks/deploy/README.md | 17 ++++++++++----- vkpr/aws/eks/deploy/config.json | 1 - vkpr/aws/eks/deploy/help.json | 4 ++++ vkpr/aws/eks/deploy/src/main.sh | 13 ++++-------- vkpr/aws/eks/destroy/README.md | 12 +++++------ vkpr/aws/eks/destroy/config.json | 1 - vkpr/aws/eks/destroy/help.json | 4 ++++ vkpr/aws/eks/destroy/src/main.sh | 6 ++++++ vkpr/aws/eks/help.json | 4 ++++ vkpr/aws/eks/up/README.md | 36 +++++++++++++++++++++++++++----- vkpr/aws/eks/up/config.json | 1 - vkpr/aws/eks/up/help.json | 4 ++++ vkpr/aws/eks/up/metadata.json | 2 +- vkpr/aws/eks/up/src/main.sh | 13 ++++-------- 14 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 vkpr/aws/eks/deploy/help.json create mode 100644 vkpr/aws/eks/destroy/help.json create mode 100644 vkpr/aws/eks/help.json create mode 100644 vkpr/aws/eks/up/help.json diff --git a/vkpr/aws/eks/deploy/README.md b/vkpr/aws/eks/deploy/README.md index 79368789..dfe3a995 100755 --- a/vkpr/aws/eks/deploy/README.md +++ b/vkpr/aws/eks/deploy/README.md @@ -1,13 +1,20 @@ # Description -Formula description +Create a Cluster EKS in AWS with [Gitops Terraform Module](https://gitlab.com/vkpr/terraform-aws-eks). -## Command +## Commands + +Interactive inputs: ```bash -rit vkpr aws eks deploy +vkpr aws eks deploy ``` -## Requirements +Non-interactive: + +```bash +rit set credential --fields="token,username" --provider="gitlab" --values="," +vkpr aws eks deploy +``` -## Demonstration +**Note**: If you set the credentials of gitlab in formula `vkpr aws eks up`, you dont need to set again. diff --git a/vkpr/aws/eks/deploy/config.json b/vkpr/aws/eks/deploy/config.json index cfde09aa..a9881c6c 100755 --- a/vkpr/aws/eks/deploy/config.json +++ b/vkpr/aws/eks/deploy/config.json @@ -1,5 +1,4 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [ { "name": "gitlab_token", diff --git a/vkpr/aws/eks/deploy/help.json b/vkpr/aws/eks/deploy/help.json new file mode 100644 index 00000000..32769eaf --- /dev/null +++ b/vkpr/aws/eks/deploy/help.json @@ -0,0 +1,4 @@ +{ + "short": "Deploy AWS EKS with Gitops", + "long": "Deploy the AWS EKS by your Gitlab CI Pipeline. The KUBECONFIG will be in the Artifacts on the pipeline." +} \ No newline at end of file diff --git a/vkpr/aws/eks/deploy/src/main.sh b/vkpr/aws/eks/deploy/src/main.sh index 24e26cf6..cf647088 100755 --- a/vkpr/aws/eks/deploy/src/main.sh +++ b/vkpr/aws/eks/deploy/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/.env -source ~/.vkpr/global/helper.sh +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/aws/eks/destroy/README.md b/vkpr/aws/eks/destroy/README.md index e7074f83..41a28b7b 100755 --- a/vkpr/aws/eks/destroy/README.md +++ b/vkpr/aws/eks/destroy/README.md @@ -1,13 +1,11 @@ # Description -Formula description +Destroy the EKS in AWS. -## Command +## Commands + +Non-interactive: ```bash -rit vkpr aws eks destroy +vkpr aws eks destroy ``` - -## Requirements - -## Demonstration diff --git a/vkpr/aws/eks/destroy/config.json b/vkpr/aws/eks/destroy/config.json index cfde09aa..a9881c6c 100755 --- a/vkpr/aws/eks/destroy/config.json +++ b/vkpr/aws/eks/destroy/config.json @@ -1,5 +1,4 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [ { "name": "gitlab_token", diff --git a/vkpr/aws/eks/destroy/help.json b/vkpr/aws/eks/destroy/help.json new file mode 100644 index 00000000..f2eec87e --- /dev/null +++ b/vkpr/aws/eks/destroy/help.json @@ -0,0 +1,4 @@ +{ + "short": "Destroy the AWS EKS", + "long": "Destroy the AWS EKS by your Gitlab CI Pipeline." +} \ No newline at end of file diff --git a/vkpr/aws/eks/destroy/src/main.sh b/vkpr/aws/eks/destroy/src/main.sh index 736f5ce4..cf647088 100755 --- a/vkpr/aws/eks/destroy/src/main.sh +++ b/vkpr/aws/eks/destroy/src/main.sh @@ -1,5 +1,11 @@ #!/bin/bash +VKPR_SCRIPTS=~/.vkpr/src + +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh + # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only diff --git a/vkpr/aws/eks/help.json b/vkpr/aws/eks/help.json new file mode 100644 index 00000000..ede3bab7 --- /dev/null +++ b/vkpr/aws/eks/help.json @@ -0,0 +1,4 @@ +{ + "short": "Manage AWS EKS", + "long": "Amazon Elastic Kubernetes Service (Amazon EKS) gives you the flexibility to start, run, and scale Kubernetes applications in the AWS Cloud or on-premises." +} \ No newline at end of file diff --git a/vkpr/aws/eks/up/README.md b/vkpr/aws/eks/up/README.md index b77f7784..f3fce5f2 100755 --- a/vkpr/aws/eks/up/README.md +++ b/vkpr/aws/eks/up/README.md @@ -1,13 +1,39 @@ # Description -Formula description +Fork the project from [Gitops EKS](https://gitlab.com/vkpr/aws-eks) and run the pipeline to build the terraform config. -## Command +## Commands + +Interactive inputs: ```bash -rit vkpr aws eks up +vkpr aws eks up ``` -## Requirements +Non-interactive: + +```bash +rit set credential --fields="accesskeyid,secretaccesskey" --provider="aws" --values="," +rit set credential --fields="token,username" --provider="gitlab" --values="," +vkpr aws eks up --aws_region="us-east-1" +``` + +```bash +vkpr aws eks up --default +``` -## Demonstration +## Parameters + +```bash + --aws_region= Define the region to create the EKS. Default: us-east-1 + --default= Set all values with default. +``` + +## Globals File Parameters + +```yaml +global: + aws: + eks: + aws_region: +``` diff --git a/vkpr/aws/eks/up/config.json b/vkpr/aws/eks/up/config.json index df9345a5..7bf24fd5 100755 --- a/vkpr/aws/eks/up/config.json +++ b/vkpr/aws/eks/up/config.json @@ -1,5 +1,4 @@ { - "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", "inputs": [ { "name": "aws_access_key", diff --git a/vkpr/aws/eks/up/help.json b/vkpr/aws/eks/up/help.json new file mode 100644 index 00000000..7f8de3bd --- /dev/null +++ b/vkpr/aws/eks/up/help.json @@ -0,0 +1,4 @@ +{ + "short": "Build AWS EKS with Gitops", + "long": "Build the terraform module in your Gitlab CI Pipeline forked by a AWS EKS project." +} \ No newline at end of file diff --git a/vkpr/aws/eks/up/metadata.json b/vkpr/aws/eks/up/metadata.json index b9615a24..deaea978 100755 --- a/vkpr/aws/eks/up/metadata.json +++ b/vkpr/aws/eks/up/metadata.json @@ -15,4 +15,4 @@ "eks", "up" ] -} +} \ No newline at end of file diff --git a/vkpr/aws/eks/up/src/main.sh b/vkpr/aws/eks/up/src/main.sh index 9697102d..cf647088 100755 --- a/vkpr/aws/eks/up/src/main.sh +++ b/vkpr/aws/eks/up/src/main.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! -d ~/.vkpr/global ]; then - echo "Doesn't initializated the vkpr... Call again the function" - rit vkpr init - exit; -fi +VKPR_SCRIPTS=~/.vkpr/src -source ~/.vkpr/global/log.sh -source ~/.vkpr/global/var.sh -source ~/.vkpr/global/helper.sh -source ~/.vkpr/global/.env +source $VKPR_SCRIPTS/log.sh +source $VKPR_SCRIPTS/var.sh +source $VKPR_SCRIPTS/helper.sh # shellcheck source=/dev/null . "$(dirname "$0")"/unix/formula/formula.sh --source-only From 65e3585b0e97b820dd2a2f50e4010d3f9f063ca8 Mon Sep 17 00:00:00 2001 From: Jpeedroza Date: Fri, 10 Sep 2021 15:37:25 -0300 Subject: [PATCH 25/25] Deleted vkpr globals due to lack of use and purpose --- vkpr/globals/help.json | 4 --- vkpr/globals/set/README.md | 13 -------- vkpr/globals/set/build.sh | 12 -------- vkpr/globals/set/config.json | 27 ----------------- vkpr/globals/set/help.json | 4 --- vkpr/globals/set/metadata.json | 17 ----------- vkpr/globals/set/src/main.sh | 12 -------- vkpr/globals/set/src/unix/formula/formula.sh | 31 -------------------- 8 files changed, 120 deletions(-) delete mode 100644 vkpr/globals/help.json delete mode 100755 vkpr/globals/set/README.md delete mode 100755 vkpr/globals/set/build.sh delete mode 100755 vkpr/globals/set/config.json delete mode 100644 vkpr/globals/set/help.json delete mode 100755 vkpr/globals/set/metadata.json delete mode 100755 vkpr/globals/set/src/main.sh delete mode 100755 vkpr/globals/set/src/unix/formula/formula.sh diff --git a/vkpr/globals/help.json b/vkpr/globals/help.json deleted file mode 100644 index b9f57e07..00000000 --- a/vkpr/globals/help.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "short": "Manage Globals", - "long": "Manage Globals" -} \ No newline at end of file diff --git a/vkpr/globals/set/README.md b/vkpr/globals/set/README.md deleted file mode 100755 index 4cee78e1..00000000 --- a/vkpr/globals/set/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Description - -Formula description - -## Command - -```bash -rit vkpr globals set -``` - -## Requirements - -## Demonstration diff --git a/vkpr/globals/set/build.sh b/vkpr/globals/set/build.sh deleted file mode 100755 index ce55095f..00000000 --- a/vkpr/globals/set/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -BIN_FOLDER=bin -BINARY_NAME_UNIX=run.sh -ENTRY_POINT_UNIX=main.sh - -#bash-build: - mkdir -p $BIN_FOLDER - cp -r src/* $BIN_FOLDER - mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX - chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX - diff --git a/vkpr/globals/set/config.json b/vkpr/globals/set/config.json deleted file mode 100755 index f293e841..00000000 --- a/vkpr/globals/set/config.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "inputs": [ - { - "label": "Type of global:", - "name": "global_type", - "required": true, - "type": "text", - "items": [ - "credential", - "file" - ], - "default": "file" - }, - { - "label": "Type the env name:", - "name": "name", - "type": "text" - }, - { - "label": "Type the env content:", - "name": "content", - "type": "text" - } - ], - "template": "shell-bat", - "templateRelease:": "2.16.2" -} \ No newline at end of file diff --git a/vkpr/globals/set/help.json b/vkpr/globals/set/help.json deleted file mode 100644 index 44b760be..00000000 --- a/vkpr/globals/set/help.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "short": "Set a new variable", - "long": "Set a new variable by the methods credential or env" -} \ No newline at end of file diff --git a/vkpr/globals/set/metadata.json b/vkpr/globals/set/metadata.json deleted file mode 100755 index 2e588971..00000000 --- a/vkpr/globals/set/metadata.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "execution": [ - "local" - ], - "os": { - "deps": [], - "support": [ - "mac", - "linux" - ] - }, - "tags": [ - "vkpr", - "globals", - "set" - ] -} diff --git a/vkpr/globals/set/src/main.sh b/vkpr/globals/set/src/main.sh deleted file mode 100755 index 8a7d61d5..00000000 --- a/vkpr/globals/set/src/main.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -VKPR_SCRIPTS=~/.vkpr/src - -source $VKPR_SCRIPTS/log.sh -source $VKPR_SCRIPTS/var.sh -source $VKPR_SCRIPTS/helper.sh - -# shellcheck source=/dev/null -. "$(dirname "$0")"/unix/formula/formula.sh --source-only - -runFormula \ No newline at end of file diff --git a/vkpr/globals/set/src/unix/formula/formula.sh b/vkpr/globals/set/src/unix/formula/formula.sh deleted file mode 100755 index a5fb0cb4..00000000 --- a/vkpr/globals/set/src/unix/formula/formula.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -runFormula() { - VKPR_GLOBAL_TYPE=$GLOBAL_TYPE - VKPR_GLOBAL_NAME=$(echo "$NAME" | tr '[a-z]' '[A-Z]') - VKPR_GLOBAL_CONTENT=$CONTENT - - case $VKPR_GLOBAL_TYPE in - credential) - createEnvCredential - ;; - file) - createEnvFile - ;; - esac -} - -createEnvCredential() { - read -p "$(echoColor "bold" "$(echoColor "green" "?")") $(echoColor "bold" "Type of provider : (vkpr)")" VKPR_GLOBAL_PROVIDER - VKPR_GLOBAL_PROVIDER=${VKPR_GLOBAL_PROVIDER:-vkpr} - rit set credential --provider=$VKPR_GLOBAL_PROVIDER --fields="$VKPR_GLOBAL_NAME" --values="$VKPR_GLOBAL_CONTENT" -} - -createEnvFile() { - if [ ! -d $VKPR_GLOBALS ]; then - mkdir -p $VKPR_GLOBALS - fi - if [ ! -z $VKPR_GLOBAL_NAME ]; then - printf "VKPR_ENV_$VKPR_GLOBAL_NAME=$VKPR_GLOBAL_CONTENT\n" >> $VKPR_GLOBALS/.env - fi -} \ No newline at end of file