Merged in feature/helm (pull request #16)

Feature/helm

* Add helm details

* Modify ecr as medicalalert-web-reloaded

* Modify pipeline file

* Remove old deployment artifacts except common and pvc

* Modify for weca namesapce

* Modify for weca namesapce

* Revert the APP Change

* Revert APP to weareconnectamerica-web Again

* merge conflicts


Approved-by: Rachit Bhargava
This commit is contained in:
Jay Sharma
2024-09-04 16:56:19 +00:00
committed by Rachit Bhargava
parent 4e06f267ec
commit ed6b060261
6 changed files with 608 additions and 243 deletions

View File

@@ -15,6 +15,7 @@ definitions:
- "list-schedule-pipelines"
- "update-schedule-pipelines"
- "list-schedule-pipelines-run"
- "SELECT_FROM_DROP_DOWN"
- name: UUID
default: "ENTER_UUID_FOR_DELETION_ONLY"
- name: PIPELINE_NAME
@@ -107,10 +108,38 @@ definitions:
default: "STATIC_FILE_NAME_TO_DEPLOY"
steps:
- step: &helmpush
name: Helm package creation for env
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
script:
- if [ -e setenv.sh ]; then cat setenv.sh ; source setenv.sh ; fi && echo "This is for $ENV environment"
- git clone --branch="develop" https://x-token-auth:${cswtoken}@bitbucket.org/connectamerica/common-scripts-web.git && ls -lrth
- cp -rf ./common-scripts-web/deployment/helm/* ./deployment/helm/ && ls -lrth && cd deployment/helm && ls -lrth
- if [[ "$ENV" = "dev" || "$ENV" = "qa" ]]; then DBENV="dev qa"; else DBENV="stage prod"; fi
- >-
for ENV in $DBENV;
do
export DB_PASSWORD=$(aws ssm get-parameters --names $ENV-weareconnectamerica-masterdbpass --query "Parameters[*].{Value:Value}" --output text);
export CACHE_PASSWORD=$(aws ssm get-parameters --names redis-password --query "Parameters[*].{Value:Value}" --output text);
export DB_PASSWORD=`echo -n "$DB_PASSWORD" | base64` && sed -i "/DB_PASSWORD/c\ DB_PASSWORD:\ $DB_PASSWORD" values-$ENV.tmpl;
export CACHE_PASSWORD=`echo -n "$CACHE_PASSWORD" | base64` && sed -i "/CACHE_PASSWORD/c\ CACHE_PASSWORD:\ $CACHE_PASSWORD" values-$ENV.tmpl;
envsubst '${VERSION}' < values-$ENV.tmpl > values-$ENV.yaml;
cat values-$ENV.yaml;
done
- envsubst '${VERSION} ${APP} ${HELMREPO}' < Chart.tmpl > Chart.yaml && echo ------------ && cat Chart.yaml
- helm package .
- aws ecr get-login-password --region us-east-1 | helm registry login --username AWS --password-stdin 716593996126.dkr.ecr.us-east-1.amazonaws.com
- helm push $HELMREPO-$VERSION-$APP.tgz oci://716593996126.dkr.ecr.us-east-1.amazonaws.com/
- step: &deploy
name: deploy to $ENV environment
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -121,25 +150,11 @@ definitions:
- source setenv.sh
- fi
- echo "This is for $ENV environment"
# importing csw-token common scripts to the workspace #
- git clone --branch="develop" https://x-token-auth:${cswtoken}@bitbucket.org/connectamerica/common-scripts-web.git && ls -lrth && cp -rf ./common-scripts-web/* . && ls -lrth
- chmod 755 ./validation.sh && ./validation.sh default && echo validation-done || exit 9
- ls -lrth && cd build/${ENV}
- export DB_PASSWORD=$(aws ssm get-parameters --names $ENV-weareconnectamerica-masterdbpass --query "Parameters[*].{Value:Value}" --output text)
- export DB_PASSWORD=`echo -n "$DB_PASSWORD" | base64` && sed -i "/DB_PASSWORD/c\ DB_PASSWORD:\ $DB_PASSWORD" secrets.yaml
- envsubst < deployment.tpl > deployment.yaml
- cat deployment.yaml
- pipe: atlassian/aws-eks-kubectl-run:2.2.0
variables:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
CLUSTER_NAME: $CLUSTER
KUBECTL_COMMAND: "apply"
RESOURCE_PATH: "../${ENV}"
KUBECTL_ARGS: ""
KUBECTL_APPLY_ARGS: "-f"
DEBUG: "true"
- aws eks update-kubeconfig --name caresage-eks-cluster-$ENV --region us-east-1
- aws ecr get-login-password --region us-east-1 | helm registry login --username AWS --password-stdin 716593996126.dkr.ecr.us-east-1.amazonaws.com
- export APP="weareconnectamerica-web"
- mkdir helm && cd helm && helm pull oci://716593996126.dkr.ecr.us-east-1.amazonaws.com/$HELMREPO --version $VERSION-$APP
- tar -xzvf *$HELMREPO-$VERSION-$APP.tgz && cd $HELMREPO && helm upgrade --install --timeout 20m $APP . --namespace $APP -f values-$ENV.yaml --debug
after-script:
- aws eks update-kubeconfig --name caresage-eks-cluster-$ENV --region us-east-1
- sleep 10 && while kubectl get po -A |grep -i weareconnectamerica-web|egrep -i '0/1|crash|term'; do sleep 10; echo "--- still getting 0/1 or crash pods-----"; done
@@ -154,7 +169,7 @@ pipelines:
- step:
name: vars for schedule-pipelines
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -212,7 +227,7 @@ pipelines:
- step:
name: vars for common-jobs-prod
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -243,7 +258,7 @@ pipelines:
- step:
name: vars for common-jobs-prod
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -273,7 +288,7 @@ pipelines:
- step:
name: vars for common-jobs-prod
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -331,7 +346,7 @@ pipelines:
- step:
name: vars for common-jobs-dev
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -365,7 +380,7 @@ pipelines:
- step:
name: vars for common-jobs qa/stage/prod
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -398,7 +413,7 @@ pipelines:
- step:
name: vars for subdomain
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -464,7 +479,7 @@ pipelines:
3-release:
- <<: *set-variables
- step:
name: "plan for the release and tag the given version."
name: "plan for the release and push the given version to helm repo"
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:pipelines-awscli-latest-v01
aws:
@@ -478,8 +493,13 @@ pipelines:
- aws ecr put-image --repository-name $BITBUCKET_REPO_SLUG --image-tag $RELEASE --image-manifest "$MANIFEST" && echo ------ image $VERSION has been retagged as $RELEASE || exit 9
- echo "export VERSION=$RELEASE" >> setenv.sh
- echo "export ENV=stage" >> setenv.sh
- echo "export APP="weareconnectamerica-web"" >> setenv.sh
- echo "export HELMREPO=helm-release" >> setenv.sh
artifacts: # define the artifacts to be passed to each future step
- setenv.sh
- step:
<<: *helmpush
name: "helmpush for stage and prod release"
- step:
<<: *deploy
deployment: stage
@@ -488,7 +508,7 @@ pipelines:
- step:
name: vars for prod
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -496,6 +516,8 @@ pipelines:
- source release
- echo "export VERSION=$RELEASE" >> setenv.sh
- echo "export ENV=prod" >> setenv.sh
- echo "export APP="weareconnectamerica-web"" >> setenv.sh
- echo "export HELMREPO=helm-release" >> setenv.sh
artifacts: # define the artifacts to be passed to each future step
- setenv.sh
- step:
@@ -509,7 +531,7 @@ pipelines:
- step:
name: build the application and push that to dev env.
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
@@ -517,9 +539,9 @@ pipelines:
# importing csw-token common scripts to the workspace #
- git clone --branch="develop" https://x-token-auth:${cswtoken}@bitbucket.org/connectamerica/common-scripts-web.git && ls -lrth
- cp -rf ./common-scripts-web/* . && ls -lrth && export ENV=dev
- chmod 755 ./validation.sh && ./validation.sh default
#- chmod 755 ./validation.sh && ./validation.sh default
- export IMAGE="$BITBUCKET_REPO_SLUG" && export VERSION=$BITBUCKET_BUILD_NUMBER
- export IMAGE="$BITBUCKET_REPO_SLUG" && export VERSION="$BITBUCKET_BUILD_NUMBER" && export APP="weareconnectamerica-web"
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 716593996126.dkr.ecr.us-east-1.amazonaws.com
- docker build -t ${IMAGE} .
- docker tag ${IMAGE} ${IMAGE}:${VERSION}
@@ -538,15 +560,21 @@ pipelines:
- step:
name: vars for dev
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
script:
- echo "export VERSION=$BITBUCKET_BUILD_NUMBER" >> setenv.sh
- echo "export APP="weareconnectamerica-web"" >> setenv.sh
- echo "export ENV=dev" >> setenv.sh
- echo "export HELMREPO=helm-develop" >> setenv.sh
artifacts: # define the artifacts to be passed to each future step
- setenv.sh
- step:
<<: *helmpush
name: "helmpush for dev and qa"
- step:
<<: *deploy
deployment: dev
@@ -554,13 +582,15 @@ pipelines:
- step:
name: vars for qa
image:
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v01
name: 716593996126.dkr.ecr.us-east-1.amazonaws.com/common-images:atlassian-default-image4.x-v02
aws:
oidc-role: arn:aws:iam::716593996126:role/bitbucket-to-ecr
oidc: true
script:
- echo "export VERSION=$BITBUCKET_BUILD_NUMBER" >> setenv.sh
- echo "export ENV=qa" >> setenv.sh
- echo "export APP="weareconnectamerica-web"" >> setenv.sh
- echo "export HELMREPO=helm-develop" >> setenv.sh
artifacts:
- setenv.sh
- step: