John Wu
John Wu

Reputation: 131

After applying ingress for k8s, why service address was set to node's IP address?

After applying ingress in k8s, I see service address was set to node's IP address?

Firstly, I added ingress controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/baremetal/deploy.yaml

Secondly, I add ingress yml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress1
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: "n1.avocado.work"
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: node1
            port:
              number: 80

Then I checked the ingress:

kubectl get ingress minimal-ingress1

The address was the node's IP, Why it's not the master's IP

I tried so many times, all the same result. How can I fix that? Any leads, please?

Upvotes: 2

Views: 514

Answers (1)

P....
P....

Reputation: 18411

If you are on bare metal, this is as per design. check this for more info.

MetalLB provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster.

This section demonstrates how to use the Layer 2 configuration mode of MetalLB together with the NGINX Ingress controller in a Kubernetes cluster that has publicly accessible nodes. In this mode, one node attracts all the traffic for the ingress-nginx Service IP. See Traffic policies for more details.

Upvotes: 2

Related Questions