🚧 wip(bonus): try and cleanup setup script

Signed-off-by: dyn <oss+dyn@xtrm.me>
This commit is contained in:
dyn
2025-12-17 23:02:56 +01:00
parent e7dd4513db
commit 8c65674d35
2 changed files with 39 additions and 22 deletions

View File

@ -3,47 +3,64 @@
k3d cluster create inception-of-things k3d cluster create inception-of-things
# Setup a metrics-server to prevent dumb errors # Setup a metrics-server to prevent dumb errors
# kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml 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' \ kubectl patch deployment metrics-server -n kube-system --type='json' \
# -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-insecure-tls"}]' -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 create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
echo ">" echo "> ArgoCD is starting (this takes around ~6 minutes)..."
echo "> ArgoCD is starting (this takes around ~4 minutes)..." sleep 10
echo ">" echo '> Starting watch...'
sleep 5
kubectl wait --namespace argocd \ # So we have a progress-ish indicator visual
--for=condition=ready pod \ while true; do
--selector=app.kubernetes.io/name=argocd-server \ ready=$(kubectl get pods -n argocd --no-headers 2>/dev/null | grep -E "([0-9]+)/\1" | wc -l)
--timeout=600s total=$(kubectl get pods -n argocd --no-headers 2>/dev/null | wc -l)
kubectl port-forward svc/argocd-server -n argocd 8080:443 1>/dev/null 2>/dev/null & clear
echo 'ArgoCD is running' 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_PATH="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")" SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
kubectl create namespace dev kubectl create namespace dev
kubectl apply -n argocd -f "$SCRIPT_DIR/../confs/argocd-app.yml"
echo '>' echo '>'
echo '> App is starting (this takes around ~30 seconds)...' echo '> App is starting (this takes around ~30 seconds)...'
echo '>' echo '>'
kubectl apply -n argocd -f "$SCRIPT_DIR/../confs/argocd-app.yml" kubectl wait --namespace dev \
--for=condition=ready pod \
--selector=app=app-p3 \
--timeout=300s
echo 'App imported in ArgoCD' echo 'App imported in ArgoCD'
sleep 2
kubectl create namespace gitlab kubectl create namespace gitlab
echo '>' echo '>'
echo '> Gitlab is starting (this takes around ~10 minutes)...' echo '> GitLab is starting (this takes around ~10 minutes)...'
echo '>' echo '>'
helm repo add gitlab https://charts.gitlab.io/ > /dev/null 2>&1 helm repo add gitlab https://charts.gitlab.io/
help repo update > /dev/null 2>&1 help repo update
helm upgrade --install gitlab gitlab/gitlab \ helm upgrade --install gitlab gitlab/gitlab \
--namespace gitlab \ --namespace gitlab \
--timeout 600s \ --timeout 1200s \
--set global.hosts.domain=gitlab-app.com \ --set global.hosts.domain=gitlab-app.com \
--set global.ingress.enabled=true \ --set global.ingress.enabled=true \
--set global.ingress.className=traefik \ --set global.ingress.className=traefik \
@ -56,14 +73,14 @@ helm upgrade --install gitlab gitlab/gitlab \
kubectl wait --namespace gitlab \ kubectl wait --namespace gitlab \
--for=condition=available \ --for=condition=available \
--timeout=600s \ --timeout=1200s \
deployment/gitlab-webservice-default deployment/gitlab-webservice-default
kubectl port-forward -n gitlab svc/gitlab-webservice-default 8081:8181 1>/dev/null 2>/dev/null & # 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}') TRAEFIK_IP=$(kubectl get service -n kube-system traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo Traefik ip is : $TRAEFIK_IP echo Traefik ip is: $TRAEFIK_IP
if grep -q argo-app.com /etc/hosts; then if grep -q argo-app.com /etc/hosts; then
sudo sed -i "/argo-app.com/d" /etc/hosts sudo sed -i "/argo-app.com/d" /etc/hosts
fi fi
@ -72,7 +89,7 @@ echo App is now reachable at argo-app.com
echo echo
if grep -q gitlab-app.com /etc/hosts; then if grep -q gitlab-app.com /etc/hosts; then
sudo sed -i "/argo-app.com/d" /etc/hosts sudo sed -i "/gitlab-app.com/d" /etc/hosts
fi fi
echo "$TRAEFIK_IP gitlab-app.com" | sudo tee -a "/etc/hosts" echo "$TRAEFIK_IP gitlab-app.com" | sudo tee -a "/etc/hosts"
echo Gitlab is now reachable at gitlab-app.com echo Gitlab is now reachable at gitlab-app.com

View File

@ -47,7 +47,7 @@ kubectl wait --namespace dev \
--selector=app=app-p3 \ --selector=app=app-p3 \
--timeout=300s --timeout=300s
echo 'App imported in ArgoCD' echo 'App imported in ArgoCD'
sleep 10 sleep 2
TRAEFIK_IP=$(kubectl get service -n kube-system traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}') TRAEFIK_IP=$(kubectl get service -n kube-system traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo Traefik IP is: $TRAEFIK_IP echo Traefik IP is: $TRAEFIK_IP