#!/usr/bin/env bash set -euo pipefail export KUBECONFIG=/Users/chrisfu/dev/knoe/knoe-k3s.kubeconfig echo "==> Deleting failed migrations job so operator can recreate it..." kubectl -n gitlab delete job -l app=migrations --ignore-not-found echo "==> Patching GitLab CR — extraVolumes/extraVolumeMounts as YAML strings..." # The GitLab chart expects extraVolumes/extraVolumeMounts as YAML strings, not arrays kubectl -n gitlab patch gitlab gitlab --type=merge -p '{ "spec":{"chart":{"values":{ "global":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"} }, "gitlab":{ "migrations":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"}, "extraVolumes":"- name: jemalloc-16k\n hostPath:\n path: /opt/gitlab-jemalloc\n type: Directory\n", "extraVolumeMounts":"- name: jemalloc-16k\n mountPath: /opt/gitlab-jemalloc\n readOnly: true\n" }, "sidekiq":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"}, "extraVolumes":"- name: jemalloc-16k\n hostPath:\n path: /opt/gitlab-jemalloc\n type: Directory\n", "extraVolumeMounts":"- name: jemalloc-16k\n mountPath: /opt/gitlab-jemalloc\n readOnly: true\n" }, "webservice":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"}, "extraVolumes":"- name: jemalloc-16k\n hostPath:\n path: /opt/gitlab-jemalloc\n type: Directory\n", "extraVolumeMounts":"- name: jemalloc-16k\n mountPath: /opt/gitlab-jemalloc\n readOnly: true\n" }, "gitaly":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"}, "extraVolumes":"- name: jemalloc-16k\n hostPath:\n path: /opt/gitlab-jemalloc\n type: Directory\n", "extraVolumeMounts":"- name: jemalloc-16k\n mountPath: /opt/gitlab-jemalloc\n readOnly: true\n" }, "toolbox":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"}, "extraVolumes":"- name: jemalloc-16k\n hostPath:\n path: /opt/gitlab-jemalloc\n type: Directory\n", "extraVolumeMounts":"- name: jemalloc-16k\n mountPath: /opt/gitlab-jemalloc\n readOnly: true\n" } }, "registry":{ "extraEnv":{"LD_PRELOAD":"/opt/gitlab-jemalloc/libjemalloc.so.2"}, "extraVolumes":"- name: jemalloc-16k\n hostPath:\n path: /opt/gitlab-jemalloc\n type: Directory\n", "extraVolumeMounts":"- name: jemalloc-16k\n mountPath: /opt/gitlab-jemalloc\n readOnly: true\n" } }}}}' echo "==> Patch applied. Waiting 60s for operator to reconcile..." sleep 60 echo "==> Pod status:" kubectl -n gitlab get pods --sort-by=.metadata.creationTimestamp | grep -v jemalloc-builder | grep -v arch-check echo "==> GitLab CR status:" kubectl -n gitlab get gitlab gitlab