Kubernetes LoadBalancer服务无法访问问题求助(AWS ECR场景)
Let's break down your issues step by step and fix them one by one:
First: Resolve the LoadBalancer Service Access Problem
1. Fix the Mismatch Between Service YAML and Running State
Your provided Service YAML configures port: 80, but kubectl get service shows the PORT as 8765:32735/TCP — this means the running Service doesn't match your desired configuration. Update it first:
kubectl apply -f your-service-yaml-file.yaml # Verify the update kubectl get service charting-rest-server-service
Make sure the PORT field shows 80:xxxx/TCP afterward, so accessing port 80 externally works as expected.
2. Correct the DNS Resolution Error
You ran curl *****.us-west-2.elb.amazonaws.com:80, but your Service's EXTERNAL-IP is in the eu-west-2 region — this is a clear typo! Use the correct ELB address:
curl *******.eu-west-2.elb.amazonaws.com:80
If it still fails to resolve:
- Check if your local network can access AWS eu-west-2 services (try pinging a public eu-west-2 endpoint for testing)
- Log into the AWS Console, go to EC2 > Load Balancers, search for your ELB's DNS name, and confirm it's in Active status. ELB DNS records can take a few minutes to propagate globally after creation.
3. Validate LoadBalancer Backend Health Checks
Even if the ELB is created, failed health checks will block access:
- In the AWS Console's ELB details page, check the Target Groups tab to confirm your Pods show as healthy
- Your Pod listens on port 5000 — ensure the target group's health check path (e.g.,
/health) points to a valid endpoint in your Python app. If you don't have a dedicated health endpoint, you can temporarily use/(not recommended for production).
Second: Fix the Ingress Issues
Your Ingress config has several critical problems:
1. Use the Supported API Version
extensions/v1beta1 is deprecated — switch to the current networking.k8s.io/v1 API. Here's the updated YAML:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: charting-rest-server-ingress spec: rules: - http: paths: - path: / pathType: Prefix backend: service: name: charting-rest-server-service port: number: 80
2. Deploy the Required Ingress Controller
AWS EKS doesn't include an Ingress Controller by default. You need to deploy the AWS Load Balancer Controller (replaces the old ALB Ingress Controller) to convert Ingress resources into AWS ALBs:
- First, ensure your EKS cluster has the necessary IAM permissions (create the required IAM Policy and ServiceAccount per AWS guidelines)
- Deploy the controller via Helm:
helm repo add eks https://aws.github.io/eks-charts helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=<your-cluster-name> \ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controller
Wait a few minutes after deployment, then run kubectl get ingress — the ADDRESS field should populate with the ALB's DNS address.
3. Fix the Invalid Host Configuration
Your original Ingress used host: charting-rest-server-service, which is not a valid domain. Either:
- Remove the
hostfield entirely to match all requests to the ALB - Replace it with a domain you own (and point its DNS record to the ALB once it's created)
Extra Troubleshooting Checks
- Confirm your Python app is actually listening on port 5000: exec into the Pod to test local access
kubectl exec -it <your-pod-name> -- curl localhost:5000
- Verify your EKS cluster's VPC configuration: ensure it has public subnets, and the LoadBalancer's security group allows inbound traffic on port 80.
内容的提问来源于stack exchange,提问作者Flora Biletsiou

