gpt4 book ai didi

ubuntu - NGINX Ingress 创建 NodePort 而不是 LoadBalancer

转载 作者:行者123 更新时间:2023-12-04 18:39:31 29 4
gpt4 key购买 nike

我对这种容器化的东西很陌生。
我在 Ubuntu 18.04 上运行 minikube
我正在以下安装:
https://kubernetes.github.io/ingress-nginx/deploy/
所以只需执行minikube addons enable ingress当我执行 kubectl get services -n ingress-nginx

it shows 
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller NodePort 10.100.216.141 <none> 80:32205/TCP,443:31915/TCP 5d2h
ingress-nginx-controller-admission ClusterIP 10.106.58.189 <none> 443/TCP 5d2h
但是,根据我关注的 ingress-nginx-controller 类型应该是负载均衡器。
我的入口配置:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: we-creators.dev
http:
paths:
- path: /api/users/?(.*)
backend:
serviceName: auth-srv
servicePort: 3000
- path: /?(.*)
backend:
serviceName: client-srv
servicePort: 3000

最佳答案

我已经用 2 个最新版本对此进行了测试,目前我可以看到没有与 ingress-nginx Controller 关联的服务(部署为 minikube 插件)。
请查看 ingress-nginx 部署中的端口。
使用此规范在 kube-system 命名空间中启用入口插件创建的部署:

...
spec:
containers:
- args:
- --report-node-internal-ip-address
...
ports:
- cotainerPort: 80
hostPort:80
name: http
protocol: TCP
- cotainerPort: 443
hostPort: 443
name: https
protocol: TCP
...

看起来在当前的 minikube 版本中,ingress-nginx 正在使用 --主机端口而不是 nginx 入口节点端口服务。
最重要的信息是您当前的 cni 网络插件是否支持 Port-mapping
来自官方文档 CNI networking plugin supports hostPort

The CNI networking plugin supports hostPort.


您可以在 minikube 节点中检查此设置:
minikube -p your_name ssh
cat /etc/cni/net.d/your_config

"type": "portmap",
"capabilities": {"portMappings": true},


限制与 hostNetwork: true 相同。配置:

One major limitation of this deployment approach is that only a single NGINX Ingress controller Pod may be scheduled on each cluster node, because binding the same port multiple times on the same network interface is technically impossible



-- 报告节点内部 IP 地址

because bare-metal nodes usually don't have an ExternalIP, one has to enable the --report-node-internal-ip-address flag, which sets the status of all Ingress objects to the internal IP address of all nodes running the NGINX Ingress controller.


  • 出版服务:ServiceTypes

  • Kubernetes ServiceTypes allow you to specify what kind of Service you want. The default is ClusterIP.

    Type values and their behaviors are:

    • ClusterIP: Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType.

    • NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You'll be able to contact the NodePort Service, from outside the cluster, by requesting :.

    • LoadBalancer: Exposes the Service externally using a cloud provider's load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created.


    服务类型特别说明 Loadbalancer

    When the Service type is set to LoadBalancer, Kubernetes provides functionality equivalent to type equals ClusterIP to pods within the cluster and extends it by programming the (external to Kubernetes) load balancer with entries for the Kubernetes pods. The Kubernetes service controller automates the creation of the external load balancer, health checks (if needed), firewall rules (if needed) and retrieves the external IP allocated by the cloud provider and populates it in the service object


    作为裸机环境中的解决方法,您可以使用 MetalLB

    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.

    关于ubuntu - NGINX Ingress 创建 NodePort 而不是 LoadBalancer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63209635/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com