Add registry service initialization and cleanup logic

- Integrate `init_registry.sh` into service-layer initialization and cleanup flows.
- Update dependency order: Registry initializes first to support downstream services.
- Refactor cleanup sequence: Registry stops last in reverse dependency order.
- Enhance action mapping for registry lifecycle operations.
This commit is contained in:
chrisfu 2026-03-22 23:32:34 -07:00
parent ad812cc504
commit d1e2a8273d
2 changed files with 48 additions and 12 deletions

View File

@ -173,7 +173,7 @@ deploy_service_layer() {
ensure_namespace "$ns"
label_namespace "$ns"
local argocd_action opentofu_action garage_action kdc_action openbao_action kong_action
local argocd_action opentofu_action garage_action kdc_action openbao_action kong_action registry_action
case "$action" in
start|initialize|update|reload) argocd_action="update" ;;
restart) argocd_action="restart" ;;
@ -214,6 +214,14 @@ deploy_service_layer() {
*) kong_action="update" ;;
esac
case "$action" in
start|initialize|update|reload) registry_action="update" ;;
restart) registry_action="restart" ;;
stop) registry_action="stop" ;;
status) registry_action="status" ;;
*) registry_action="update" ;;
esac
case "$action" in
stop) kdc_action="cleanup" ;;
status) kdc_action="status" ;;
@ -227,12 +235,18 @@ deploy_service_layer() {
# -------------------------------------------------------------------------
# Deploy services in dependency order:
# 1. OpenBao secrets vault; needed by downstream services
# 2. Garage object storage
# 3. Kong API gateway
# 4. OpenTofu IaC engine; depends on registry + secrets (last)
# 1. Registry no dependencies; other services pull images from it
# 2. OpenBao secrets vault; needed by downstream services
# 3. Garage object storage
# 4. Kong API gateway
# 5. OpenTofu IaC engine; depends on registry + secrets (last)
# -------------------------------------------------------------------------
if [[ -x "$SCRIPT_DIR/init_registry.sh" ]]; then
REGISTRY_NAMESPACE="$REGISTRY_NS" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_registry.sh" -n "$REGISTRY_NS" "$registry_action" || rc=$?
fi
OPENBAO_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_openbao.sh" -n "$ns" "$openbao_action" || rc=$?
@ -268,7 +282,7 @@ cleanup_old_namespace() {
ARGOCD_NAMESPACE="$ARGOCD_NS" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_argocd.sh" -n "$ARGOCD_NS" stop || true
fi
# Cleanup in reverse dependency order (OpenTofu first, then downstream deps)
# Cleanup in reverse dependency order (OpenTofu first, Registry last)
OPENTOFU_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_opentofu.sh" -n "$ns" stop || true
KONG_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
@ -279,6 +293,10 @@ cleanup_old_namespace() {
"$SCRIPT_DIR/init_openbao.sh" -n "$ns" stop || true
CERTMGR_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_certmgr.sh" -n "$ns" stop || true
if [[ -x "$SCRIPT_DIR/init_registry.sh" ]]; then
REGISTRY_NAMESPACE="$REGISTRY_NS" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_registry.sh" -n "$REGISTRY_NS" stop || true
fi
if [[ "$ENABLE_KERBEROS" == "1" && "${PROLE_KDC_STANDALONE:-0}" == "1" ]]; then
SERVICE_NAMESPACE="$ns" PROLE_KDC_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_kdc.sh" cleanup || true

View File

@ -173,7 +173,7 @@ deploy_service_layer() {
ensure_namespace "$ns"
label_namespace "$ns"
local argocd_action opentofu_action garage_action kdc_action openbao_action kong_action
local argocd_action opentofu_action garage_action kdc_action openbao_action kong_action registry_action
case "$action" in
start|initialize|update|reload) argocd_action="update" ;;
restart) argocd_action="restart" ;;
@ -214,6 +214,14 @@ deploy_service_layer() {
*) kong_action="update" ;;
esac
case "$action" in
start|initialize|update|reload) registry_action="update" ;;
restart) registry_action="restart" ;;
stop) registry_action="stop" ;;
status) registry_action="status" ;;
*) registry_action="update" ;;
esac
case "$action" in
stop) kdc_action="cleanup" ;;
status) kdc_action="status" ;;
@ -227,12 +235,18 @@ deploy_service_layer() {
# -------------------------------------------------------------------------
# Deploy services in dependency order:
# 1. OpenBao secrets vault; needed by downstream services
# 2. Garage object storage
# 3. Kong API gateway
# 4. OpenTofu IaC engine; depends on registry + secrets (last)
# 1. Registry no dependencies; other services pull images from it
# 2. OpenBao secrets vault; needed by downstream services
# 3. Garage object storage
# 4. Kong API gateway
# 5. OpenTofu IaC engine; depends on registry + secrets (last)
# -------------------------------------------------------------------------
if [[ -x "$SCRIPT_DIR/init_registry.sh" ]]; then
REGISTRY_NAMESPACE="$REGISTRY_NS" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_registry.sh" -n "$REGISTRY_NS" "$registry_action" || rc=$?
fi
OPENBAO_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_openbao.sh" -n "$ns" "$openbao_action" || rc=$?
@ -263,7 +277,7 @@ cleanup_old_namespace() {
ARGOCD_NAMESPACE="$ARGOCD_NS" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_argocd.sh" -n "$ARGOCD_NS" stop || true
fi
# Cleanup in reverse dependency order (OpenTofu first, then downstream deps)
# Cleanup in reverse dependency order (OpenTofu first, Registry last)
OPENTOFU_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_opentofu.sh" -n "$ns" stop || true
KONG_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
@ -274,6 +288,10 @@ cleanup_old_namespace() {
"$SCRIPT_DIR/init_openbao.sh" -n "$ns" stop || true
CERTMGR_NAMESPACE="$ns" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_certmgr.sh" -n "$ns" stop || true
if [[ -x "$SCRIPT_DIR/init_registry.sh" ]]; then
REGISTRY_NAMESPACE="$REGISTRY_NS" SERVICE_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_registry.sh" -n "$REGISTRY_NS" stop || true
fi
if [[ "$ENABLE_KERBEROS" == "1" ]]; then
SERVICE_NAMESPACE="$ns" PROLE_KDC_NAMESPACE="$ns" \
"$SCRIPT_DIR/init_kdc.sh" cleanup || true