Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple ingress hosts to be defined when using ingress #1377

Merged
merged 31 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2837cb3
replace api version for deployment kind to apps/v1
Apr 22, 2023
f024b78
add new multiple ingress spec and deprecate hostname and ingress_tls_…
Apr 22, 2023
8eccf41
manage new ingress_hosts.tls_secret backup separately
Apr 22, 2023
3fcfa21
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv May 5, 2023
c81d00e
fix ci molecule lint warnings and error
May 5, 2023
8bb8ff9
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv May 6, 2023
2719eb8
Merge branch 'devel' into allow_multiple_ingress
guillaumelfv May 9, 2023
dd54fc6
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv May 11, 2023
d246cef
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv May 19, 2023
93303b5
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv May 22, 2023
9e02a5f
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Jun 19, 2023
0ec9ce1
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Jun 26, 2023
75c13ef
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Jul 4, 2023
f376590
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Jul 17, 2023
bc6c4df
merge conflict
Jul 31, 2023
c44a24f
fix documentation
Jul 31, 2023
2331bbc
fix ingress_hosts tls_secret key being optional
Jul 31, 2023
18f2d0c
Merge branch 'devel' into allow_multiple_ingress
fosterseth Aug 16, 2023
dad4261
Merge branch 'devel' into allow_multiple_ingress
Aug 18, 2023
5246e69
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Sep 9, 2023
3505a36
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Sep 24, 2023
05cf9d8
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Oct 6, 2023
963eaf5
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Oct 12, 2023
9b53edf
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Oct 26, 2023
c912d16
remove fieldDependency:ingress_type:Ingress for Ingress Hosts
Oct 26, 2023
e52c074
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Oct 27, 2023
6037928
Merge branch 'devel' into allow_multiple_ingress
rooftopcellist Nov 8, 2023
428a1b1
Merge branch 'devel' into allow_multiple_ingress
rooftopcellist Nov 9, 2023
6cbea8e
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Dec 4, 2023
ac7fc08
Merge branch 'ansible:devel' into allow_multiple_ingress
guillaumelfv Jan 4, 2024
72ff073
fix scenario when neither hostname or ingress_hosts is defined
Jan 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions config/crd/bases/awx.ansible.com_awxs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ spec:
description: Username to use for the admin account
type: string
default: admin
hostname:
description: The hostname of the instance
hostname: # deprecated
description: (Deprecated) The hostname of the instance
type: string
admin_email:
description: The admin user email
Expand Down Expand Up @@ -123,12 +123,24 @@ spec:
ingress_annotations:
description: Annotations to add to the Ingress Controller
type: string
ingress_tls_secret:
description: Secret where the Ingress TLS secret can be found
ingress_tls_secret: # deprecated
description: (Deprecated) Secret where the Ingress TLS secret can be found
type: string
ingress_class_name:
description: The name of ingress class to use instead of the cluster default.
type: string
ingress_hosts:
description: Ingress hostnames of the instance
type: array
items:
type: object
properties:
hostname:
description: Hostname of the instance
type: string
tls_secret:
description: Secret where the Ingress TLS secret can be found
type: string
ingress_controller:
description: Special configuration for specific Ingress Controllers
type: string
Expand Down
10 changes: 8 additions & 2 deletions config/manifests/bases/awx-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ spec:
kind: AWX
name: awxs.awx.ansible.com
specDescriptors:
- displayName: Hostname
- displayName: Hostname (Deprecated)
path: hostname
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
Expand Down Expand Up @@ -297,12 +297,18 @@ spec:
- urn:alm:descriptor:com.tectonic.ui:advanced
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress
- displayName: Ingress TLS Secret
- displayName: Ingress TLS Secret (Deprecated)
path: ingress_tls_secret
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- urn:alm:descriptor:io.kubernetes:Secret
- urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress
- displayName: Ingress Hosts
path: ingress_hosts
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- urn:alm:descriptor:com.tectonic.ui:text
- urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress
guillaumelfv marked this conversation as resolved.
Show resolved Hide resolved
- displayName: Ingress Controller
path: ingress_controller
x-descriptors:
Expand Down
31 changes: 19 additions & 12 deletions docs/user-guide/network-and-tls-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following variables are customizable only when `service_type=LoadBalancer`
| --------------------- | ---------------------------------------- | ------- |
| loadbalancer_protocol | Protocol to use for Loadbalancer ingress | http |
| loadbalancer_port | Port used for Loadbalancer ingress | 80 |
| loadbalancer_ip | Assign Loadbalancer IP | '' |
| loadbalancer_ip | Assign Loadbalancer IP | '' |

