简体   繁体   中英

How to deploy nginx-ingress controller with Helm on k8s, with TCP/UDP load balancing

I am trying to deploy an nginx-ingress controller on Kubernetes with Helm.

I also want to configure it to bind specific ports of the nginx-ingress-controller service to specific node ports on the VM [I run it inside Vagrant].

For example, I want:

10000 node port -> 8080 nginx-ingress controller -> 10000 udp port of my backend service

My Helm deployment is the following:

release_name=tcp-udp-nginx-ic
http_nodePort=30080
https_nodePort=30443

echo
echo "- Installing -${release_name}- into cluster ..." | cowsay

helm del --purge ${release_name}
helm upgrade --install ${release_name} \
--set controller.service.type=NodePort \
--set controller.service.nodePorts.http=${http_nodePort} \
--set controller.service.nodePorts.https=${https_nodePort} \
--set rbac.create=true \
--set controller.replicaCount=1 \
--set controller.resources.requests."memory"=300Mi \
--set controller.resources.requests."cpu"=300m \
--set controller.resources.limits."memory"=300Mi \
--set controller.resources.limits."cpu"=300m \
--set controller.ingressClass=nginx \
--set controller.tcp.configMapNamespace=default \
--set controller.udp.configMapNamespace=default \
--set udp."8080"="default/the-backend-service:10000" \
--set service.nodePorts.udp."8080"=10000 \
stable/nginx-ingress

My question is, in what format should I enter the --set service.nodePorts.udp part in order to accomplish the above?

The format I am using is referenced in the Helm documentation about the limitations of --set .

I know I am close because when I clone the chart locally and I set in the values.yml file the following, plays well.

    nodePorts:
      http: ""
      https: ""
      tcp: {}
#      udp: {}
      udp:
        8080: 10000
        8081: 10001

When I deploy it like that and desscribe the ingress controller service I get:

Name:                     tcp-udp-nginx-ic-nginx-ingress-controller
Namespace:                default
Labels:                   app=nginx-ingress
                          chart=nginx-ingress-1.24.3
                          component=controller
                          heritage=Tiller
                          release=tcp-udp-nginx-ic
Annotations:              <none>
Selector:                 app=nginx-ingress,component=controller,release=tcp-udp-nginx-ic
Type:                     NodePort
IP:                       10.109.1.182
Port:                     http  80/TCP
TargetPort:               http/TCP
NodePort:                 http  30080/TCP
Endpoints:
Port:                     https  443/TCP
TargetPort:               https/TCP
NodePort:                 https  30443/TCP
Endpoints:
Port:                     8080-udp  8080/UDP
TargetPort:               8080-udp/UDP
NodePort:                 8080-udp  10000/UDP
Endpoints:

Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Move your complex --set settings into a custom myvalues.yaml . You don't have to clone the chart to use a yaml file to override chart values.

When you run helm upgrade --install ${release_name} -f myvalues.yaml stable/nginx-ingress it will override any default values with the values configured in this file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM