You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx Ingress无法提供服务:Ingress资源未分配IP求助

Troubleshooting Unassigned Ingress IP & Failed Access to Jenkins on kubeadm Cluster

Let's break down the steps to fix your issue where the Ingress resource has no assigned IP and you can't access jenkins.xyz.com. Since you're working with a 3-node kubeadm cluster and the Nginx Ingress Controller, here's what to check and fix:

1. Verify the Nginx Ingress Controller Deployment & Service

The mandatory.yaml you applied deploys the controller components, but it might not set up a service that exposes the controller externally (especially in on-prem/non-cloud kubeadm clusters).

  • First, check if the controller pods are running:

    kubectl get pods -n ingress-nginx
    

    All pods should show a Running status. If any are stuck, check their logs with kubectl logs <pod-name> -n ingress-nginx for errors.

  • Next, check the controller's service type:

    kubectl get svc -n ingress-nginx
    

    If the service is of type ClusterIP, that means the controller isn't exposed to the outside world—this is why your Ingress resource has no assigned IP. You have two options here:

    • Option 1: Switch to NodePort (quick fix for testing):
      Edit the service to change its type:
      kubectl edit svc ingress-nginx -n ingress-nginx
      
      Change type: ClusterIP to type: NodePort, save the changes. Now you'll see node ports assigned to port 80 and 443. You can access Jenkins via http://<any-node-ip>:<node-port-for-80>.
    • Option 2: Deploy MetalLB (for a proper LoadBalancer IP):
      Since kubeadm clusters don't have a built-in LoadBalancer provider (unlike cloud clusters), MetalLB can assign a static IP range to your Ingress Controller. Once deployed, change the controller service type to LoadBalancer, and it will get an IP from your configured range—this IP will then show up in your Ingress resource's ADDRESS field.

2. Validate Ingress API Version Compatibility

Your Ingress uses extensions/v1beta1, which is deprecated in Kubernetes 1.19 and later. While this might not be the immediate cause of the missing IP, it's best to update to the stable API version to avoid future issues. Modify your Ingress YAML to use networking.k8s.io/v1:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jenkins-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: jenkins.xyz.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: jenkins-svc
            port:
              number: 80

Apply the updated file with kubectl apply -f <ingress-file.yaml>.

3. Confirm Backend Services & Pods Are Healthy

Before blaming the Ingress, ensure your Jenkins deployment and service are working correctly:

  • Check if Jenkins pods are running:
    kubectl get pods -l component=web
    
  • Test accessing the service directly from within the cluster (or via port-forward):
    kubectl port-forward svc/jenkins-svc 8080:80
    
    Then open http://localhost:8080 in your browser—if Jenkins loads, the backend is working, and the issue is definitely with the Ingress/Controller setup.

4. Fix DNS Resolution

For jenkins.xyz.com to work, you need to ensure the domain resolves to the correct IP:

  • If using NodePort: Point the domain to any of your cluster nodes' public/private IPs.
  • If using MetalLB/LoadBalancer: Point the domain to the LoadBalancer IP assigned to the Ingress Controller service.

You can test this locally by adding an entry to your /etc/hosts file (Linux/macOS) or C:\Windows\System32\drivers\etc\hosts (Windows):

<target-ip> jenkins.xyz.com

5. Check Ingress Controller Logs for Errors

If the above steps don't resolve the issue, dig into the Ingress Controller logs to see if it's failing to process your Ingress resource:

kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx

Look for lines mentioning jenkins-ingress—common issues include mislabeled selectors or invalid Ingress configuration.


内容的提问来源于stack exchange,提问作者pawarchinmay27

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:50:46