```yaml
---
Expand Down Expand Up @@ -86,22 +86,26 @@ spec:

The following variables are customizable when `ingress_type=ingress`. The `ingress` type creates an Ingress resource as [documented](https://kubernetes.io/docs/concepts/services-networking/ingress/) which can be shared with many other Ingress Controllers as [listed](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/).

| Name | Description | Default |
| ------------------- | ---------------------------------------- | --------------------------- |
| ingress_annotations | Ingress annotations | Empty string |
| ingress_tls_secret | Secret that contains the TLS information | Empty string |
| ingress_class_name | Define the ingress class name | Cluster default |
| hostname | Define the FQDN | {{ meta.name }}.example.com |
| ingress_path | Define the ingress path to the service | / |
| ingress_path_type | Define the type of the path (for LBs) | Prefix |
| ingress_api_version | Define the Ingress resource apiVersion | 'networking.k8s.io/v1' |
| Name | Description | Default |
| ---------------------------------- | ---------------------------------------------------------------------------------- | --------------------------- |
| ingress_annotations | Ingress annotations | Empty string |
| ingress_tls_secret _(deprecated)_ | Secret that contains the TLS information | Empty string |
| ingress_class_name | Define the ingress class name | Cluster default |
| hostname _(deprecated)_ | Define the FQDN | {{ meta.name }}.example.com |
| ingress_hosts | Define one or multiple FQDN with optional Secret that contains the TLS information | Empty string |
| ingress_path | Define the ingress path to the service | / |
| ingress_path_type | Define the type of the path (for LBs) | Prefix |
| ingress_api_version | Define the Ingress resource apiVersion | 'networking.k8s.io/v1' |

```yaml
---
spec:
...
ingress_type: ingress
hostname: awx-demo.example.com
ingress_hosts:
- hostname: awx-demo.example.com
- hostname: awx-demo.sample.com
tls_secret: sample-tls-secret
ingress_annotations: |
environment: testing
```
Expand All @@ -119,7 +123,10 @@ Some Ingress Controllers need a special configuration to fully support AWX, add
spec:
...
ingress_type: ingress
hostname: awx-demo.example.com
ingress_hosts:
- hostname: awx-demo.example.com
- hostname: awx-demo.sample.com
tls_secret: sample-tls-secret
ingress_controller: contour
```

Expand Down
24 changes: 24 additions & 0 deletions roles/backup/tasks/dump_ingress_tls_secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

- name: Get secret
k8s_info:
version: v1
kind: Secret
namespace: '{{ ansible_operator_meta.namespace }}'
name: "{{ item }}"
register: _secret
no_log: "{{ no_log }}"

- name: Backup secret if exists
block:
- name: Set secret key
set_fact:
_data: "{{ _secret['resources'][0]['data'] }}"
_type: "{{ _secret['resources'][0]['type'] }}"
no_log: "{{ no_log }}"

- name: Create and Add secret names and data to dictionary
set_fact:
secret_dict: "{{ secret_dict | default({}) | combine({item: { 'name': item, 'data': _data, 'type': _type }}) }}"
no_log: "{{ no_log }}"
when: _secret | length
7 changes: 7 additions & 0 deletions roles/backup/tasks/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
include_tasks: dump_secret.yml
loop:
- route_tls_secret
# ingress_tls_secret is deprecated in favor of ingress_hosts.tls_secret
- ingress_tls_secret
- ldap_cacert_secret
- bundle_cacert_secret
- ee_pull_credentials_secret

