-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
958 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Description | ||
|
||
Create a Cluster EKS in AWS with [Gitops Terraform Module](https://gitlab.com/vkpr/terraform-aws-eks). | ||
|
||
## Commands | ||
|
||
Interactive inputs: | ||
|
||
```bash | ||
vkpr aws eks deploy | ||
``` | ||
|
||
Non-interactive: | ||
|
||
```bash | ||
rit set credential --fields="token,username" --provider="gitlab" --values="<your-gitlab-token>,<your-gitlab-username>" | ||
vkpr aws eks deploy | ||
``` | ||
|
||
**Note**: If you set the credentials of gitlab in formula `vkpr aws eks up`, you dont need to set again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "gitlab_token", | ||
"type": "CREDENTIAL_GITLAB_TOKEN" | ||
}, | ||
{ | ||
"name": "gitlab_username", | ||
"type": "CREDENTIAL_GITLAB_USERNAME" | ||
} | ||
], | ||
"template": "shell-bat", | ||
"templateRelease:": "2.16.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"execution": [ | ||
"local" | ||
], | ||
"os": { | ||
"deps": [], | ||
"support": [ | ||
"mac", | ||
"linux" | ||
] | ||
}, | ||
"tags": [ | ||
"vkpr", | ||
"aws", | ||
"eks", | ||
"deploy" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Description | ||
|
||
Destroy the EKS in AWS. | ||
|
||
## Commands | ||
|
||
Non-interactive: | ||
|
||
```bash | ||
vkpr aws eks destroy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "gitlab_token", | ||
"type": "CREDENTIAL_GITLAB_TOKEN" | ||
}, | ||
{ | ||
"name": "gitlab_username", | ||
"type": "CREDENTIAL_GITLAB_USERNAME" | ||
} | ||
], | ||
"template": "shell-bat", | ||
"templateRelease:": "2.16.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"short": "Destroy the AWS EKS", | ||
"long": "Destroy the AWS EKS by your Gitlab CI Pipeline." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"execution": [ | ||
"local" | ||
], | ||
"os": { | ||
"deps": [], | ||
"support": [ | ||
"mac", | ||
"linux" | ||
] | ||
}, | ||
"tags": [ | ||
"vkpr", | ||
"aws", | ||
"eks", | ||
"destroy" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
runFormula() { | ||
PROJECT_ID=$(curl https://gitlab.com/api/v4/users/$GITLAB_USERNAME/projects | 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Description | ||
|
||
Fork the project from [Gitops EKS](https://gitlab.com/vkpr/aws-eks) and run the pipeline to build the terraform config. | ||
|
||
## Commands | ||
|
||
Interactive inputs: | ||
|
||
```bash | ||
vkpr aws eks up | ||
``` | ||
|
||
Non-interactive: | ||
|
||
```bash | ||
rit set credential --fields="accesskeyid,secretaccesskey" --provider="aws" --values="<your-access-key-id>,<your-secret-access-key>" | ||
rit set credential --fields="token,username" --provider="gitlab" --values="<your-gitlab-token>,<your-gitlab-username>" | ||
vkpr aws eks up --aws_region="us-east-1" | ||
``` | ||
|
||
```bash | ||
vkpr aws eks up --default | ||
``` | ||
|
||
## 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: <String> | ||
``` |
Oops, something went wrong.