Skip to content

Reset demo environment (namespace: opencrvs-demo) #1

Reset demo environment (namespace: opencrvs-demo)

Reset demo environment (namespace: opencrvs-demo) #1

name: Reset environment
run-name: "Reset ${{ inputs.environment }} environment (namespace: ${{ inputs.namespace }})"
# FIXME:
# - replace sleep 30 with kubectl wait for job completion
on:
workflow_dispatch:
inputs:
namespace:
description: "Target namespace"
required: true
type: string
environment:
description: "Target environment"
required: true
type: string
workflow_call:
inputs:
namespace:
type: string
environment:
type: string
jobs:
reset:
environment: ${{ inputs.environment }}
env:
namespace: ${{ inputs.namespace }}
runs-on:
- self-hosted
- k8s
- ${{ inputs.environment }}
steps:
- name: Get helm release values
run: helm get values opencrvs -n ${namespace} > ${namespace}.yaml
- name: Cleanup environment
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true data-cleanup
helm template -f ${namespace}.yaml \
--set data_cleanup.enabled=true \
--namespace ${namespace} \
-s templates/data-cleanup-job.yaml \
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -
sleep 30;
kubectl logs job/data-cleanup -f --all-containers=true -n ${namespace} || true
kubectl wait --for=condition=complete job/data-cleanup -n ${namespace} --timeout=600s;
kubectl delete pod -n ${namespace} -lapp=events;
kubectl wait --for=condition=ready pod -n ${namespace} -lapp=events;
- name: Re-run postgres on-deploy
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true postgres-on-deploy;
helm template -f ${namespace}.yaml \
-s templates/postgres-on-update.yaml \
--namespace ${namespace} \
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -;
sleep 30;
kubectl logs job/postgres-on-deploy -f --all-containers=true -n ${namespace};
kubectl wait --for=condition=complete job/postgres-on-deploy -n ${namespace} --timeout=600s;
- name: Migration
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true data-migration
helm template -f ${namespace}.yaml \
-s templates/data-migration-job.yaml \
--namespace ${namespace} \
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -
sleep 30;
kubectl logs job/data-migration -f -n ${namespace} || true
kubectl wait --for=condition=complete job/data-migration -n ${namespace} --timeout=600s;
- name: Re-run postgres on-deploy
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true postgres-on-deploy;
helm template -f ${namespace}.yaml \
-s templates/postgres-on-update.yaml \
--namespace ${namespace} \
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -;
sleep 30;
kubectl logs job/postgres-on-deploy -f --all-containers=true -n ${namespace};
kubectl wait --for=condition=complete job/postgres-on-deploy -n ${namespace} --timeout=600s;
- name: Seeding data
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true data-seed
kubectl delete pod -n ${namespace} -lapp=events;
kubectl wait --for=condition=ready pod -n ${namespace} -lapp=events;
helm template -f ${namespace}.yaml \
--set data_seed.enabled=true \
--namespace ${namespace} \
-s templates/data-seed-job.yaml \
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait -f -
sleep 30;
kubectl logs job/data-seed -f -n ${namespace} || true
kubectl wait --for=condition=complete job/data-seed -n ${namespace} --timeout=600s;
kubectl delete pod -n ${namespace} -lapp=events;