prole/tmp/fix_gitaly_v2.sh

40 lines
1.7 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
export KUBECONFIG=/Users/chrisfu/dev/knoe/knoe-k3s.kubeconfig
echo "==> PV status:"
kubectl get pv gitlab-gitaly-synology \
-o custom-columns='NAME:.metadata.name,STATUS:.status.phase,CLAIM:.spec.claimRef.name,NS:.spec.claimRef.namespace,SC:.spec.storageClassName'
echo "==> PVC describe (binding error):"
kubectl -n gitea describe pvc repo-data-gitlab-gitaly-0 2>&1 | tail -15
echo "==> If PV is Released, patch status to Available..."
PHASE=$(kubectl get pv gitlab-gitaly-synology -o jsonpath='{.status.phase}')
echo "PV phase: $PHASE"
if [[ "$PHASE" == "Released" ]]; then
echo "Patching PV to Available via status subresource..."
kubectl patch pv gitlab-gitaly-synology --type=json \
-p '[{"op":"remove","path":"/spec/claimRef"}]' 2>/dev/null || true
fi
echo "==> Creating minio buckets directly via minio pod exec..."
AK=$(kubectl -n gitea get secret gitlab-minio-secret -o jsonpath='{.data.accesskey}' | base64 -d)
SK=$(kubectl -n gitea get secret gitlab-minio-secret -o jsonpath='{.data.secretkey}' | base64 -d)
MINIO_POD=$(kubectl -n gitea get pod -l app=minio --no-headers -o name | head -1)
echo "Using minio pod: $MINIO_POD"
kubectl -n gitea exec "$MINIO_POD" -- sh -c "
export MC_HOST_gl=http://${AK}:${SK}@localhost:9000
for bucket in gitlab-registry-storage gitlab-lfs-storage gitlab-artifacts-storage \
gitlab-uploads-storage gitlab-packages-storage gitlab-dependency-proxy-storage \
gitlab-terraform-state gitlab-ci-secure-files; do
mc mb --ignore-existing gl/\$bucket && echo \"Created: \$bucket\" || true
done
mc ls gl
" 2>&1
echo "==> Waiting 30s then final pod status:"
sleep 30
kubectl -n gitea get pods --no-headers | grep -v jemalloc-builder | sort