From 1688e05651ed349a7e09826b918993ff547e62b0 Mon Sep 17 00:00:00 2001 From: k8s-infra-cherrypick-robot <90416843+k8s-infra-cherrypick-robot@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:00:34 -0700 Subject: [PATCH] add ingress controller svc nodeport param (#11361) Co-authored-by: mochizuki875 --- inventory/sample/group_vars/k8s_cluster/addons.yml | 2 ++ .../ingress_controller/ingress_nginx/defaults/main.yml | 2 ++ .../ingress_nginx/templates/svc-ingress-nginx.yml.j2 | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/inventory/sample/group_vars/k8s_cluster/addons.yml b/inventory/sample/group_vars/k8s_cluster/addons.yml index b9960d9f39f..22bd49c5342 100644 --- a/inventory/sample/group_vars/k8s_cluster/addons.yml +++ b/inventory/sample/group_vars/k8s_cluster/addons.yml @@ -100,6 +100,8 @@ rbd_provisioner_enabled: false ingress_nginx_enabled: false # ingress_nginx_host_network: false # ingress_nginx_service_type: LoadBalancer +# ingress_nginx_service_nodeport_http: 30080 +# ingress_nginx_service_nodeport_https: 30081 ingress_publish_status_address: "" # ingress_nginx_nodeselector: # kubernetes.io/os: "linux" diff --git a/roles/kubernetes-apps/ingress_controller/ingress_nginx/defaults/main.yml b/roles/kubernetes-apps/ingress_controller/ingress_nginx/defaults/main.yml index c83c8c3ed61..a2cc7038b64 100644 --- a/roles/kubernetes-apps/ingress_controller/ingress_nginx/defaults/main.yml +++ b/roles/kubernetes-apps/ingress_controller/ingress_nginx/defaults/main.yml @@ -2,6 +2,8 @@ ingress_nginx_namespace: "ingress-nginx" ingress_nginx_host_network: false ingress_nginx_service_type: LoadBalancer +ingress_nginx_service_nodeport_http: "" +ingress_nginx_service_nodeport_https: "" ingress_publish_status_address: "" ingress_nginx_nodeselector: kubernetes.io/os: "linux" diff --git a/roles/kubernetes-apps/ingress_controller/ingress_nginx/templates/svc-ingress-nginx.yml.j2 b/roles/kubernetes-apps/ingress_controller/ingress_nginx/templates/svc-ingress-nginx.yml.j2 index 115232f01c5..46fa8a6241f 100644 --- a/roles/kubernetes-apps/ingress_controller/ingress_nginx/templates/svc-ingress-nginx.yml.j2 +++ b/roles/kubernetes-apps/ingress_controller/ingress_nginx/templates/svc-ingress-nginx.yml.j2 @@ -14,10 +14,16 @@ spec: port: 80 targetPort: 80 protocol: TCP +{% if (ingress_nginx_service_type == 'NodePort' or ingress_nginx_service_type == 'LoadBalancer') and ingress_nginx_service_nodeport_http %} + nodePort: {{ingress_nginx_service_nodeport_http | int}} +{% endif %} - name: https port: 443 targetPort: 443 protocol: TCP +{% if (ingress_nginx_service_type == 'NodePort' or ingress_nginx_service_type == 'LoadBalancer') and ingress_nginx_service_nodeport_https %} + nodePort: {{ingress_nginx_service_nodeport_https | int}} +{% endif %} selector: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/port-of: ingress-nginx