Skip to content

Commit 2ba3660

Browse files
committed
Enhance service endpoint printing and monitoring deployment workflow
- Updated endpoint printing to include detailed information for ArgoCD, application, and monitoring services. - Added troubleshooting tips and cost impact analysis for LoadBalancer services. - Improved monitoring deployment workflow by ensuring NGINX Ingress Controller installation and configuration.
1 parent 4c277e1 commit 2ba3660

File tree

2 files changed

+101
-36
lines changed

2 files changed

+101
-36
lines changed

.github/workflows/endpoints.yml

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,46 +49,65 @@ jobs:
4949
run: |
5050
echo "================= SERVICE ENDPOINTS ================="
5151
52-
# Get ArgoCD endpoint (still using LoadBalancer)
52+
# Get 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')
54-
55-
MONITORING_HOST=$(kubectl get ingress monitoring-ingress -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.spec.rules[0].host}' 2>/dev/null || echo 'Not found')
54+
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')
5655
57-
# Alternative: get ingress from kube-prometheus-stack if using helm ingress
58-
if [ "$MONITORING_HOST" = "Not found" ]; then
59-
MONITORING_HOST=$(kubectl get ingress -n ${{ inputs.monitoring_namespace }} -l app.kubernetes.io/name=kube-prometheus-stack -o jsonpath='{.items[0].spec.rules[0].host}' 2>/dev/null || echo 'Not found')
60-
fi
56+
# Get monitoring ingress information
57+
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)
6160
62-
# Get app endpoint
63-
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')
61+
# Get NGINX ingress controller LoadBalancer
62+
NGINX_LB=$(kubectl get svc -n ingress-nginx ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
6463
6564
# Print endpoints
66-
echo "ArgoCD: http://$ARGOCD_HOST"
67-
68-
if [ "$MONITORING_HOST" != "Not found" ]; then
69-
echo "Prometheus: http://$MONITORING_HOST/prometheus"
70-
echo "Grafana: http://$MONITORING_HOST/grafana"
71-
echo "Alertmanager: http://$MONITORING_HOST/alertmanager"
65+
echo "🚀 ArgoCD: http://$ARGOCD_HOST"
66+
echo "🌟 App: http://$APP_HOST"
67+
echo ""
68+
echo "📊 Monitoring Services (via Ingress):"
69+
if [ "$MONITORING_DOMAIN" != "Not found" ]; then
70+
echo " Domain: $MONITORING_DOMAIN"
71+
echo " 📊 Prometheus: http://$MONITORING_DOMAIN/prometheus"
72+
echo " 📈 Grafana: http://$MONITORING_DOMAIN/grafana"
73+
echo " 🚨 Alertmanager: http://$MONITORING_DOMAIN/alertmanager"
74+
echo ""
75+
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
7282
else
73-
echo "Monitoring services: Not found (check ingress configuration)"
83+
echo " ⚠️ Ingress not found or not ready"
7484
fi
75-
76-
echo "App: http://$APP_HOST"
85+
echo ""
86+
echo "🌐 NGINX Ingress Controller: $NGINX_LB"
7787
7888
echo ""
79-
echo "================= INGRESS STATUS ================="
89+
echo "================= DETAILED INGRESS STATUS ================="
90+
echo "All Ingress Resources:"
91+
kubectl get ingress -A -o wide 2>/dev/null || echo "No ingress resources found"
92+
echo ""
93+
echo "Monitoring Namespace Ingress Details:"
94+
kubectl describe ingress -n ${{ inputs.monitoring_namespace }} 2>/dev/null || echo "No ingress in monitoring namespace"
8095
81-
# Show ingress details for debugging
82-
echo "Monitoring Ingress Status:"
83-
kubectl get ingress -n ${{ inputs.monitoring_namespace }} -o wide 2>/dev/null || echo "No ingress found in monitoring namespace"
96+
echo ""
97+
echo "================= SERVICE STATUS ================="
98+
echo "Monitoring Services (should be ClusterIP):"
99+
kubectl get svc -n ${{ inputs.monitoring_namespace }} -l app.kubernetes.io/instance=kube-prometheus-stack
84100
85101
echo ""
86-
echo "Load Balancer Services:"
102+
echo "All LoadBalancer Services:"
87103
kubectl get svc -A --field-selector spec.type=LoadBalancer -o wide
88104
89105
echo ""
90-
echo "================= DEFAULT CREDENTIALS ================="
106+
echo "NGINX Ingress Controller Status:"
107+
kubectl get svc -n ingress-nginx -o wide 2>/dev/null || echo "NGINX Ingress Controller not found"
91108
109+
echo ""
110+
echo "================= DEFAULT CREDENTIALS ================="
92111
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')
93112
echo "ArgoCD -> Username: admin"
94113
echo "ArgoCD -> Password: $ARGOCD_PASS"
@@ -97,7 +116,24 @@ jobs:
97116
echo "Prometheus -> No login needed (anonymous access by default)"
98117
99118
echo ""
100-
echo "================= CONFIGURATION NOTES ================="
101-
echo "• Monitoring services are accessed through a single ingress endpoint"
102-
echo "• Make sure your DNS points to the ingress controller's LoadBalancer"
103-
echo "• If monitoring host shows 'Not found', check ingress controller deployment"
119+
echo "================= TROUBLESHOOTING TIPS ================="
120+
LB_COUNT=$(kubectl get svc -A --field-selector spec.type=LoadBalancer --no-headers 2>/dev/null | wc -l)
121+
INGRESS_COUNT=$(kubectl get ingress -A --no-headers 2>/dev/null | wc -l)
122+
123+
echo "📊 Current LoadBalancers: $LB_COUNT"
124+
echo "📊 Current Ingress Resources: $INGRESS_COUNT"
125+
echo ""
126+
echo "🔍 If monitoring services aren't accessible:"
127+
echo " 1. Check if NGINX Ingress Controller is installed"
128+
echo " 2. Verify domain 'monitoring.yourdomain.com' points to NGINX LB"
129+
echo " 3. Check ingress resource was created successfully"
130+
echo " 4. Ensure kube-prometheus-stack synced without errors in ArgoCD"
131+
echo ""
132+
echo "💰 Cost Impact:"
133+
echo " • Target: 2 LoadBalancers (ArgoCD + NGINX Ingress)"
134+
echo " • Current: $LB_COUNT LoadBalancers"
135+
if [ "$LB_COUNT" -gt 2 ]; then
136+
EXCESS=$((LB_COUNT - 2))
137+
COST=$((EXCESS * 16))
138+
echo " • Potential monthly savings: ~\$COST (reducing $EXCESS extra LoadBalancers)"
139+
fi

.github/workflows/monitoring.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,61 @@ jobs:
3434
name: Deploy Monitoring Stack
3535
runs-on: ubuntu-latest
3636
environment: production
37-
3837
steps:
3938
- name: Checkout Repository
4039
uses: actions/checkout@v5
41-
40+
4241
- name: Configure AWS credentials via OIDC
4342
uses: aws-actions/configure-aws-credentials@v4
4443
with:
4544
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GitHubActionsInfraRole
4645
aws-region: us-east-1
47-
48-
46+
4947
- name: Update kubeconfig
5048
run: aws eks update-kubeconfig --name ${{ inputs.cluster_name }} --region us-east-1
51-
49+
50+
- name: Install Helm
51+
uses: azure/setup-helm@v4
52+
with:
53+
version: '3.12.0'
54+
55+
- name: Add Helm Repositories
56+
run: |
57+
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
58+
helm repo update
59+
60+
- name: Install NGINX Ingress Controller with Helm
61+
run: |
62+
if ! helm list -n ingress-nginx | grep -q ingress-nginx; then
63+
kubectl create namespace ingress-nginx --dry-run=client -o yaml | kubectl apply -f -
64+
helm install ingress-nginx ingress-nginx/ingress-nginx \
65+
--namespace ingress-nginx \
66+
--set controller.service.type=LoadBalancer \
67+
--set controller.service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-type"=nlb \
68+
--set controller.service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-cross-zone-load-balancing-enabled"=true \
69+
--set controller.config.use-forwarded-headers=true \
70+
--set controller.metrics.enabled=true \
71+
--wait --timeout=10m
72+
fi
73+
74+
- name: Get NGINX LoadBalancer Hostname
75+
id: nginx-lb
76+
run: |
77+
NGINX_HOSTNAME=$(kubectl get svc -n ingress-nginx ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
78+
echo "nginx_hostname=$NGINX_HOSTNAME" >> $GITHUB_OUTPUT
79+
5280
- name: Create Grafana Secret
5381
run: |
5482
kubectl create namespace ${{ inputs.monitoring_namespace }} --dry-run=client -o yaml | kubectl apply -f -
5583
kubectl create secret generic grafana-admin-secret \
56-
--from-literal=admin-user=admin \
5784
--from-literal=admin-password='${{ secrets.GRAFANA_ADMIN_PASSWORD }}' \
5885
--namespace ${{ inputs.monitoring_namespace }} \
5986
--dry-run=client -o yaml | kubectl apply -f -
60-
87+
6188
- name: Deploy Monitoring
6289
run: |
6390
export MONITORING_NAMESPACE=${{ inputs.monitoring_namespace }}
6491
export ARGOCD_NAMESPACE=${{ inputs.argocd_namespace }}
65-
envsubst < ./argocd/monitoring.yml | kubectl apply -f -
92+
envsubst < ./argocd/monitoring.yml | \
93+
sed "s/monitoring\.yourdomain\.com/${{ steps.nginx-lb.outputs.nginx_hostname }}/g" | \
94+
kubectl apply -f -

0 commit comments

Comments
 (0)