Skip to content

Commit 23650ac

Browse files
committed
Refactor endpoint printing script for clarity and error handling improvements
1 parent 2ba3660 commit 23650ac

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

.github/workflows/endpoints.yml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ jobs:
4848
- name: Print Service Endpoints
4949
run: |
5050
echo "================= SERVICE ENDPOINTS ================="
51-
52-
# Get ArgoCD and App LoadBalancer services
51+
52+
# ArgoCD and App LoadBalancer services
5353
ARGOCD_HOST=$(kubectl get svc argocd-server -n ${{ inputs.argocd_namespace }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
5454
APP_HOST=$(kubectl get svc ${{ inputs.app_name }}-svc -n ${{ inputs.app_namespace }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
55-
56-
# Get monitoring ingress information
55+
56+
# Monitoring ingress information
5757
MONITORING_DOMAIN=$(kubectl get ingress -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.items[0].spec.rules[0].host}' 2>/dev/null || echo 'Not found')
58-
INGRESS_IP=$(kubectl get ingress -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}' 2>/dev/null)
59-
INGRESS_HOSTNAME=$(kubectl get ingress -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.items[0].status.loadBalancer.ingress[0].hostname}' 2>/dev/null)
60-
61-
# Get NGINX ingress controller LoadBalancer
58+
INGRESS_IP=$(kubectl get ingress -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}' 2>/dev/null || echo '')
59+
INGRESS_HOSTNAME=$(kubectl get ingress -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.items[0].status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo '')
60+
61+
# NGINX ingress controller LoadBalancer
6262
NGINX_LB=$(kubectl get svc -n ingress-nginx ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
63-
63+
6464
# Print endpoints
6565
echo "🚀 ArgoCD: http://$ARGOCD_HOST"
6666
echo "🌟 App: http://$APP_HOST"
@@ -69,43 +69,40 @@ jobs:
6969
if [ "$MONITORING_DOMAIN" != "Not found" ]; then
7070
echo " Domain: $MONITORING_DOMAIN"
7171
echo " 📊 Prometheus: http://$MONITORING_DOMAIN/prometheus"
72-
echo " 📈 Grafana: http://$MONITORING_DOMAIN/grafana"
72+
echo " 📈 Grafana: http://$MONITORING_DOMAIN/grafana"
7373
echo " 🚨 Alertmanager: http://$MONITORING_DOMAIN/alertmanager"
7474
echo ""
7575
echo " Ingress Status:"
76-
if [ ! -z "$INGRESS_IP" ]; then
77-
echo " IP: $INGRESS_IP"
78-
fi
79-
if [ ! -z "$INGRESS_HOSTNAME" ]; then
80-
echo " LoadBalancer: $INGRESS_HOSTNAME"
81-
fi
76+
[ ! -z "$INGRESS_IP" ] && echo " IP: $INGRESS_IP"
77+
[ ! -z "$INGRESS_HOSTNAME" ] && echo " LoadBalancer: $INGRESS_HOSTNAME"
8278
else
8379
echo " ⚠️ Ingress not found or not ready"
8480
fi
81+
8582
echo ""
8683
echo "🌐 NGINX Ingress Controller: $NGINX_LB"
87-
84+
8885
echo ""
8986
echo "================= DETAILED INGRESS STATUS ================="
9087
echo "All Ingress Resources:"
9188
kubectl get ingress -A -o wide 2>/dev/null || echo "No ingress resources found"
9289
echo ""
9390
echo "Monitoring Namespace Ingress Details:"
9491
kubectl describe ingress -n ${{ inputs.monitoring_namespace }} 2>/dev/null || echo "No ingress in monitoring namespace"
95-
92+
9693
echo ""
9794
echo "================= SERVICE STATUS ================="
9895
echo "Monitoring Services (should be ClusterIP):"
99-
kubectl get svc -n ${{ inputs.monitoring_namespace }} -l app.kubernetes.io/instance=kube-prometheus-stack
100-
96+
kubectl get svc -n ${{ inputs.monitoring_namespace }} -l app.kubernetes.io/instance=kube-prometheus-stack 2>/dev/null || echo "No monitoring services found"
97+
10198
echo ""
10299
echo "All LoadBalancer Services:"
103-
kubectl get svc -A --field-selector spec.type=LoadBalancer -o wide
104-
100+
kubectl get svc -A --field-selector spec.type=LoadBalancer -o wide 2>/dev/null || echo "No LoadBalancer services found"
101+
105102
echo ""
106103
echo "NGINX Ingress Controller Status:"
107104
kubectl get svc -n ingress-nginx -o wide 2>/dev/null || echo "NGINX Ingress Controller not found"
108-
105+
109106
echo ""
110107
echo "================= DEFAULT CREDENTIALS ================="
111108
ARGOCD_PASS=$(kubectl -n ${{ inputs.argocd_namespace }} get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' 2>/dev/null | base64 -d || echo 'Not found')
@@ -114,12 +111,12 @@ jobs:
114111
echo "Grafana -> Username: admin"
115112
echo "Grafana -> Password: ${{ secrets.GRAFANA_PASSWORD }}"
116113
echo "Prometheus -> No login needed (anonymous access by default)"
117-
114+
118115
echo ""
119116
echo "================= TROUBLESHOOTING TIPS ================="
120117
LB_COUNT=$(kubectl get svc -A --field-selector spec.type=LoadBalancer --no-headers 2>/dev/null | wc -l)
121118
INGRESS_COUNT=$(kubectl get ingress -A --no-headers 2>/dev/null | wc -l)
122-
119+
123120
echo "📊 Current LoadBalancers: $LB_COUNT"
124121
echo "📊 Current Ingress Resources: $INGRESS_COUNT"
125122
echo ""
@@ -136,4 +133,5 @@ jobs:
136133
EXCESS=$((LB_COUNT - 2))
137134
COST=$((EXCESS * 16))
138135
echo " • Potential monthly savings: ~\$COST (reducing $EXCESS extra LoadBalancers)"
139-
fi
136+
fi
137+
shell: /usr/bin/bash

0 commit comments

Comments
 (0)