Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/k8s-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@ jobs:
uses: ./.github/workflows/k8s-reset-data.yml
with:
environment: ${{ inputs.environment }}
chart-branch: ${{ inputs.chart-branch }}
secrets: inherit
98 changes: 58 additions & 40 deletions .github/workflows/k8s-reset-data.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
name: Reset environment
run-name: "Reset ${{ inputs.environment }} environment"
on:
workflow_dispatch:
inputs:
environment:
description: "Target environment"
required: true
type: string
workflow_call:
inputs:
environment:
type: string
workflow_dispatch:
inputs:
environment:
description: "Target environment"
required: true
type: string
chart-branch:
description: 'Helm chart version to deploy'
required: false
default: 'develop'
workflow_call:
inputs:
environment:
type: string
chart-branch:
type: string
jobs:
prepare:
outputs:
Expand Down Expand Up @@ -58,37 +64,49 @@ jobs:
matrix:
job-name:
- data-cleanup
- postgres-on-update-core
- postgres-on-update-analytics
- postgres-on-deploy
- data-migration-analytics
- data-migration
- data-seed
- elasticsearch-reindex
steps:
- name: Download helm release values file into /tmp/opencrvs-${{ inputs.environment }}.json
uses: actions/download-artifact@v4
with:
name: opencrvs-${{ inputs.environment }}-values-file
path: /tmp
- name: Create job ${{ matrix.job-name }} from helm template and apply it
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true ${{ matrix.job-name }}
helm template -f ${{ needs.prepare.outputs.values-file }} \
--set data_cleanup.enabled=true \
--set data_seed.enabled=true \
--namespace ${namespace} \
-s templates/${{ matrix.job-name }}-job.yaml \
oci://ghcr.io/opencrvs/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -
- name: Checking ${{ matrix.job-name }} job status
run: |
while true; do
kubectl wait --for=condition=ready pod -ljob-name=${{ matrix.job-name }} --timeout=300s -n ${namespace} && \
kubectl logs job/${{ matrix.job-name }} --all-containers -f -n ${namespace} && \
touch /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt || break;
sleep 1; done &
echo "---------------------- Waiting for job completion ----------------------"
kubectl wait --for=condition=complete job/${{ matrix.job-name }} -n ${namespace} --timeout=600s; status=$? || true
[ $status -ne 0 ] && kubectl get pods -n ${namespace} --show-labels && kubectl describe pod -ljob-name=${job_name} -n ${namespace};
[ ! -f /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt ] && kubectl logs job/${{ matrix.job-name }} --all-containers -n ${namespace} || \
rm -vf /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt
kill %1 2>/dev/null && echo "Stopped log streaming" || true
exit $status
- name: Checkout repo
uses: actions/checkout@v5
# FIXME: Update to charts repository once available
- name: Checkout infrastructure repository
uses: actions/checkout@v5
with:
repository: opencrvs/infrastructure
path: infrastructure
ref: ${{ inputs.chart-branch }}
- name: Verify branch status ${{ inputs.chart-branch }}
working-directory: infrastructure
run: git status
- name: Download helm release values file into /tmp/opencrvs-${{ inputs.environment }}.json
uses: actions/download-artifact@v4
with:
name: opencrvs-${{ inputs.environment }}-values-file
path: /tmp
- name: Create job ${{ matrix.job-name }} from helm template and apply it
run: |
kubectl delete job -n ${namespace} --ignore-not-found=true ${{ matrix.job-name }}
helm template -f ${{ needs.prepare.outputs.values-file }} \
--set data_cleanup.enabled=true \
--set data_seed.enabled=true \
--namespace ${namespace} \
-s templates/${{ matrix.job-name }}-job.yaml \
infrastructure/charts/opencrvs-services | kubectl apply -n ${namespace} --wait=true -f -
- name: Checking ${{ matrix.job-name }} job status
run: |
while true; do
kubectl wait --for=condition=ready pod -ljob-name=${{ matrix.job-name }} --timeout=300s -n ${namespace} && \
kubectl logs job/${{ matrix.job-name }} --all-containers -f -n ${namespace} && \
touch /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt || break;
sleep 1; done &
echo "---------------------- Waiting for job completion ----------------------"
kubectl wait --for=condition=complete job/${{ matrix.job-name }} -n ${namespace} --timeout=600s; status=$? || true
[ $status -ne 0 ] && kubectl get pods -n ${namespace} --show-labels && kubectl describe pod -ljob-name=${job_name} -n ${namespace};
[ ! -f /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt ] && kubectl logs job/${{ matrix.job-name }} --all-containers -n ${namespace} || \
rm -vf /tmp/logs_stramed-${namespace}-${{ matrix.job-name }}.txt
kill %1 2>/dev/null && echo "Stopped log streaming" || true
exit $status
Loading