Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
demo for DW
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosrodlop committed Sep 22, 2022
1 parent 981ea1f commit 7e61945
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 41 deletions.
7 changes: 3 additions & 4 deletions bin/reload-cbci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ fi

kubectl delete pod cjoc-0
kubectl rollout status sts cjoc

kubectl top node

for x in $(seq 0 $(( MC_COUNT - 1))); do
Expand All @@ -33,9 +32,9 @@ for x in $(seq 0 $(( MC_COUNT - 1))); do
bash "$BIN/wake-and-build.sh" "$mc" easily-resumable
bash "$BIN/wake-and-build.sh" "$mc" uses-agents
done
if [ $(( x % 5 )) == 0 ]; then
setAWSRoleSession
fi
# if [ $(( x % 5 )) == 0 ]; then
# setAWSRoleSession
# fi
done

kubectl top node
2 changes: 1 addition & 1 deletion bin/scale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ do
# https://issues.jenkins.io/browse/JENKINS-67097 workaround:
kubectl delete pod --all --force
fi
setAWSRoleSession
#setAWSRoleSession
eksctl scale nodegroup --cluster="$CLUSTER_NAME" --name=ng-linux --nodes=$SCALE --region="$AWS_DEFAULT_REGION"
until [ "$(kubectl get nodes | grep -c 'Ready')" -eq "$SCALE" ]
do
Expand Down
11 changes: 7 additions & 4 deletions bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ deploy_infra() {
sed "s/@NAME@/$DEMO_NAME/g; s/@REGION@/$AWS_DEFAULT_REGION/g; s/@ACCOUNT@/$ACCOUNT/g; s/@ZONE1@/$ZONE1/g; s/@ZONE2@/$ZONE2/g; s/@SUFFIX@/$SUFFIX/g" < cluster.yaml > "/tmp/$CLUSTER_NAME-cluster.yaml"
eksctl create cluster -f "/tmp/$CLUSTER_NAME-cluster.yaml"
#It should match with use-context demo.profile.sh
kubectl config rename-context "AWSCLI-Session@${CLUSTER_NAME}.${AWS_DEFAULT_REGION}.eksctl.io" "$CLUSTER_NAME-$AWS_DEFAULT_REGION"
current_context=$(kubectl config get-contexts | grep "*" | awk '{print $2}' | xargs)
kubectl config rename-context "$current_context" "$CLUSTER_NAME-$AWS_DEFAULT_REGION"
INFO "Checking Deployed Nodes"
kubectl get nodes
setState "build.$AWS_DEFAULT_REGION.infra" true
Expand All @@ -48,7 +49,7 @@ deploy_apps(){
INFO "Checking Deployed Resources"
kubectl get all -A -o wide
INFO "Checking Metrics for Nodes"
kubectl top nodes
kubectl top nodes || WARN "Metrics Server not deployed"
setState "build.$AWS_DEFAULT_REGION.apps" true
INFO "New set of apps deployed for $AWS_DEFAULT_REGION"
else
Expand All @@ -59,6 +60,7 @@ setBackUpScheduller(){
if [ "$(getState "build.backups")" = false ] && ! velero get schedule cbci-dr &>/dev/null; then
in-east
INFO "Prepare Velero Scheduller. As desired you can also manually schedule: TZ=UTC velero backup create --from-schedule cbci-dr"
velero delete schedule cbci-dr --confirm || INFO "No previous scheduller"
velero create schedule cbci-dr --schedule='@every 15m' --ttl 1h --include-namespaces cbci --exclude-resources pods,events,events.events.k8s.io
INFO 'Watch Velero progress live:'
INFO 'while :; do kubectl logs -n velero -f deploy/velero || sleep 1; done'
Expand Down Expand Up @@ -88,9 +90,9 @@ do
ZONE1=${AWS_DEFAULT_REGION}b
ZONE2=${AWS_DEFAULT_REGION}a
fi
setAWSRoleSession
#setAWSRoleSession
deploy_infra
setAWSRoleSession
#setAWSRoleSession
deploy_apps
done
INFO "-------------------------------"
Expand All @@ -109,4 +111,5 @@ INFO "Preparing Jenkins Token for Remote authentication"
#https://github.com/jenkinsci/configuration-as-code-plugin/issues/1830 hard to make a crumb
crumb=$(curl -s -u admin:$pass -c /tmp/cookies http://$ROUTE_53_DOMAIN/cjoc/crumbIssuer/api/xml'?xpath=concat(//crumbRequestField,":",//crumb)')
token=$(curl -s -u admin:$pass -H $crumb -d newTokenName=general -b /tmp/cookies http://$ROUTE_53_DOMAIN/cjoc/user/admin/descriptorByName/jenkins.security.ApiTokenProperty/generateNewToken | jq -r .data.tokenValue)
kubectl delete secret api-token --namespace cbci || INFO "No api-token secret"
kubectl create secret generic api-token --from-literal=token="$token" --namespace cbci
12 changes: 10 additions & 2 deletions demo.profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#######################

export AWS_PROFILE="example-profile" # https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
export AWS_ASSUME_ROLE="example-rol" # Optional (Set it to null in case you work with user credentials)
export AWS_ASSUME_ROLE="example-rol-arn" # Optional (Set it to null in case you work with user credentials)
export ROUTE_53_DOMAIN="dr.example.com"
export ROUTE_53_ZONE_ID="Z041787_EXAMPLE"
export MY_DEMO_ID="ex"
Expand Down Expand Up @@ -100,7 +100,7 @@ EOF
export SUFFIX="$suffix"
export CLUSTER_NAME="$demo-$suffix"
## AWS
setAWSRoleSession
#setAWSRoleSession
sleep 1
account=$(aws sts get-caller-identity | jq -r .Account)
export ACCOUNT="$account"
Expand Down Expand Up @@ -163,6 +163,14 @@ ERROR(){
exit 1
}

WARN(){
local function_name="${FUNCNAME[1]}"
local msg="$1"
timeAndDate=$(date)
echo "[$timeAndDate] [WARN] [${0}] [$function_name] $msg"
exit 1
}

#######################
## Init
#######################
Expand Down
67 changes: 37 additions & 30 deletions helm/hf.common.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repositories:
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: vmware-tanzu
url: https://vmware-tanzu.github.io/helm-charts
- name: bitnami
url: https://charts.bitnami.com/bitnami
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: vmware-tanzu
url: https://vmware-tanzu.github.io/helm-charts
- name: bitnami
url: https://charts.bitnami.com/bitnami
helmDefaults:
wait: true
timeout: 1200
Expand All @@ -13,27 +13,34 @@ helmDefaults:
createNamespace: true
cleanupOnFail: true
releases:
# https://bitnami.com/stack/metrics-server/helm
- name: metrics-server
namespace: kube-system
chart: bitnami/metrics-server
version: "6.0.0"
hooks:
- events: ["postsync"]
showlogs: true
command: "helm"
args: ["upgrade", "--namespace", "kube-system", "metrics-server", "bitnami/metrics-server", "--set", "apiService.create=true"]
# https://artifacthub.io/packages/helm/vmware-tanzu/velero
- name: velero
namespace: velero
chart: vmware-tanzu/velero
version: "2.24.0"
values:
- /tmp/velero.yaml
# https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx
- name: ingress
namespace: ingress
chart: ingress-nginx/ingress-nginx
version: "4.0.3"
values:
- ingress.yaml
# https://bitnami.com/stack/metrics-server/helm
- name: metrics-server
namespace: kube-system
chart: bitnami/metrics-server
version: "6.0.0"
set:
- name: apiService.create
value: true
- name: hostNetwork.enabled
value: true
- name: metrics.enabled
value: true
# hooks:
# - events: ["postsync"]
# showlogs: true
# command: "helm"
# args: ["upgrade", "--namespace", "kube-system", "metrics-server", "bitnami/metrics-server", "--set", "apiService.create=true"]
# https://artifacthub.io/packages/helm/vmware-tanzu/velero
- name: velero
namespace: velero
chart: vmware-tanzu/velero
version: "2.24.0"
values:
- /tmp/velero.yaml
# https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx
- name: ingress
namespace: ingress
chart: ingress-nginx/ingress-nginx
version: "4.0.3"
values:
- ingress.yaml

0 comments on commit 7e61945

Please sign in to comment.