File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ CLUSTER=$(kubectl config current-context | cut -d"/" -f2)
77NAMESPACE=< % .Name %>
88REGION=< % index .Params ` region` %>
99
10+ if [[ " $CLUSTER " = * " -stage-" * ]]; then
11+ DEFAULT_IP=" 10.10.199.200"
12+ else
13+ DEFAULT_IP=" 10.10.99.200"
14+ fi
15+
1016# get pod id for execution
1117POD=$( kubectl -n vpn get pods --selector=app=wireguard -o jsonpath=' {.items[0].metadata.name}' )
1218
@@ -16,7 +22,7 @@ if [ -z "$POD" ]; then
1622fi
1723
1824function k8s_exec() {
19- kubectl -n vpn exec -it $POD -- /bin/bash -c " $1 "
25+ kubectl -n vpn exec $POD wireguard --container wireguard -- /bin/bash -c " $1 "
2026}
2127
2228# get name
@@ -32,6 +38,8 @@ client_public_key=$(k8s_exec "echo -n $client_private_key | wg pubkey | tr -d \"
3238
3339# get next available IP
3440existing_ips=$( k8s_exec " cat /etc/wireguard/wg0.conf | grep AllowedIPs| cut -d\" \" -f3 | cut -d\" /\" -f1 | sort" )
41+ # Default start at 201 if no existing IPs are found
42+ existing_ips=${existing_ips:- $DEFAULT_IP }
3543last_ip=$( echo " $existing_ips " | tr -cd " [:alnum:].\n" | tail -1)
3644next_ip=$last_ip
3745while [[ " $existing_ips " =~ " $next_ip " ]]; do
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ DOCKER_IMAGE_TAG=commitdev/zero-k8s-utilities:0.0.3
3535# database info preparation
3636# this script will run both before and after make-apply-k8s, therefore the database service is not always available
3737DB_ENDPOINT=$( aws rds describe-db-instances --region=$REGION --db-instance-identifier " ${PROJECT_NAME} -${ENVIRONMENT} " --query " DBInstances[0].Endpoint.Address" | jq -r ' .' )
38- DB_NAME_LIST=$( echo ${DATABASE_NAME} | tr -dc ' A-Za-z0-9 ' ) # used by job
38+ DB_NAME_LIST=$( echo ${DATABASE_NAME} | tr -dc ' A-Za-z0-9_ ' ) # used by job
3939DB_NAME=$( echo ${DB_NAME_LIST} | cut -d" " -f1) # used by db-pod
4040DB_TYPE=${DATABASE_TYPE}
4141# # get rds master
Original file line number Diff line number Diff line change 33PROJECT=< % .Name %>
44AWS_DEFAULT_REGION=< % index .Params ` region` %>
55RANDOM_SEED=" <% index .Params ` randomSeed` %>"
6+ DATABASE_TYPE=< % index .Params ` database` %>
67ENVIRONMENT=stage # only apply to Staging environment
78
8- DEV_DB_LIST=$( aws iam get-group --group-name ${PROJECT} -developer-${ENVIRONMENT} | jq -r ' "dev" + .Users[].UserName' | tr ' \n' ' ' )
9+ # # Creating each member in developer IAM group a dev-database
10+ # # name: john-doe -> dbname: dev_johndoe
11+ DEV_DB_LIST=$( aws iam get-group --group-name ${PROJECT} -developer-${ENVIRONMENT} | jq -r ' "dev_" + .Users[].UserName' | tr ' \n' ' ' )
912if [[ -z " ${DEV_DB_LIST} " ]]; then
1013 echo " $0 : No developers available yet, skip."
1114 exit 0
@@ -20,11 +23,11 @@ if [[ $? -eq 0 ]]; then
2023 PROJECT_NAME=${PROJECT} \
2124 ENVIRONMENT=${ENVIRONMENT} \
2225 NAMESPACE=${PROJECT} \
23- DATABASE_TYPE=< % index .Params ` database ` % > \
26+ DATABASE_TYPE=${DATABASE_TYPE} \
2427 DATABASE_NAME=" ${DEV_DB_LIST} " \
25- SECRET_NAME=devenv${PROJECT} \
28+ SECRET_NAME=devenv- ${PROJECT} \
2629 USER_NAME=dev${PROJECT} \
2730 USER_PASSWORD=${DEV_DB_SECRET} \
28- CREATE_SECRET=secret-application.yml .tpl \
31+ CREATE_SECRET=secret-application.json .tpl \
2932 sh ./create-db-user.sh
3033fi
You can’t perform that action at this time.
0 commit comments