From 12f43766c8ce333f9570ff22fec96d713e2ff2fe Mon Sep 17 00:00:00 2001 From: "zhangpeng.zong" Date: Fri, 10 Feb 2023 22:03:33 +0800 Subject: [PATCH 1/4] feat: add HostAliases to web/task containers (fixes #646) --- README.md | 19 +++++++++++++++++++ config/crd/bases/awx.ansible.com_awxs.yaml | 12 ++++++++++++ .../templates/deployments/task.yaml.j2 | 10 ++++++++++ 3 files changed, 41 insertions(+) diff --git a/README.md b/README.md index 9d80d417c..b594d2a1e 100644 --- a/README.md +++ b/README.md @@ -676,6 +676,25 @@ $ oc adm policy add-scc-to-user privileged -z awx Again, this is the most relaxed SCC that is provided by OpenShift, so be sure to familiarize yourself with the security concerns that accompany this action. +#### Containers HostAliases Requirements + +Sometimes you might need to use HostAliases in web/task containers. + +| Name | Description | Default | +| ------------ | --------------------- | ------- | +| host_aliases | A list of HostAliases | None | + +Example of customization could be: + +```yaml +--- +spec: + ... + host_aliases: + - ip: + hostnames: + - +``` #### Containers Resource Requirements diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 53bf64ff1..55365f2e0 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -1345,6 +1345,18 @@ spec: image_pull_secret: # deprecated description: (Deprecated) Image pull secret for app and database containers type: string + host_aliases: + description: HostAliases for app containers + type: array + items: + type: object + properties: + ip: + type: string + hostnames: + type: array + items: + type: string task_resource_requirements: description: Resource requirements for the task container properties: diff --git a/roles/installer/templates/deployments/task.yaml.j2 b/roles/installer/templates/deployments/task.yaml.j2 index ae7dcc375..4a5265890 100644 --- a/roles/installer/templates/deployments/task.yaml.j2 +++ b/roles/installer/templates/deployments/task.yaml.j2 @@ -50,6 +50,16 @@ spec: {% endif %} spec: serviceAccountName: '{{ ansible_operator_meta.name }}' +{% if host_aliases | length > 0 %} + hostAliases: +{% for item in host_aliases %} + - ip: {{ item.ip }} + hostnames: +{% for hostname in item.hostnames %} + - {{ hostname }} +{% endfor %} +{% endfor %} +{% endif %} {% if image_pull_secret is defined %} imagePullSecrets: - name: {{ image_pull_secret }} From 14a86d7bc73befc3e380ebed34dcdbbf38325bbe Mon Sep 17 00:00:00 2001 From: "zhangpeng.zong" Date: Fri, 17 Mar 2023 11:30:47 +0800 Subject: [PATCH 2/4] feat: add HostAliases to web/task containers --- README.md | 2 +- .../manifests/bases/awx-operator.clusterserviceversion.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b594d2a1e..8c515f21e 100644 --- a/README.md +++ b/README.md @@ -678,7 +678,7 @@ Again, this is the most relaxed SCC that is provided by OpenShift, so be sure to #### Containers HostAliases Requirements -Sometimes you might need to use HostAliases in web/task containers. +Sometimes you might need to use [HostAliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/) in web/task containers. | Name | Description | Default | | ------------ | --------------------- | ------- | diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index 7519e04b2..f91813057 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -320,6 +320,11 @@ spec: path: image_pull_secret x-descriptors: - urn:alm:descriptor:com.tectonic.ui:hidden + - displayName: HostAliases for app containers + path: host_aliases + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:hidden - displayName: Web Container Resource Requirements path: web_resource_requirements x-descriptors: From ae7aa9a467c8aa72e7ac3ba69726a37705b8ba6a Mon Sep 17 00:00:00 2001 From: Christian Adams Date: Wed, 19 Apr 2023 15:39:10 -0400 Subject: [PATCH 3/4] Make host_aliases display in the Operator UI Co-authored-by: Dimitri Savineau --- config/manifests/bases/awx-operator.clusterserviceversion.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index f91813057..31ab7e0d2 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -324,7 +324,7 @@ spec: path: host_aliases x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced - - urn:alm:descriptor:com.tectonic.ui:hidden + - urn:alm:descriptor:com.tectonic.ui:text - displayName: Web Container Resource Requirements path: web_resource_requirements x-descriptors: From c3f07be7cc7e59221f230f0a96a86881ea6ff6f9 Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Thu, 20 Apr 2023 01:08:17 -0400 Subject: [PATCH 4/4] Add default value for host_aliases and add to web deployment template --- roles/installer/defaults/main.yml | 7 +++++++ .../templates/deployments/task.yaml.j2 | 20 +++++++++---------- .../templates/deployments/web.yaml.j2 | 10 ++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index ad3e98b36..97b728734 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -425,3 +425,10 @@ set_self_labels: true # Disable web container's nginx ipv6 listener ipv6_disabled: false + +# Set hostAliases on deployments +# hostAliases: +# - ip: 10.10.0.10 +# hostnames: +# - hostname +host_aliases: '' diff --git a/roles/installer/templates/deployments/task.yaml.j2 b/roles/installer/templates/deployments/task.yaml.j2 index 4a5265890..d48c432f5 100644 --- a/roles/installer/templates/deployments/task.yaml.j2 +++ b/roles/installer/templates/deployments/task.yaml.j2 @@ -50,16 +50,6 @@ spec: {% endif %} spec: serviceAccountName: '{{ ansible_operator_meta.name }}' -{% if host_aliases | length > 0 %} - hostAliases: -{% for item in host_aliases %} - - ip: {{ item.ip }} - hostnames: -{% for hostname in item.hostnames %} - - {{ hostname }} -{% endfor %} -{% endfor %} -{% endif %} {% if image_pull_secret is defined %} imagePullSecrets: - name: {{ image_pull_secret }} @@ -69,6 +59,16 @@ spec: - name: {{ secret }} {% endfor %} {% endif %} +{% if host_aliases is defined and host_aliases | length > 0 %} + hostAliases: +{% for item in host_aliases %} + - ip: {{ item.ip }} + hostnames: +{% for hostname in item.hostnames %} + - {{ hostname }} +{% endfor %} +{% endfor %} +{% endif %} {% if control_plane_priority_class is defined %} priorityClassName: '{{ control_plane_priority_class }}' {% endif %} diff --git a/roles/installer/templates/deployments/web.yaml.j2 b/roles/installer/templates/deployments/web.yaml.j2 index ba814c43c..9e10985b5 100644 --- a/roles/installer/templates/deployments/web.yaml.j2 +++ b/roles/installer/templates/deployments/web.yaml.j2 @@ -60,6 +60,16 @@ spec: - name: {{ secret }} {% endfor %} {% endif %} +{% if host_aliases is defined and host_aliases | length > 0 %} + hostAliases: +{% for item in host_aliases %} + - ip: {{ item.ip }} + hostnames: +{% for hostname in item.hostnames %} + - {{ hostname }} +{% endfor %} +{% endfor %} +{% endif %} {% if control_plane_priority_class is defined %} priorityClassName: '{{ control_plane_priority_class }}' {% endif %}