mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 20:04:31 +00:00
chore: scale down over-replicated GitLab deployments to target replica count of 1
This commit is contained in:
parent
b59a53f491
commit
27d8a723f0
@ -2604,6 +2604,45 @@ if [[ "${GITLAB_NO_WAIT:-0}" != "1" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Requirement: Explicitly scale down over-replicated GitLab deployments
|
||||||
|
# Some components may remain at 2 replicas even after CR is Available.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
log "Verifying GitLab deployment replica counts (desired=1)..."
|
||||||
|
_over_replicated_found=0
|
||||||
|
# Explicit list of components to verify and scale if needed (Requirement 2)
|
||||||
|
for _dep_suffix in "gitlab-shell" "kas" "registry" "sidekiq-all-in-1-v2"; do
|
||||||
|
_dep_name="${GITLAB_RELEASE}-${_dep_suffix}"
|
||||||
|
|
||||||
|
# Read live spec.replicas (Requirement 2 & 6)
|
||||||
|
_live_replicas=$(kubectl --context "$KUBECTL_CONTEXT" -n "$NAMESPACE" get deployment "$_dep_name" -o jsonpath='{.spec.replicas}' 2>/dev/null || echo "0")
|
||||||
|
|
||||||
|
if [[ -n "$_live_replicas" && "$_live_replicas" -gt 1 ]]; then
|
||||||
|
log "Deployment ${_dep_name} is over-replicated: live=${_live_replicas}, desired=1. Scaling down..."
|
||||||
|
# Explicit scale down (Requirement 3)
|
||||||
|
kubectl --context "$KUBECTL_CONTEXT" -n "$NAMESPACE" scale deployment "$_dep_name" --replicas=1
|
||||||
|
_over_replicated_found=1
|
||||||
|
else
|
||||||
|
log "Deployment ${_dep_name} replica count is correct: live=${_live_replicas:-0}, desired=1"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$_over_replicated_found" == "1" ]]; then
|
||||||
|
log "Waiting for rollout of scaled-down deployments..."
|
||||||
|
for _dep_suffix in "gitlab-shell" "kas" "registry" "sidekiq-all-in-1-v2"; do
|
||||||
|
_dep_name="${GITLAB_RELEASE}-${_dep_suffix}"
|
||||||
|
kubectl --context "$KUBECTL_CONTEXT" -n "$NAMESPACE" rollout status deployment/"$_dep_name" --timeout=300s || true
|
||||||
|
done
|
||||||
|
|
||||||
|
# Final verification (Requirement 4 & 6)
|
||||||
|
log "Final replica count verification (after corrective action):"
|
||||||
|
for _dep_suffix in "gitlab-shell" "kas" "registry" "sidekiq-all-in-1-v2"; do
|
||||||
|
_dep_name="${GITLAB_RELEASE}-${_dep_suffix}"
|
||||||
|
_final_replicas=$(kubectl --context "$KUBECTL_CONTEXT" -n "$NAMESPACE" get deployment "$_dep_name" -o jsonpath='{.spec.replicas}' 2>/dev/null || echo "0")
|
||||||
|
log "Deployment ${_dep_name}: final_live=${_final_replicas}, desired=1"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Public ingress for configured GitLab domain -> gitlab-webservice
|
# Public ingress for configured GitLab domain -> gitlab-webservice
|
||||||
# The GitLab Operator creates the Ingress; this block ensures a stable public
|
# The GitLab Operator creates the Ingress; this block ensures a stable public
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user