From 1ef1f00b3d5ec20669f8613d8016612800b07009 Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Thu, 9 Feb 2023 19:49:37 -0500 Subject: [PATCH] Auto-assign NodePort port by default rather than hardcoding a default value - previously, there was no way to auto-assign a port by default which led to conflicts with other deployments at times - nodeport_port param can still be used to specify a port if desired --- README.md | 2 -- config/crd/bases/awx.ansible.com_awxs.yaml | 1 - roles/installer/defaults/main.yml | 4 +++- roles/installer/templates/networking/service.yaml.j2 | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7631924f..487c3da9 100644 --- a/README.md +++ b/README.md @@ -199,8 +199,6 @@ metadata: name: awx-demo spec: service_type: nodeport - # default nodeport_port is 30080 - nodeport_port: ``` > It may make sense to create and specify your own secret key for your deployment so that if the k8s secret gets deleted, it can be re-created if needed. If it is not provided, one will be auto-generated, but cannot be recovered if lost. Read more [here](#secret-key-configuration). diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 0d645191..7ca390cf 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -153,7 +153,6 @@ spec: nodeport_port: description: Port to use for the nodeport type: integer - default: 30080 node_selector: description: nodeSelector for the pods type: string diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 6f6f4064..85676ee9 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -40,7 +40,9 @@ loadbalancer_protocol: 'http' loadbalancer_port: '80' service_annotations: '' -nodeport_port: '30080' +# Port to be used for NodePort configuration, default is to auto-assign a port between 30000-32768 +#nodeport_port: '30080' + # The TLS termination mechanism to use to access # the services. Supported mechanism are: edge, passthrough # diff --git a/roles/installer/templates/networking/service.yaml.j2 b/roles/installer/templates/networking/service.yaml.j2 index 93b18ba6..72ad544d 100644 --- a/roles/installer/templates/networking/service.yaml.j2 +++ b/roles/installer/templates/networking/service.yaml.j2 @@ -19,7 +19,9 @@ spec: protocol: TCP targetPort: 8052 name: http +{% if nodeport_port is defined %} nodePort: {{ nodeport_port }} +{% endif %} {% elif service_type | lower != 'loadbalancer' and loadbalancer_protocol | lower != 'https' %} - port: 80 protocol: TCP