From 77e054cdea67665338a40cc24d1cd04c8ecb6570 Mon Sep 17 00:00:00 2001 From: mik-tf Date: Fri, 7 Nov 2025 22:18:44 -0500 Subject: [PATCH] feat: Add deployment scripts and hard node affinity for nginx-load-balancer example --- examples/nginx-load-balancer/apply-fixes.sh | 159 ++++++++++++++ examples/nginx-load-balancer/clean-deploy.sh | 202 ++++++++++++++++++ .../nginx-load-balancer-deployment.yaml | 12 +- .../nginx-load-balancer-service.yaml | 1 - .../nginx-load-balancer.md | 10 +- examples/nginx-load-balancer/verify-fixes.sh | 159 ++++++++++++++ 6 files changed, 530 insertions(+), 13 deletions(-) create mode 100755 examples/nginx-load-balancer/apply-fixes.sh create mode 100755 examples/nginx-load-balancer/clean-deploy.sh create mode 100755 examples/nginx-load-balancer/verify-fixes.sh diff --git a/examples/nginx-load-balancer/apply-fixes.sh b/examples/nginx-load-balancer/apply-fixes.sh new file mode 100755 index 0000000..ce547f7 --- /dev/null +++ b/examples/nginx-load-balancer/apply-fixes.sh @@ -0,0 +1,159 @@ +#!/bin/bash + +# Apply fixes for nginx-load-balancer +# Implements the configuration changes identified in the analysis + +set -e + +echo "๐Ÿ”ง nginx-load-balancer Fixes Application" +echo "========================================" +echo "" + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +echo "๐Ÿš€ Applying fixes for nginx-load-balancer..." +echo "" + +# Step 1: Apply the updated deployment (hard node affinity) +echo "๐Ÿ” Step 1: Applying updated deployment (hard node affinity)..." +echo " Changes:" +echo " โ€ข Changed from soft preferences to hard requirements" +echo " โ€ข Ensures pods only run on worker nodes (not masters)" +echo "" + +if kubectl apply -f nginx-load-balancer-deployment.yaml; then + echo -e "${GREEN}โœ… Deployment updated successfully${NC}" +else + echo -e "${RED}โŒ Failed to update deployment${NC}" + exit 1 +fi +echo "" + +# Step 2: Apply the updated service (remove externalTrafficPolicy) +echo "๐Ÿ” Step 2: Applying updated service (LoadBalancer configuration)..." +echo " Changes:" +echo " โ€ข Removed externalTrafficPolicy: Local" +echo " โ€ข Fixes LoadBalancer IP accessibility issues" +echo "" + +if kubectl apply -f nginx-load-balancer-service.yaml; then + echo -e "${GREEN}โœ… Service updated successfully${NC}" +else + echo -e "${RED}โŒ Failed to update service${NC}" + exit 1 +fi +echo "" + +# Step 3: Restart deployment to apply changes +echo "๐Ÿ” Step 3: Restarting deployment to apply changes..." +echo " This ensures all pods are recreated with the new configuration" + +if kubectl rollout restart deployment/nginx-load-balancer; then + echo -e "${GREEN}โœ… Deployment restart initiated${NC}" +else + echo -e "${RED}โŒ Failed to restart deployment${NC}" + exit 1 +fi + +echo " Waiting for rollout to complete..." +if kubectl rollout status deployment/nginx-load-balancer --timeout=180s; then + echo -e "${GREEN}โœ… Deployment rollout completed${NC}" +else + echo -e "${YELLOW}โš ๏ธ Deployment rollout timed out (this is normal, pods may still be starting)${NC}" +fi +echo "" + +# Step 4: Wait for pods to be ready +echo "๐Ÿ” Step 4: Waiting for pods to be ready..." +echo " This may take up to 60 seconds due to restart and node affinity changes" + +if kubectl wait --for=condition=ready pod -l app=nginx-load-balancer --timeout=120s; then + echo -e "${GREEN}โœ… All pods are ready${NC}" +else + echo -e "${YELLOW}โš ๏ธ Some pods are still starting (this is normal)${NC}" +fi +echo "" + +# Step 5: Verify the fixes +echo "๐Ÿ” Step 5: Running verification checks..." +echo "" + +# Check pod distribution +echo "๐Ÿ“Š Pod Distribution:" +PODS=$(kubectl get pods -l app=nginx-load-balancer -o wide) +echo "$PODS" +echo "" + +# Count pods on master vs worker nodes +MASTER_PODS=$(echo "$PODS" | grep "master" | wc -l) +WORKER_PODS=$(echo "$PODS" | grep -v "master" | grep -v "NAME" | wc -l) +TOTAL_PODS=$(echo "$PODS" | grep -v "NAME" | wc -l) + +echo "Pod distribution:" +echo " โ€ข Total pods: $TOTAL_PODS" +echo " โ€ข Master pods: $MASTER_PODS" +echo " โ€ข Worker pods: $WORKER_PODS" + +if [ "$MASTER_PODS" -eq 0 ] && [ "$WORKER_PODS" -eq 3 ]; then + echo -e "${GREEN}โœ… EXCELLENT: Pods only on worker nodes (3/3)${NC}" +elif [ "$MASTER_PODS" -eq 0 ]; then + echo -e "${GREEN}โœ… GOOD: No pods on master nodes${NC}" + echo -e "${YELLOW} Note: Expected 3 pods, found $WORKER_PODS${NC}" +else + echo -e "${RED}โŒ ISSUE: Pods found on master nodes (node affinity not working)${NC}" +fi +echo "" + +# Check LoadBalancer service +echo "๐ŸŒ LoadBalancer Service Status:" +SERVICE=$(kubectl get svc nginx-load-balancer-service) +echo "$SERVICE" +echo "" + +SERVICE_IP=$(kubectl get svc nginx-load-balancer-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}') +SERVICE_PORT=$(kubectl get svc nginx-load-balancer-service -o jsonpath='{.spec.ports[0].port}') + +if [ -n "$SERVICE_IP" ]; then + echo -e "${GREEN}โœ… LoadBalancer IP assigned: $SERVICE_IP${NC}" + echo " Service URL: http://$SERVICE_IP:$SERVICE_PORT" +else + echo -e "${YELLOW}โš ๏ธ LoadBalancer IP not yet assigned (may take time)${NC}" +fi +echo "" + +# Final summary +echo "========================================" +echo "๐ŸŽ‰ FIXES APPLIED SUCCESSFULLY!" +echo "========================================" +echo "" + +echo -e "${BLUE}๐Ÿ“‹ Summary of Changes Applied:${NC}" +echo "โ€ข โœ… Hard node affinity (pods on workers only)" +echo "โ€ข โœ… LoadBalancer service configuration (removed externalTrafficPolicy)" +echo "โ€ข โœ… Deployment restarted with new configuration" +echo "" + +echo -e "${BLUE}๐ŸŒ Access Information:${NC}" +if [ -n "$SERVICE_IP" ]; then + echo "โ€ข LoadBalancer URL: http://$SERVICE_IP:$SERVICE_PORT" + echo "โ€ข Direct node access: http://[node-ip]:8080 (on nodes with pods)" + echo "" + echo -e "${BLUE}๐Ÿงช Test both access methods:${NC}" + echo " 1. LoadBalancer IP (load balancing): curl -6 'http://$SERVICE_IP:$SERVICE_PORT'" + echo " 2. Direct node access: kubectl get nodes -o wide" +fi +echo "" + +echo -e "${BLUE}๐Ÿ”ง Next Steps:${NC}" +echo "1. Run verification: ./verify-fixes.sh" +echo "2. Test LoadBalancer: curl -6 'http://$SERVICE_IP:$SERVICE_PORT'" +echo "3. Test node access: Get node IPs with 'kubectl get nodes -o wide'" +echo "4. Monitor pods: kubectl get pods -l app=nginx-load-balancer -o wide" +echo "" + +echo -e "${GREEN}โœ… All fixes applied and verified!${NC}" \ No newline at end of file diff --git a/examples/nginx-load-balancer/clean-deploy.sh b/examples/nginx-load-balancer/clean-deploy.sh new file mode 100755 index 0000000..c22349f --- /dev/null +++ b/examples/nginx-load-balancer/clean-deploy.sh @@ -0,0 +1,202 @@ +#!/bin/bash + +# Clean deploy script for nginx-load-balancer +# Removes existing resources and deploys with fixes applied + +set -e + +echo "๐Ÿงน Clean Deploy nginx-load-balancer" +echo "===================================" +echo "" + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +echo "๐Ÿ—‘๏ธ Step 1: Cleaning up existing resources..." +echo "" + +# Delete existing resources if they exist +echo "Removing existing nginx-load-balancer resources..." + +if kubectl get deployment nginx-load-balancer &> /dev/null; then + echo "โ€ข Deleting deployment..." + kubectl delete deployment nginx-load-balancer --ignore-not-found=true +fi + +if kubectl get service nginx-load-balancer-service &> /dev/null; then + echo "โ€ข Deleting service..." + kubectl delete service nginx-load-balancer-service --ignore-not-found=true +fi + +if kubectl get configmap nginx-load-balancer-content &> /dev/null; then + echo "โ€ข Deleting configmaps..." + kubectl delete configmap nginx-load-balancer-content --ignore-not-found=true +fi + +if kubectl get configmap nginx-load-balancer-nginx-config &> /dev/null; then + kubectl delete configmap nginx-load-balancer-nginx-config --ignore-not-found=true +fi + +echo -e "${GREEN}โœ… Cleanup complete${NC}" +echo "" + +# Wait a moment for resources to be fully cleaned up +echo "โณ Waiting for cleanup to complete (5 seconds)..." +sleep 5 +echo "" + +echo "๐Ÿš€ Step 2: Deploying with fixes applied..." +echo "" + +# Deploy ConfigMaps +echo "๐Ÿ“ฆ Deploying ConfigMaps..." +if kubectl apply -f nginx-load-balancer-configmaps.yaml; then + echo -e "${GREEN}โœ… ConfigMaps deployed successfully${NC}" +else + echo -e "${RED}โŒ Failed to deploy ConfigMaps${NC}" + exit 1 +fi +echo "" + +# Deploy Deployment (with hard node affinity) +echo "๐Ÿ“ฆ Deploying nginx application (3 replicas, worker-only)..." +if kubectl apply -f nginx-load-balancer-deployment.yaml; then + echo -e "${GREEN}โœ… Deployment created successfully${NC}" + echo " โ€ข Hard node affinity: Worker nodes only" + echo " โ€ข Replicas: 3" + echo " โ€ข Image: nginx:alpine" +else + echo -e "${RED}โŒ Failed to create deployment${NC}" + exit 1 +fi +echo "" + +# Deploy Service (without externalTrafficPolicy: Local) +echo "๐Ÿ“ฆ Creating LoadBalancer service..." +if kubectl apply -f nginx-load-balancer-service.yaml; then + echo -e "${GREEN}โœ… LoadBalancer service created successfully${NC}" + echo " โ€ข Type: LoadBalancer" + echo " โ€ข ExternalTrafficPolicy: None (optimized for Mycelium)" + echo " โ€ข Dual-stack: IPv4 + IPv6" +else + echo -e "${RED}โŒ Failed to create service${NC}" + exit 1 +fi +echo "" + +echo "โณ Step 3: Waiting for deployment to be ready..." +echo " This may take up to 60 seconds..." +echo "" + +# Wait for deployment to be ready +if kubectl wait --for=condition=available deployment/nginx-load-balancer --timeout=120s; then + echo -e "${GREEN}โœ… Deployment is ready${NC}" +else + echo -e "${YELLOW}โš ๏ธ Deployment not fully ready yet (pods may still be starting)${NC}" +fi +echo "" + +# Check pod status +echo "๐Ÿ” Step 4: Checking pod distribution..." +PODS=$(kubectl get pods -l app=nginx-load-balancer -o wide) + +if echo "$PODS" | grep -q "master"; then + echo -e "${RED}โŒ ISSUE: Pods found on master nodes (this shouldn't happen with hard affinity)${NC}" + echo "$PODS" +else + echo -e "${GREEN}โœ… EXCELLENT: No pods on master nodes (hard affinity working)${NC}" +fi + +echo "$PODS" +echo "" + +# Count pods +TOTAL_PODS=$(echo "$PODS" | grep -v "NAME" | wc -l) +echo "Total pods running: $TOTAL_PODS" + +if [ "$TOTAL_PODS" -eq 3 ]; then + echo -e "${GREEN}โœ… Perfect: 3/3 pods running${NC}" +elif [ "$TOTAL_PODS" -lt 3 ]; then + echo -e "${YELLOW}โš ๏ธ Partial: $TOTAL_PODS/3 pods running (pods may still be starting)${NC}" +else + echo -e "${YELLOW}โš ๏ธ Unexpected: $TOTAL_PODS pods running (expected 3)${NC}" +fi +echo "" + +# Check LoadBalancer service +echo "๐ŸŒ Step 5: Checking LoadBalancer service..." +SERVICE=$(kubectl get svc nginx-load-balancer-service) +echo "$SERVICE" +echo "" + +SERVICE_IP=$(kubectl get svc nginx-load-balancer-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}') +SERVICE_PORT=$(kubectl get svc nginx-load-balancer-service -o jsonpath='{.spec.ports[0].port}') + +if [ -n "$SERVICE_IP" ]; then + echo -e "${GREEN}โœ… LoadBalancer IP assigned: $SERVICE_IP${NC}" + echo " Service URL: http://$SERVICE_IP:$SERVICE_PORT" + + # Test LoadBalancer access + echo "" + echo "๐Ÿงช Testing LoadBalancer IP access..." + if timeout 10 curl -s -f "http://$SERVICE_IP:$SERVICE_PORT" > /dev/null 2>&1; then + echo -e "${GREEN}โœ… LoadBalancer IP is accessible!${NC}" + echo " Test command: curl -6 'http://$SERVICE_IP:$SERVICE_PORT'" + else + echo -e "${YELLOW}โš ๏ธ LoadBalancer IP not yet accessible (may take time to propagate)${NC}" + echo " Try: curl -6 'http://$SERVICE_IP:$SERVICE_PORT'" + fi +else + echo -e "${YELLOW}โš ๏ธ LoadBalancer IP not yet assigned (may take time)${NC}" +fi +echo "" + +# Test direct node access +echo "๐Ÿ”— Step 6: Testing direct node access..." +NODE_IPS=$(kubectl get nodes -o jsonpath='{range .items[*]}{.status.addresses[?@.type=="InternalIP"].address}{"\n"}{end}' | head -3) + +for node_ip in $NODE_IPS; do + echo "Testing node: $node_ip" + if timeout 5 curl -s -f "http://$node_ip:8080" > /dev/null 2>&1; then + echo -e "${GREEN} โœ… Direct node access works${NC}" + break + else + echo -e "${YELLOW} โš ๏ธ Direct node access failed (no pod on this node)${NC}" + fi +done +echo "" + +# Final summary +echo "===================================" +echo "๐ŸŽ‰ CLEAN DEPLOY COMPLETE!" +echo "===================================" +echo "" + +echo -e "${BLUE}๐Ÿ“Š Deployment Summary:${NC}" +echo "โ€ข โœ… Clean deployment with fixes applied" +echo "โ€ข โœ… Hard node affinity (worker nodes only)" +echo "โ€ข โœ… LoadBalancer service (no externalTrafficPolicy)" +echo "โ€ข โœ… 3 nginx replicas" +echo "" + +if [ -n "$SERVICE_IP" ]; then + echo -e "${BLUE}๐ŸŒ Access Information:${NC}" + echo "โ€ข LoadBalancer URL: http://$SERVICE_IP:$SERVICE_PORT" + echo " (This should do real load balancing across pods)" + echo "" + echo "โ€ข Direct node access: Get node IPs with 'kubectl get nodes -o wide'" + echo " (This bypasses load balancer, goes directly to pods)" + echo "" + echo -e "${BLUE}๐Ÿงช Test Commands:${NC}" + echo "โ€ข LoadBalancer (load balancing): curl -6 'http://$SERVICE_IP:$SERVICE_PORT'" + echo "โ€ข Node access: Get node IP and curl -6 'http://[node-ip]:8080'" + echo "โ€ข Monitor pods: kubectl get pods -l app=nginx-load-balancer -o wide" + echo "โ€ข Check service: kubectl get svc nginx-load-balancer-service" +fi + +echo "" +echo -e "${GREEN}โœ… Clean deploy with fixes completed successfully!${NC}" \ No newline at end of file diff --git a/examples/nginx-load-balancer/nginx-load-balancer-deployment.yaml b/examples/nginx-load-balancer/nginx-load-balancer-deployment.yaml index 7d35535..fc76f2c 100644 --- a/examples/nginx-load-balancer/nginx-load-balancer-deployment.yaml +++ b/examples/nginx-load-balancer/nginx-load-balancer-deployment.yaml @@ -16,18 +16,14 @@ spec: spec: hostNetwork: false dnsPolicy: ClusterFirst - # Prefer worker nodes only (not master nodes) + # Hard requirement: worker nodes only (not master nodes) affinity: nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 - preference: - matchExpressions: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: - key: node-role.kubernetes.io/master operator: DoesNotExist - - weight: 50 - preference: - matchExpressions: - key: node-role.kubernetes.io/control-plane operator: DoesNotExist containers: diff --git a/examples/nginx-load-balancer/nginx-load-balancer-service.yaml b/examples/nginx-load-balancer/nginx-load-balancer-service.yaml index c267040..6a764ea 100644 --- a/examples/nginx-load-balancer/nginx-load-balancer-service.yaml +++ b/examples/nginx-load-balancer/nginx-load-balancer-service.yaml @@ -8,7 +8,6 @@ metadata: description: "LoadBalancer service for nginx-load-balancer deployment with automatic IPv6 assignment" spec: type: LoadBalancer - externalTrafficPolicy: Local ipFamilies: - IPv4 - IPv6 diff --git a/examples/nginx-load-balancer/nginx-load-balancer.md b/examples/nginx-load-balancer/nginx-load-balancer.md index c498752..670db0f 100644 --- a/examples/nginx-load-balancer/nginx-load-balancer.md +++ b/examples/nginx-load-balancer/nginx-load-balancer.md @@ -14,10 +14,11 @@ cd myceliumcloud-examples/examples/nginx-load-balancer **What this script does:** 1. โœ… Deploy 3 nginx replicas (production-ready scaling) 2. โœ… Create LoadBalancer service with automatic IPv6 -3. โœ… Configure worker node preferences -4. โœ… Update website content with service information -5. โœ… Verify load balancing functionality -6. โœ… Show you the automatic IPv6 assignment +3. โœ… Configure hard worker node affinity (ensures pods on workers only) +4. โœ… Support both LoadBalancer IP and direct node access +5. โœ… Update website content with service information +6. โœ… Verify load balancing functionality +7. โœ… Show you the automatic IPv6 assignment **Expected output:** ``` @@ -42,6 +43,7 @@ To access from a machine with Mycelium installed: - **Traffic Distribution** - Automatic load balancing across 3 replicas - **Worker Node Preferences** - Deploy only on worker nodes (not masters) - **Production Patterns** - Real-world scaling and reliability +- **Dual-Access Networking** - Both LoadBalancer IP and direct node access supported --- diff --git a/examples/nginx-load-balancer/verify-fixes.sh b/examples/nginx-load-balancer/verify-fixes.sh new file mode 100755 index 0000000..1c81131 --- /dev/null +++ b/examples/nginx-load-balancer/verify-fixes.sh @@ -0,0 +1,159 @@ +#!/bin/bash + +# Verification script for nginx-load-balancer fixes +# Tests the applied configuration changes + +set -e + +echo "๐Ÿ” nginx-load-balancer Fix Verification" +echo "======================================" +echo "" + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +echo "๐Ÿ” Checking if fixes were applied..." +echo "" + +# Check 1: Verify current pods distribution +echo "๐Ÿ“ Step 1: Checking pod distribution..." +PODS=$(kubectl get pods -l app=nginx-load-balancer -o wide) + +if echo "$PODS" | grep -q "master"; then + echo -e "${RED}โŒ ISSUE: Pods found on master nodes (node affinity fix not working)${NC}" + echo "$PODS" +else + echo -e "${GREEN}โœ… GOOD: No pods on master nodes (node affinity working)${NC}" +fi + +echo "$PODS" +echo "" + +# Check 2: Count pods per node type +echo "๐Ÿ“Š Step 2: Analyzing pod distribution by node type..." +WORKER_PODS=$(echo "$PODS" | grep -v "master" | grep -v "NAME" | wc -l) +TOTAL_PODS=$(echo "$PODS" | grep -v "NAME" | wc -l) + +echo "Total pods running: $TOTAL_PODS" +echo "Pods on worker nodes: $WORKER_PODS" + +if [ "$WORKER_PODS" -eq 3 ] && [ "$TOTAL_PODS" -eq 3 ]; then + echo -e "${GREEN}โœ… EXPECTED: 3 pods on 3 worker nodes only${NC}" +else + echo -e "${YELLOW}โš ๏ธ UNEXPECTED: Expected 3 pods on 3 worker nodes${NC}" +fi +echo "" + +# Check 3: Service configuration +echo "๐Ÿ”ง Step 3: Checking service configuration..." +SERVICE=$(kubectl get svc nginx-load-balancer-service -o yaml) + +if echo "$SERVICE" | grep -q "externalTrafficPolicy: Local"; then + echo -e "${RED}โŒ ISSUE: externalTrafficPolicy: Local still present${NC}" + echo " This may cause LoadBalancer IP issues" +else + echo -e "${GREEN}โœ… GOOD: externalTrafficPolicy: Local removed${NC}" +fi + +if echo "$SERVICE" | grep -q "type: LoadBalancer"; then + echo -e "${GREEN}โœ… GOOD: Service type is LoadBalancer${NC}" +else + echo -e "${RED}โŒ ISSUE: Service type is not LoadBalancer${NC}" +fi +echo "" + +# Check 4: LoadBalancer IP availability +echo "๐ŸŒ Step 4: Checking LoadBalancer IP..." +SERVICE_STATUS=$(kubectl get svc nginx-load-balancer-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}') +SERVICE_PORT=$(kubectl get svc nginx-load-balancer-service -o jsonpath='{.spec.ports[0].port}') + +if [ -n "$SERVICE_STATUS" ]; then + echo -e "${GREEN}โœ… GOOD: LoadBalancer IP assigned: $SERVICE_STATUS${NC}" + echo " Full URL: http://$SERVICE_STATUS:$SERVICE_PORT" + + # Test LoadBalancer IP + echo "" + echo "๐Ÿงช Testing LoadBalancer IP access..." + if timeout 10 curl -s -f "http://$SERVICE_STATUS:$SERVICE_PORT" > /dev/null 2>&1; then + echo -e "${GREEN}โœ… GOOD: LoadBalancer IP is accessible${NC}" + else + echo -e "${RED}โŒ ISSUE: LoadBalancer IP is not accessible${NC}" + echo " Try: curl -6 'http://[$SERVICE_STATUS]:$SERVICE_PORT'" + fi +else + echo -e "${YELLOW}โš ๏ธ WAITING: LoadBalancer IP not yet assigned${NC}" +fi +echo "" + +# Check 5: Node access (dual access pattern) +echo "๐Ÿ”— Step 5: Testing dual access pattern..." + +# Get a node IP for testing +NODE_IPS=$(kubectl get nodes -o jsonpath='{range .items[*]}{.status.addresses[?@.type=="InternalIP"].address}{"\n"}{end}' | head -3) +WORKER_COUNT=0 + +for node_ip in $NODE_IPS; do + echo "Testing node: $node_ip" + + # Test direct node access + if timeout 5 curl -s -f "http://$node_ip:8080" > /dev/null 2>&1; then + echo -e "${GREEN} โœ… Direct node access works${NC}" + WORKER_COUNT=$((WORKER_COUNT + 1)) + else + echo -e "${YELLOW} โš ๏ธ Direct node access failed${NC}" + fi +done + +echo "Nodes with working direct access: $WORKER_COUNT" +echo "" + +# Check 6: Deployment configuration +echo "โš™๏ธ Step 6: Checking deployment configuration..." +DEPLOYMENT=$(kubectl get deployment nginx-load-balancer -o yaml) + +if echo "$DEPLOYMENT" | grep -q "requiredDuringSchedulingIgnoredDuringExecution"; then + echo -e "${GREEN}โœ… GOOD: Hard node affinity configured${NC}" +else + echo -e "${RED}โŒ ISSUE: Hard node affinity not found${NC}" +fi + +if echo "$DEPLOYMENT" | grep -q "node-role.kubernetes.io/master"; then + echo -e "${GREEN}โœ… GOOD: Node role filtering configured${NC}" +else + echo -e "${YELLOW}โš ๏ธ WARNING: Node role filtering may be missing${NC}" +fi +echo "" + +# Summary +echo "======================================" +echo "๐Ÿ“Š VERIFICATION SUMMARY" +echo "======================================" +echo "" + +if echo "$PODS" | grep -q "master"; then + echo -e "${RED}โŒ NODE AFFINITY: Pods on master nodes (need fix)${NC}" +else + echo -e "${GREEN}โœ… NODE AFFINITY: Pods on worker nodes only${NC}" +fi + +if [ -n "$SERVICE_STATUS" ]; then + echo -e "${GREEN}โœ… LOADBALANCER: IP assigned ($SERVICE_STATUS)${NC}" +else + echo -e "${YELLOW}โš ๏ธ LOADBALANCER: IP not assigned yet${NC}" +fi + +echo -e "${BLUE}๐ŸŽฏ DUAL ACCESS: Both LoadBalancer IP and node access should work${NC}" +echo "" + +echo "๐Ÿ”ง Next steps if issues found:" +echo "1. Apply fixes: kubectl apply -f nginx-load-balancer-deployment.yaml" +echo "2. Apply service: kubectl apply -f nginx-load-balancer-service.yaml" +echo "3. Restart deployment: kubectl rollout restart deployment/nginx-load-balancer" +echo "4. Re-run this verification script" +echo "" + +echo "โœ… Verification complete!" \ No newline at end of file