Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stage' into VKPR-178
Browse files Browse the repository at this point in the history
  • Loading branch information
luangazin committed Oct 26, 2021
2 parents 214dfdb + 606c899 commit 5d804fc
Show file tree
Hide file tree
Showing 22 changed files with 339 additions and 18 deletions.
1 change: 1 addition & 0 deletions vkpr/cert-manager/install/aws/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions vkpr/cert-manager/install/aws/build.sh
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
59 changes: 59 additions & 0 deletions vkpr/cert-manager/install/aws/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"inputs": [
{
"label": "Type your email to use to generate certificates:",
"default": "[email protected]",
"name": "email",
"required": true,
"tutorial": "<email>@<domain>",
"type": "text",
"cache": {
"active": true,
"qty": 2,
"newLabel": "Type other email: "
}
},
{
"default": "letsencrypt-staging",
"items": [
"letsencrypt-staging",
"letsencrypt-production"
],
"label": "What is the default cluster issuer? ",
"name": "issuer",
"required": true,
"type": "text"
},
{
"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": "aws_iam_role_arn",
"label": "Type your IAM Role ARN: ",
"type": "text",
"cache": {
"active": true,
"qty": 2,
"newLabel": "Type another IAM Role ARN: "
}
}
],
"template": "shell-bat",
"templateRelease": "2.17.0"
}
4 changes: 4 additions & 0 deletions vkpr/cert-manager/install/aws/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "",
"long": ""
}
18 changes: 18 additions & 0 deletions vkpr/cert-manager/install/aws/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"execution": [
"local"
],
"os": {
"deps": [],
"support": [
"mac",
"linux"
]
},
"tags": [
"vkpr",
"cert-manager",
"install",
"aws"
]
}
11 changes: 11 additions & 0 deletions vkpr/cert-manager/install/aws/src/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

VKPR_SCRIPTS=~/.vkpr/src

source $VKPR_SCRIPTS/log.sh
source $VKPR_SCRIPTS/var.sh
source $VKPR_SCRIPTS/helper.sh

. "$(dirname "$0")"/unix/formula/formula.sh --source-only

runFormula
67 changes: 67 additions & 0 deletions vkpr/cert-manager/install/aws/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

runFormula() {
checkGlobalConfig $EMAIL "[email protected]" "cert-manager.email" "EMAIL"

startInfos
installCRDS
addCertManager
installCertManager
addTokenDNS
installIssuer
}

installCRDS() {
echoColor "yellow" "Installing cert-manager CRDS beforehand..."
$VKPR_KUBECTL apply -f "https://github.com/jetstack/cert-manager/releases/download/$VKPR_CERT_VERSION/cert-manager.crds.yaml"
}

addCertManager() {
registerHelmRepository jetstack https://charts.jetstack.io
}

installCertManager() {
echoColor "yellow" "Installing cert-manager..."
local VKPR_CERT_MANAGER_VALUES=$(dirname "$0")/utils/cert-manager.yaml
local VKPR_ENV_CERT_ISSUER="$ISSUER"
$VKPR_YQ eval $VKPR_CERT_MANAGER_VALUES \
| $VKPR_HELM upgrade -i -f - \
-n cert-manager --create-namespace \
--set ingressShim.defaultIssuerName="$VKPR_ENV_CERT_ISSUER" \
--version "$VKPR_CERT_VERSION" \
--wait \
cert-manager jetstack/cert-manager
}


addTokenDNS() {
local VKPR_CERT_TOKEN=$(dirname "$0")/utils/route53-secret.yaml
local BASE64_ARGS="" # detect OS for proper base64 args
if [[ "$OSTYPE" != "darwin"* ]]; then
BASE64_ARGS="-w0"
fi
echoColor "yellow" "Adding the Token..."
local VKPR_INPUT_SECRET_KEY_BASE64=$(echo "$AWS_SECRET_KEY" | base64 $BASE64_ARGS)
$VKPR_YQ eval '.data.secret-access-key = strenv(VKPR_INPUT_SECRET_KEY_BASE64) |
.data.secret-access-key style = "double"' "$VKPR_CERT_TOKEN" \
| $VKPR_KUBECTL apply -f -
}

installIssuer() {
echoColor "yellow" "Installing Issuers and/or ClusterIssuers..."
local VKPR_ISSUER_VALUES=$(dirname "$0")/utils/issuers.yaml
local VKPR_ENV_INPUT_EMAIL="$VKPR_ENV_EMAIL"
$VKPR_YQ eval '.spec.acme.email = "'$VKPR_ENV_INPUT_EMAIL'" |
.spec.acme.solvers[0].dns01.route53.region = "'$AWS_REGION'" |
.spec.acme.solvers[0].dns01.route53.accessKeyID = "'$AWS_ACCESS_KEY'" |
.spec.acme.solvers[0].dns01.route53.role = "'$AWS_IAM_ROLE_ARN'"' "$VKPR_ISSUER_VALUES" \
| $VKPR_KUBECTL apply -f -
}

