mirror of
https://codeberg.org/27/inception-of-things.git
synced 2025-12-31 21:56:41 +01:00
🔨 chore(bonus): cleanup script for v
Signed-off-by: dyn <oss+dyn@xtrm.me>
This commit is contained in:
@ -7,6 +7,7 @@ fi
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
### === Initial K3D Setup ===
|
||||||
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
|
||||||
@ -16,6 +17,7 @@ kubectl patch deployment metrics-server -n kube-system --type='json' \
|
|||||||
echo '> metrics-server is starting (this takes around ~3 minutes)...'
|
echo '> metrics-server is starting (this takes around ~3 minutes)...'
|
||||||
kubectl wait --for=condition=available deployment/metrics-server -n kube-system --timeout=500s
|
kubectl wait --for=condition=available deployment/metrics-server -n kube-system --timeout=500s
|
||||||
|
|
||||||
|
### === ArgoCD ===
|
||||||
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
|
||||||
|
|
||||||
@ -41,23 +43,26 @@ while true; do
|
|||||||
sleep 30
|
sleep 30
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#TODO: The app will be imported via Gitlab, don't import it here
|
||||||
|
# so we don't have 2 of the same deployment.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
|
### === Gitlab ===
|
||||||
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
|
kubectl create namespace gitlab
|
||||||
helm repo add gitlab https://charts.gitlab.io/
|
helm repo add gitlab https://charts.gitlab.io/
|
||||||
helm repo update
|
helm repo update
|
||||||
@ -75,46 +80,43 @@ helm upgrade --install gitlab gitlab/gitlab \
|
|||||||
echo '>'
|
echo '>'
|
||||||
echo '> GitLab is starting (this takes around ~10 minutes)...'
|
echo '> GitLab is starting (this takes around ~10 minutes)...'
|
||||||
echo '>'
|
echo '>'
|
||||||
sleep 10
|
echo '> To watch the pods status, run:'
|
||||||
echo '> Starting watch...'
|
echo '> kubectl get pods -n gitlab -w'
|
||||||
|
echo '>'
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# So we have a progress-ish indicator visual
|
kubectl wait --namespace gitlab \
|
||||||
while true; do
|
--for=condition=available \
|
||||||
ready=$(kubectl get pods -n gitlab --no-headers 2>/dev/null | grep -E "([0-9]+)/\1" | wc -l)
|
--timeout=1200s \
|
||||||
total=$(kubectl get pods -n gitlab --no-headers 2>/dev/null | wc -l)
|
deployment/gitlab-webservice-default
|
||||||
|
|
||||||
clear
|
echo 'GitLab is ready!'
|
||||||
kubectl get pods -n gitlab
|
echo
|
||||||
|
echo '> To setup port-forwarding, run:'
|
||||||
if [ "$ready" -eq "$total" ] && [ "$total" -gt 0 ]; then
|
echo '> kubectl port-forward -n gitlab svc/gitlab-webservice-default 8081:8181'
|
||||||
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 &
|
|
||||||
|
### === Setup /etc/hosts ===
|
||||||
|
function add_host() {
|
||||||
|
local ip=$1
|
||||||
|
local domain=$2
|
||||||
|
local service=$3
|
||||||
|
|
||||||
|
# If it's already there, remove it
|
||||||
|
if grep -q $domain /etc/hosts; then
|
||||||
|
sudo sed -i "/$domain/d" /etc/hosts
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add it
|
||||||
|
echo "$ip $domain" | sudo tee -a "/etc/hosts"
|
||||||
|
echo "$service is now reachable at $domain"
|
||||||
|
}
|
||||||
|
|
||||||
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}')
|
||||||
|
add_host "$TRAEFIK_IP" "argo-app.com" "ArgoCD"
|
||||||
|
add_host "$TRAEFIK_IP" "gitlab-app.com" "Gitlab"
|
||||||
|
|
||||||
echo Traefik ip is: $TRAEFIK_IP
|
### === Login ===
|
||||||
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 "=== Login into ArgoCD with: ==="
|
||||||
echo Username: admin
|
echo Username: admin
|
||||||
echo -n "Password: "
|
echo -n "Password: "
|
||||||
|
|||||||
Reference in New Issue
Block a user