mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 12:03:59 +00:00
32 lines
1.9 KiB
Bash
32 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export KUBECONFIG=/Users/chrisfu/dev/knoe/knoe-k3s.kubeconfig
|
|
|
|
MINIO_POD=$(kubectl -n gitlab get pod -l app=minio --no-headers -o name | head -1)
|
|
echo "==> Minio pod: $MINIO_POD"
|
|
|
|
AK=$(kubectl -n gitlab exec "$MINIO_POD" -- \
|
|
sh -c "python3 -c \"import json; d=json.load(open('/tmp/.minio/config.json.old')); print(d['credential']['accessKey'],end='')\"" 2>/dev/null)
|
|
SK=$(kubectl -n gitlab exec "$MINIO_POD" -- \
|
|
sh -c "python3 -c \"import json; d=json.load(open('/tmp/.minio/config.json.old')); print(d['credential']['secretKey'],end='')\"" 2>/dev/null)
|
|
echo "==> AK=${AK:0:8}... (len=${#AK}) SK=${SK:0:8}... (len=${#SK})"
|
|
|
|
kubectl -n gitlab delete pod minio-init --ignore-not-found 2>/dev/null || true
|
|
|
|
cat > /tmp/mc-cmd.sh << SCRIPT
|
|
#!/bin/sh
|
|
mc alias set gl http://gitlab-minio-svc.gitlab.svc.cluster.local:9000 '${AK}' '${SK}' && \
|
|
for b in registry 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/\$b" && echo "OK:\$b"
|
|
done && mc ls gl && echo BUCKETS_DONE
|
|
SCRIPT
|
|
chmod +x /tmp/mc-cmd.sh
|
|
|
|
kubectl -n gitlab run minio-init \
|
|
--image=minio/mc:latest \
|
|
--restart=Never \
|
|
--overrides="{\"spec\":{\"nodeName\":\"gandalf.knoe.org\",\"tolerations\":[{\"operator\":\"Exists\"}],\"containers\":[{\"name\":\"minio-init\",\"image\":\"minio/mc:latest\",\"command\":[\"sh\",\"-c\",\"mc alias set gl http://gitlab-minio-svc.gitlab.svc.cluster.local:9000 ${AK} ${SK} && for b in registry 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/\\\$b && echo OK:\\\$b; done && mc ls gl && echo BUCKETS_DONE\"]}]}}"
|
|
echo "==> minio-init started — check with: kubectl -n gitlab logs minio-init"
|