startInfos() {
echo "=============================="
echoColor "bold" "$(echoColor "green" "VKPR Cert-manager Install Routine")"
echoColor "bold" "$(echoColor "blue" "Provider:") AWS"
echoColor "bold" "$(echoColor "blue" "Email:") ${VKPR_ENV_EMAIL}"
echo "=============================="
}
23 changes: 23 additions & 0 deletions vkpr/cert-manager/install/aws/src/utils/IAM-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "route53:GetChange",
"Resource": "arn:aws:route53:::change/*"
},
{
"Effect": "Allow",
"Action": [
"route53:ChangeResourceRecordSets",
"route53:ListResourceRecordSets"
],
"Resource": "arn:aws:route53:::hostedzone/*"
},
{
"Effect": "Allow",
"Action": "route53:ListHostedZonesByName",
"Resource": "*"
}
]
}
7 changes: 7 additions & 0 deletions vkpr/cert-manager/install/aws/src/utils/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
installCRDs: false
ingressShim:
defaultIssuerName: letsencrypt-staging
defaultIssuerKind: ClusterIssuer
defaultIssuerGroup: cert-manager.io
prometheus:
enabled: false
43 changes: 43 additions & 0 deletions vkpr/cert-manager/install/aws/src/utils/issuers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
namespace: cert-manager
spec:
acme:
email: [email protected]
server: https://acme-staging-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt-staging-key
solvers:
- selector: {}
dns01:
route53:
region: <region>
accessKeyID: <access-key>
secretAccessKeySecretRef:
name: route53-secret
key: secret-access-key
role: <iam-role-arn>
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
namespace: cert-manager
spec:
acme:
email: [email protected]
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt-production-key
solvers:
- selector: {}
dns01:
route53:
region: <region>
accessKeyID: <access-key>
secretAccessKeySecretRef:
name: route53-secret
key: secret-access-key
role: <iam-role-arn>
8 changes: 8 additions & 0 deletions vkpr/cert-manager/install/aws/src/utils/route53-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: route53-secret
namespace: cert-manager
type: Opaque
data:
secret-access-key: <secret-access-key>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ installCertManager() {
-n cert-manager --create-namespace \
--version "$VKPR_CERT_VERSION" \
--wait \
vkpr-cert-manager jetstack/cert-manager
cert-manager jetstack/cert-manager
}

installIssuer() {
Expand Down
2 changes: 1 addition & 1 deletion vkpr/cert-manager/install/do/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ installCertManager() {
--set ingressShim.defaultIssuerName="$VKPR_ENV_CERT_ISSUER" \
--version "$VKPR_CERT_VERSION" \
--wait \
vkpr-cert-manager jetstack/cert-manager
cert-manager jetstack/cert-manager
}


Expand Down
15 changes: 0 additions & 15 deletions vkpr/cert-manager/install/do/src/utils/cert-manager-custom-ca.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion vkpr/create/formula/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ runFormula() {
if [ -z "$VKPR_WORKSPACE_PATH" ]; then
REAL_WORKSPACE_PATH="$CURRENT_PWD"
fi
#echo "DEBUG VKPR_FORMULA_PATH='$VKPR_FORMULA_PATH'"
#echo "DEBUG VKPR_FORMULA='$VKPR_FORMULA'"

if [ -z "$VKPR_FORMULA_PATH" ]; then
REAL_FORMULA_PATH="$REAL_WORKSPACE_PATH/${VKPR_FORMULA// //}"
fi

local REAL_WORKSPACE_NAME=$(getWorkspaceName "$REAL_WORKSPACE_PATH")

startInfos

cat << EOF |
{
"formulaCmd":"$REAL_FORMULA",
Expand All @@ -34,7 +38,7 @@ startInfos() {
echoColor "bold" "$(echoColor "blue" "Formula Name:") ${VKPR_FORMULA}"
echoColor "bold" "$(echoColor "blue" "Formula Language:") ${VKPR_FORMULA_LANGUAGE}"
echoColor "bold" "$(echoColor "blue" "Formula Workspace:") ${REAL_WORKSPACE_NAME}"
echoColor "bold" "$(echoColor "blue" "Formula Path:") ${REAL_WORKSPACE_PATH}"
echoColor "bold" "$(echoColor "blue" "Formula Path:") ${REAL_FORMULA_PATH}"
echo "=============================="
}

Expand Down
1 change: 1 addition & 0 deletions vkpr/postgres/createdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions vkpr/postgres/createdb/build.sh
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
25 changes: 25 additions & 0 deletions vkpr/postgres/createdb/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"inputs": [
{
"label": "Type the new database name: ",
"name": "dbname",
"type": "text"
},
{
"label": "Type the db user name: ",
"name": "dbuser",
"type": "text"
},
{
"label": "Type the db users' password: ",
"name": "dbpassword",
"type": "text"
},
{
"name": "password",
"type": "CREDENTIAL_POSTGRES_PASSWORD"
}
],
"template": "shell-bat",
"templateRelease:": "2.16.2"
}
4 changes: 4 additions & 0 deletions vkpr/postgres/createdb/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "Create new database",
"long": "Create new database with new owner (user/passwd)"
}
17 changes: 17 additions & 0 deletions vkpr/postgres/createdb/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"execution": [
"local"
],
"os": {
"deps": [],
"support": [
"mac",
"linux"
]
},
"tags": [
"vkpr",
"postgres",
"createdb"
]
}
Loading

0 comments on commit 5d804fc

Please sign in to comment.