- name: Dump ingress tls secret names from awx spec and data into file
include_tasks: dump_ingress_tls_secrets.yml
with_items:
- "{{ awx_spec.spec['ingress_hosts'] | default('') | map(attribute='tls_secret', default='') | select() | list }}"
when: "{{ awx_spec.spec['ingress_hosts'] | default('') | map(attribute='tls_secret', default='') | select() | list | length }}"

- name: Dump receptor secret names and data into file
include_tasks: dump_receptor_secrets.yml
loop:
Expand Down
10 changes: 10 additions & 0 deletions roles/installer/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ ingress_tls_secret: ''
# ingress_controller: contour
ingress_controller: ''

# One or multiple FQDN with optional Secret that contains the TLS information.
# The TLS secret either has to exist before hand with
# the corresponding cert and key or just be an indicator for where an automated
# process like cert-manager (enabled via annotations) will store the TLS
# certificate and key.
# ingress_hosts:
# - hostname: awx-demo.example.com
# tls_secret: example-com-tls
ingress_hosts: ''

loadbalancer_protocol: 'http'
loadbalancer_port: '80'
service_annotations: ''
Expand Down
2 changes: 1 addition & 1 deletion roles/installer/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Delete old deployment for before installing during upgrade
k8s:
kind: Deployment
api_version: v1
api_version: apps/v1
namespace: "{{ ansible_operator_meta.namespace }}"
name: "{{ ansible_operator_meta.name }}"
state: absent
Expand Down
4 changes: 2 additions & 2 deletions roles/installer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

- name: Check for presence of awx-task Deployment
k8s_info:
api_version: v1
api_version: apps/v1
kind: Deployment
name: "{{ ansible_operator_meta.name }}-task"
namespace: "{{ ansible_operator_meta.namespace }}"
register: awx_task_deployment

- name: Check for presence of awx-web Deployment
k8s_info:
api_version: v1
api_version: apps/v1
kind: Deployment
name: "{{ ansible_operator_meta.name }}-web"
namespace: "{{ ansible_operator_meta.namespace }}"
Expand Down
43 changes: 37 additions & 6 deletions roles/installer/templates/networking/ingress.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
annotations:
{% if ingress_annotations %}
{{ ingress_annotations | indent(width=4) }}
{% endif %}
{%- endif %}
{% if ingress_controller|lower == "contour" %}
projectcontour.io/websocket-routes: "/websocket"
kubernetes.io/ingress.class: contour
Expand All @@ -24,7 +24,9 @@ spec:
ingressClassName: '{{ ingress_class_name }}'
{% endif %}
rules:
- http:
{% if hostname and (not ingress_hosts) %}
- host: {{ hostname }}
http:
paths:
- path: '{{ ingress_path }}'
pathType: '{{ ingress_path_type }}'
Expand All @@ -42,16 +44,45 @@ spec:
port:
number: 80
{% endif %}
{% if hostname %}
host: {{ hostname }}
{% endif %}
{% if ingress_tls_secret %}
tls:
- hosts:
- {{ hostname }}
- {{ hostname }}
secretName: {{ ingress_tls_secret }}
{% endif %}
{% endif %}
{% if ingress_hosts %}
{% for item in ingress_hosts %}
- host: {{ item.hostname }}
http:
paths:
- path: '{{ ingress_path }}'
pathType: '{{ ingress_path_type }}'
backend:
service:
name: '{{ ansible_operator_meta.name }}-service'
port:
number: 80
{% if ingress_controller|lower == "contour" %}
- path: '{{ ingress_path.rstrip("/") }}/websocket'
pathType: '{{ ingress_path_type }}'
backend:
service:
name: '{{ ansible_operator_meta.name }}-service'
port:
number: 80
{% endif %}
{% endfor %}
tls:
{% for item in ingress_hosts %}
{% if 'tls_secret' in item %}
- hosts:
- {{ item.hostname }}
secretName: {{ item.tls_secret }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}

{% if ingress_type|lower == "route" %}
---
Expand Down