k8s申请ingress后,为什么服务地址设置为节点的IP地址?
After applying ingress for k8s, why service address was set to node's IP address?
在 k8s
中应用 ingress
后,我看到服务地址设置为 node's
IP 地址?
首先,我添加了入口控制器
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/baremetal/deploy.yaml
其次,我添加入口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
然后我检查了入口:
kubectl get ingress minimal-ingress1
地址是节点的IP,为什么不是master的IP
我试了很多次,都是一样的结果。我该如何解决?请问有什么线索吗?
如果您使用的是裸机,这是按照设计。查看 this 了解更多信息。
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.
在 k8s
中应用 ingress
后,我看到服务地址设置为 node's
IP 地址?
首先,我添加了入口控制器
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/baremetal/deploy.yaml
其次,我添加入口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
然后我检查了入口:
kubectl get ingress minimal-ingress1
地址是节点的IP,为什么不是master的IP
我试了很多次,都是一样的结果。我该如何解决?请问有什么线索吗?
如果您使用的是裸机,这是按照设计。查看 this 了解更多信息。
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.