Files
inception-of-things/bonus/scripts/argo-install.sh
dyn af6278f414 🔨 chore: fix gitlab + helm
Signed-off-by: dyn <oss+dyn@xtrm.me>
2025-12-18 10:22:04 +01:00

131 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env sh
if [ -z "$KUBECONFIG" ]; then
echo "KUBECONFIG is not set"
exit 1
fi
set -x
k3d cluster create inception-of-things
# Setup a metrics-server to prevent dumb errors
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl patch deployment metrics-server -n kube-system --type='json' \
-p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-insecure-tls"}]'
echo '> metrics-server is starting (this takes around ~3 minutes)...'
kubectl wait --for=condition=available deployment/metrics-server -n kube-system --timeout=500s
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
echo "> ArgoCD is starting (this takes around ~6 minutes)..."
sleep 10
echo '> Starting watch...'
sleep 5
# So we have a progress-ish indicator visual
while true; do
ready=$(kubectl get pods -n argocd --no-headers 2>/dev/null | grep -E "([0-9]+)/\1" | wc -l)
total=$(kubectl get pods -n argocd --no-headers 2>/dev/null | wc -l)
clear
kubectl get pods -n argocd
if [ "$ready" -eq "$total" ] && [ "$total" -gt 0 ]; then
echo "All ArgoCD pods are ready!"
sleep 5
break
fi
sleep 30
done
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
kubectl create namespace dev
kubectl apply -n argocd -f "$SCRIPT_DIR/../confs/argocd-app.yml"
echo '>'
echo '> App is starting (this takes around ~30 seconds)...'
echo '>'
sleep 5 # THIS SLEEP IS REQUIRED, IT BREAKS WITHOUT IT, TRUST -kiroussa
kubectl wait --namespace dev \
--for=condition=ready pod \
--selector=app=app-p3 \
--timeout=300s
echo 'App imported in ArgoCD'
sleep 2
kubectl create namespace gitlab
helm repo add gitlab https://charts.gitlab.io/
helm repo update
# This is the second time a MAJOR SERVICE's prod has gone down while we're the day before the push.
# I hate this world.
helm upgrade --install gitlab gitlab/gitlab \
-f https://gitlab.com/gitlab-org/charts/gitlab/raw/master/examples/values-minikube-minimum.yaml \
--namespace gitlab \
--timeout 1200s \
--set global.hosts.domain=gitlab-app.com \
--set global.hosts.externalIP=0.0.0.0 \
--set global.hosts.https=false \
--disable-openapi-validation
echo '>'
echo '> GitLab is starting (this takes around ~10 minutes)...'
echo '>'
sleep 10
echo '> Starting watch...'
sleep 5
# So we have a progress-ish indicator visual
while true; do
ready=$(kubectl get pods -n gitlab --no-headers 2>/dev/null | grep -E "([0-9]+)/\1" | wc -l)
total=$(kubectl get pods -n gitlab --no-headers 2>/dev/null | wc -l)
clear
kubectl get pods -n gitlab
if [ "$ready" -eq "$total" ] && [ "$total" -gt 0 ]; then
echo "All GitLab pods are ready!"
sleep 5
break
fi
sleep 30
done
# kubectl port-forward -n gitlab svc/gitlab-webservice-default 8081:8181 1>/dev/null 2>/dev/null &
TRAEFIK_IP=$(kubectl get service -n kube-system traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo Traefik ip is: $TRAEFIK_IP
if grep -q argo-app.com /etc/hosts; then
sudo sed -i "/argo-app.com/d" /etc/hosts
fi
echo "$TRAEFIK_IP argo-app.com" | sudo tee -a "/etc/hosts"
echo App is now reachable at argo-app.com
echo
if grep -q gitlab-app.com /etc/hosts; then
sudo sed -i "/gitlab-app.com/d" /etc/hosts
fi
echo "$TRAEFIK_IP gitlab-app.com" | sudo tee -a "/etc/hosts"
echo Gitlab is now reachable at gitlab-app.com
echo
echo "=== Login into ArgoCD with: ==="
echo Username: admin
echo -n "Password: "
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
echo
echo "==============================="
echo
echo "=== Login into Gitlab with: ==="
echo Username: admin
echo -n "Password: "
kubectl -n gitlab get secret gitlab-gitlab-initial-root-password -o jsonpath='{.data.password}' | base64 -d
echo
echo "==============================="