From 2837cb370d1b963ca425833e2ef79de920ffaf45 Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Sat, 22 Apr 2023 14:43:02 +0700 Subject: [PATCH 1/8] replace api version for deployment kind to apps/v1 --- roles/installer/defaults/main.yml | 10 ++++++++++ roles/installer/tasks/install.yml | 2 +- roles/installer/tasks/main.yml | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index ad3e98b36..fd7e30574 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -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: '' diff --git a/roles/installer/tasks/install.yml b/roles/installer/tasks/install.yml index ecf945d57..c5a3a00dd 100644 --- a/roles/installer/tasks/install.yml +++ b/roles/installer/tasks/install.yml @@ -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 diff --git a/roles/installer/tasks/main.yml b/roles/installer/tasks/main.yml index 234caa3f4..f0b2ae5b6 100644 --- a/roles/installer/tasks/main.yml +++ b/roles/installer/tasks/main.yml @@ -9,7 +9,7 @@ - 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 }}" @@ -17,7 +17,7 @@ - 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 }}" From f024b78f460b59b6f0ce8aab1a8ba4fdf95caa4c Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Sat, 22 Apr 2023 16:20:32 +0700 Subject: [PATCH 2/8] add new multiple ingress spec and deprecate hostname and ingress_tls_secret --- README.md | 29 ++++++++----- config/crd/bases/awx.ansible.com_awxs.yaml | 20 +++++++-- .../awx-operator.clusterserviceversion.yaml | 10 ++++- .../templates/networking/ingress.yaml.j2 | 41 ++++++++++++++++--- 4 files changed, 77 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 9d80d417c..c5fdc3dd4 100644 --- a/README.md +++ b/README.md @@ -457,22 +457,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 ``` @@ -490,7 +494,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 ``` diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 53bf64ff1..dec97ede5 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -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 @@ -115,12 +115,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 diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index 7519e04b2..5419b2d3e 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -156,7 +156,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 @@ -245,12 +245,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 - displayName: Ingress Controller path: ingress_controller x-descriptors: diff --git a/roles/installer/templates/networking/ingress.yaml.j2 b/roles/installer/templates/networking/ingress.yaml.j2 index 3d79c934f..649517f6b 100644 --- a/roles/installer/templates/networking/ingress.yaml.j2 +++ b/roles/installer/templates/networking/ingress.yaml.j2 @@ -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 @@ -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 }}' @@ -42,16 +44,43 @@ 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 item.tls_secret %} + - hosts: + - {{ item.hostname }} + secretName: {{ item.tls_secret }} +{%- endfor %} +{% endif %} +{% endif %} {% if ingress_type|lower == "route" %} --- From 8eccf41acfdb447e840bc11cce74af3742c77716 Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Sat, 22 Apr 2023 16:22:23 +0700 Subject: [PATCH 3/8] manage new ingress_hosts.tls_secret backup separately --- .../backup/tasks/dump_ingress_tls_secrets.yml | 24 +++++++++++++++++++ roles/backup/tasks/secrets.yml | 7 ++++++ 2 files changed, 31 insertions(+) create mode 100644 roles/backup/tasks/dump_ingress_tls_secrets.yml diff --git a/roles/backup/tasks/dump_ingress_tls_secrets.yml b/roles/backup/tasks/dump_ingress_tls_secrets.yml new file mode 100644 index 000000000..92a732755 --- /dev/null +++ b/roles/backup/tasks/dump_ingress_tls_secrets.yml @@ -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 \ No newline at end of file diff --git a/roles/backup/tasks/secrets.yml b/roles/backup/tasks/secrets.yml index 42ca63d03..fd9dc9a93 100644 --- a/roles/backup/tasks/secrets.yml +++ b/roles/backup/tasks/secrets.yml @@ -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: From c81d00e8be6e78e631af25767cd8c207619e48cb Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Fri, 5 May 2023 17:26:02 +0700 Subject: [PATCH 4/8] fix ci molecule lint warnings and error --- ansible/helm-release.yml | 2 +- config/crd/bases/awx.ansible.com_awxs.yaml | 4 ++-- roles/backup/tasks/dump_ingress_tls_secrets.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible/helm-release.yml b/ansible/helm-release.yml index ef6022ede..ccff346d2 100644 --- a/ansible/helm-release.yml +++ b/ansible/helm-release.yml @@ -99,7 +99,7 @@ loop: - git add index.yaml - git commit -m "{{ commit_message }}" - #- git push + # - git push args: chdir: "{{ temp_dir.path }}/" environment: diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index dec97ede5..cab350e8c 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -54,7 +54,7 @@ spec: description: Username to use for the admin account type: string default: admin - hostname: # deprecated + hostname: # deprecated description: (Deprecated) The hostname of the instance type: string admin_email: @@ -115,7 +115,7 @@ spec: ingress_annotations: description: Annotations to add to the Ingress Controller type: string - ingress_tls_secret: # deprecated + ingress_tls_secret: # deprecated description: (Deprecated) Secret where the Ingress TLS secret can be found type: string ingress_class_name: diff --git a/roles/backup/tasks/dump_ingress_tls_secrets.yml b/roles/backup/tasks/dump_ingress_tls_secrets.yml index 92a732755..dd82dcfa2 100644 --- a/roles/backup/tasks/dump_ingress_tls_secrets.yml +++ b/roles/backup/tasks/dump_ingress_tls_secrets.yml @@ -21,4 +21,4 @@ set_fact: secret_dict: "{{ secret_dict | default({}) | combine({item: { 'name': item, 'data': _data, 'type': _type }}) }}" no_log: "{{ no_log }}" - when: _secret | length \ No newline at end of file + when: _secret | length From c44a24f86c84a5acc8ee3a49274b982227c220d0 Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Mon, 31 Jul 2023 14:13:13 +0700 Subject: [PATCH 5/8] fix documentation --- README.md | 1402 ----------------- .../network-and-tls-configuration.md | 31 +- 2 files changed, 19 insertions(+), 1414 deletions(-) diff --git a/README.md b/README.md index 52f655925..de5d41d1d 100644 --- a/README.md +++ b/README.md @@ -31,1408 +31,6 @@ NOTE: we are in the process of moving this readme into official docs in the /do -## Purpose - -This operator is meant to provide a more Kubernetes-native installation method for AWX via an AWX Custom Resource Definition (CRD). - -## Usage - -This Kubernetes Operator is meant to be deployed in your Kubernetes cluster(s) and can manage one or more AWX instances in any namespace. - -### Creating a minikube cluster for testing - -If you do not have an existing cluster, the `awx-operator` can be deployed on a [Minikube](https://minikube.sigs.k8s.io/docs/) cluster for testing purposes. Due to different OS and hardware environments, please refer to the official Minikube documentation for further information. - -``` -$ minikube start --cpus=4 --memory=6g --addons=ingress -😄 minikube v1.23.2 on Fedora 34 -✨ Using the docker driver based on existing profile -👍 Starting control plane node minikube in cluster minikube -🚜 Pulling base image ... -🏃 Updating the running docker "minikube" container ... -🐳 Preparing Kubernetes v1.22.2 on Docker 20.10.8 ... -🔎 Verifying Kubernetes components... - ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 - ▪ Using image k8s.gcr.io/ingress-nginx/controller:v1.0.0-beta.3 - ▪ Using image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 - ▪ Using image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 -🔎 Verifying ingress addon... -🌟 Enabled addons: storage-provisioner, default-storageclass, ingress -🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default -``` - -Once Minikube is deployed, check if the node(s) and `kube-apiserver` communication is working as expected. - -``` -$ minikube kubectl -- get nodes -NAME STATUS ROLES AGE VERSION -minikube Ready control-plane,master 113s v1.22.2 - -$ minikube kubectl -- get pods -A -NAMESPACE NAME READY STATUS RESTARTS AGE -ingress-nginx ingress-nginx-admission-create--1-kk67h 0/1 Completed 0 2m1s -ingress-nginx ingress-nginx-admission-patch--1-7mp2r 0/1 Completed 1 2m1s -ingress-nginx ingress-nginx-controller-69bdbc4d57-bmwg8 1/1 Running 0 2m -kube-system coredns-78fcd69978-q7nmx 1/1 Running 0 2m -kube-system etcd-minikube 1/1 Running 0 2m12s -kube-system kube-apiserver-minikube 1/1 Running 0 2m16s -kube-system kube-controller-manager-minikube 1/1 Running 0 2m12s -kube-system kube-proxy-5mmnw 1/1 Running 0 2m1s -kube-system kube-scheduler-minikube 1/1 Running 0 2m15s -kube-system storage-provisioner 1/1 Running 0 2m11s -``` - -It is not required for `kubectl` to be separately installed since it comes already wrapped inside minikube. As demonstrated above, simply prefix `minikube kubectl --` before kubectl command, i.e. `kubectl get nodes` would become `minikube kubectl -- get nodes` - -Let's create an alias for easier usage: - -``` -$ alias kubectl="minikube kubectl --" -``` - -### Basic Install - -Once you have a running Kubernetes cluster, you can deploy AWX Operator into your cluster using [Kustomize](https://kubectl.docs.kubernetes.io/guides/introduction/kustomize/). Since kubectl version 1.14 kustomize functionality is built-in (otherwise, follow the instructions here to install the latest version of Kustomize: https://kubectl.docs.kubernetes.io/installation/kustomize/ ) - -There is a make target you can run: -``` -make deploy -``` - -If you have a custom operator image you have built, you can specify it with: -``` -IMG=quay.io/$YOURNAMESPACE/awx-operator:$YOURTAG make deploy -``` - -Otherwise, you can manually create a file called `kustomization.yaml` with the following content: - -```yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - # Find the latest tag here: https://github.com/ansible/awx-operator/releases - - github.com/ansible/awx-operator/config/default?ref= - -# Set the image tags to match the git version from above -images: - - name: quay.io/ansible/awx-operator - newTag: - -# Specify a custom namespace in which to install AWX -namespace: awx -``` - -> **TIP:** If you need to change any of the default settings for the operator (such as resources.limits), you can add [patches](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patches/) at the bottom of your kustomization.yaml file. - -Install the manifests by running this: - -``` -$ kubectl apply -k . -namespace/awx created -customresourcedefinition.apiextensions.k8s.io/awxbackups.awx.ansible.com created -customresourcedefinition.apiextensions.k8s.io/awxrestores.awx.ansible.com created -customresourcedefinition.apiextensions.k8s.io/awxs.awx.ansible.com created -serviceaccount/awx-operator-controller-manager created -role.rbac.authorization.k8s.io/awx-operator-awx-manager-role created -role.rbac.authorization.k8s.io/awx-operator-leader-election-role created -clusterrole.rbac.authorization.k8s.io/awx-operator-metrics-reader created -clusterrole.rbac.authorization.k8s.io/awx-operator-proxy-role created -rolebinding.rbac.authorization.k8s.io/awx-operator-awx-manager-rolebinding created -rolebinding.rbac.authorization.k8s.io/awx-operator-leader-election-rolebinding created -clusterrolebinding.rbac.authorization.k8s.io/awx-operator-proxy-rolebinding created -configmap/awx-operator-awx-manager-config created -service/awx-operator-controller-manager-metrics-service created -deployment.apps/awx-operator-controller-manager created -``` - -Wait a bit and you should have the `awx-operator` running: - -``` -$ kubectl get pods -n awx -NAME READY STATUS RESTARTS AGE -awx-operator-controller-manager-66ccd8f997-rhd4z 2/2 Running 0 11s -``` - -So we don't have to keep repeating `-n awx`, let's set the current namespace for `kubectl`: - -``` -$ kubectl config set-context --current --namespace=awx -``` - -Next, create a file named `awx-demo.yaml` in the same folder with the suggested content below. The `metadata.name` you provide will be the name of the resulting AWX deployment. - -**Note:** If you deploy more than one AWX instance to the same namespace, be sure to use unique names. - -```yaml ---- -apiVersion: awx.ansible.com/v1beta1 -kind: AWX -metadata: - name: awx-demo -spec: - service_type: nodeport -``` - -> 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). - -If you are on Openshift, you can take advantage of Routes by specifying the following your spec. This will automatically create a Route for you with a custom hostname. This can be found on the Route section of the Openshift Console. - -```yaml ---- -apiVersion: awx.ansible.com/v1beta1 -kind: AWX -metadata: - name: awx-demo -spec: - service_type: clusterip - ingress_type: Route -``` - - -Make sure to add this new file to the list of "resources" in your `kustomization.yaml` file: - -```yaml -... -resources: - - github.com/ansible/awx-operator/config/default?ref= - # Add this extra line: - - awx-demo.yaml -... -``` - -Finally, apply the changes to create the AWX instance in your cluster: - -``` -kubectl apply -k . -``` - -After a few minutes, the new AWX instance will be deployed. You can look at the operator pod logs in order to know where the installation process is at: - -``` -$ kubectl logs -f deployments/awx-operator-controller-manager -c awx-manager -``` - -After a few seconds, you should see the operator begin to create new resources: - -``` -$ kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator" -NAME READY STATUS RESTARTS AGE -awx-demo-77d96f88d5-pnhr8 4/4 Running 0 3m24s -awx-demo-postgres-0 1/1 Running 0 3m34s - -$ kubectl get svc -l "app.kubernetes.io/managed-by=awx-operator" -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -awx-demo-postgres ClusterIP None 5432/TCP 4m4s -awx-demo-service NodePort 10.109.40.38 80:31006/TCP 3m56s -``` - -Once deployed, the AWX instance will be accessible by running: - -``` -$ minikube service -n awx awx-demo-service --url -``` - -By default, the admin user is `admin` and the password is available in the `-admin-password` secret. To retrieve the admin password, run: - -``` -$ kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo -yDL2Cx5Za94g9MvBP6B73nzVLlmfgPjR -``` - -You just completed the most basic install of an AWX instance via this operator. Congratulations!!! - -For an example using the Nginx Ingress Controller in Minikube, don't miss our [demo video](https://asciinema.org/a/416946). - - -### Helm Install on existing cluster - -For those that wish to use [Helm](https://helm.sh/) to install the awx-operator to an existing K8s cluster: - -The helm chart is generated from the `helm-chart` Makefile section using the starter files in `.helm/starter`. Consult [the documentation](.helm/starter/README.md) on how to customize the AWX resource with your own values. - -```bash -$ helm repo add awx-operator https://ansible.github.io/awx-operator/ -"awx-operator" has been added to your repositories - -$ helm repo update -Hang tight while we grab the latest from your chart repositories... -...Successfully got an update from the "awx-operator" chart repository -Update Complete. ⎈Happy Helming!⎈ - -$ helm search repo awx-operator -NAME CHART VERSION APP VERSION DESCRIPTION -awx-operator/awx-operator 0.17.1 0.17.1 A Helm chart for the AWX Operator - -$ helm install -n awx --create-namespace my-awx-operator awx-operator/awx-operator -NAME: my-awx-operator -LAST DEPLOYED: Thu Feb 17 22:09:05 2022 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None -NOTES: -Helm Chart 0.17.1 -``` - -### Admin user account configuration - -There are three variables that are customizable for the admin user account creation. - -| Name | Description | Default | -| --------------------- | -------------------------------------------- | ---------------- | -| admin_user | Name of the admin user | admin | -| admin_email | Email of the admin user | test@example.com | -| admin_password_secret | Secret that contains the admin user password | Empty string | - - -> :warning: **admin_password_secret must be a Kubernetes secret and not your text clear password**. - -If `admin_password_secret` is not provided, the operator will look for a secret named `-admin-password` for the admin password. If it is not present, the operator will generate a password and create a Secret from it named `-admin-password`. - -To retrieve the admin password, run `kubectl get secret -admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo` - -The secret that is expected to be passed should be formatted as follow: - -```yaml ---- -apiVersion: v1 -kind: Secret -metadata: - name: -admin-password - namespace: -stringData: - password: mysuperlongpassword -``` - - -### Secret Key Configuration - -This key is used to encrypt sensitive data in the database. - -| Name | Description | Default | -| ----------------- | ----------------------------------------------------- | ---------------- | -| secret_key_secret | Secret that contains the symmetric key for encryption | Generated | - - -> :warning: **secret_key_secret must be a Kubernetes secret and not your text clear secret value**. - -If `secret_key_secret` is not provided, the operator will look for a secret named `-secret-key` for the secret key. If it is not present, the operator will generate a password and create a Secret from it named `-secret-key`. It is important to not delete this secret as it will be needed for upgrades and if the pods get scaled down at any point. If you are using a GitOps flow, you will want to pass a secret key secret. - -The secret should be formatted as follow: - -```yaml ---- -apiVersion: v1 -kind: Secret -metadata: - name: custom-awx-secret-key - namespace: -stringData: - secret_key: supersecuresecretkey -``` - -Then specify the secret name on the AWX spec: - -```yaml ---- -spec: - ... - secret_key_secret: custom-awx-secret-key -``` - -### Network and TLS Configuration - -#### Service Type - -If the `service_type` is not specified, the `ClusterIP` service will be used for your AWX Tower service. - -The `service_type` supported options are: `ClusterIP`, `LoadBalancer` and `NodePort`. - -The following variables are customizable for any `service_type` - -| Name | Description | Default | -| ------------------- | ----------------------- | ------------ | -| service_labels | Add custom labels | Empty string | -| service_annotations | Add service annotations | Empty string | - -```yaml ---- -spec: - ... - service_type: ClusterIP - service_annotations: | - environment: testing - service_labels: | - environment: testing -``` - - * LoadBalancer - -The following variables are customizable only when `service_type=LoadBalancer` - -| Name | Description | Default | -| --------------------- | ---------------------------------------- | ------- | -| loadbalancer_protocol | Protocol to use for Loadbalancer ingress | http | -| loadbalancer_port | Port used for Loadbalancer ingress | 80 | -| loadbalancer_ip | Assign Loadbalancer IP | '' | - -```yaml ---- -spec: - ... - service_type: LoadBalancer - loadbalancer_ip: '192.168.10.25' - loadbalancer_protocol: https - loadbalancer_port: 443 - service_annotations: | - environment: testing - service_labels: | - environment: testing -``` - -When setting up a Load Balancer for HTTPS you will be required to set the `loadbalancer_port` to move the port away from `80`. - -The HTTPS Load Balancer also uses SSL termination at the Load Balancer level and will offload traffic to AWX over HTTP. - - * NodePort - -The following variables are customizable only when `service_type=NodePort` - -| Name | Description | Default | -| ------------- | ---------------------- | ------- | -| nodeport_port | Port used for NodePort | 30080 | - -```yaml ---- -spec: - ... - service_type: NodePort - nodeport_port: 30080 -``` -#### Ingress Type - -By default, the AWX operator is not opinionated and won't force a specific ingress type on you. So, when the `ingress_type` is not specified, it will default to `none` and nothing ingress-wise will be created. - -The `ingress_type` supported options are: `none`, `ingress` and `route`. To toggle between these options, you can add the following to your AWX CRD: - - * None - -```yaml ---- -spec: - ... - ingress_type: none -``` - - * Generic Ingress Controller - -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 _(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 - ingress_hosts: - - hostname: awx-demo.example.com - - hostname: awx-demo.sample.com - tls_secret: sample-tls-secret - ingress_annotations: | - environment: testing -``` - -##### Specialized Ingress Controller configuration - -Some Ingress Controllers need a special configuration to fully support AWX, add the following value with the `ingress_controller` variable, if you are using one of these: - -| Ingress Controller name | value | -| ------------------------------------- | ------- | -| [Contour](https://projectcontour.io/) | contour | - -```yaml ---- -spec: - ... - ingress_type: ingress - ingress_hosts: - - hostname: awx-demo.example.com - - hostname: awx-demo.sample.com - tls_secret: sample-tls-secret - ingress_controller: contour -``` - - * Route - -The following variables are customizable when `ingress_type=route` - -| Name | Description | Default | -| ------------------------------- | --------------------------------------------- | ------------------------------------------------------- | -| route_host | Common name the route answers for | `--` | -| route_tls_termination_mechanism | TLS Termination mechanism (Edge, Passthrough) | Edge | -| route_tls_secret | Secret that contains the TLS information | Empty string | -| route_api_version | Define the Route resource apiVersion | 'route.openshift.io/v1' | - -```yaml ---- -spec: - ... - ingress_type: route - route_host: awx-demo.example.com - route_tls_termination_mechanism: Passthrough - route_tls_secret: custom-route-tls-secret-name -``` - -### Database Configuration - -#### Postgres Version - -The default Postgres version for the version of AWX bundled with the latest version of the awx-operator is Postgres 13. You can find this default for a given version by at the default value for [_postgres_image_version](./roles/installer/defaults/main.yml#L138). - -We only have coverage for the default version of Postgres. Newer versions of Postgres (14+) will likely work, but should only be configured as an external database. If your database is managed by the awx-operator (default if you don't specify a `postgres_configuration_secret`), then you should not override the default version as this may cause issues when awx-operator tries to upgrade your postgresql pod. - -#### External PostgreSQL Service - -To configure AWX to use an external database, the Custom Resource needs to know about the connection details. To do this, create a k8s secret with those connection details and specify the name of the secret as `postgres_configuration_secret` at the CR spec level. - - -The secret should be formatted as follows: - -```yaml ---- -apiVersion: v1 -kind: Secret -metadata: - name: -postgres-configuration - namespace: -stringData: - host: - port: - database: - username: - password: - sslmode: prefer - type: unmanaged -type: Opaque -``` - -> Please ensure that the value for the variable `password` should _not_ contain single or double quotes (`'`, `"`) or backslashes (`\`) to avoid any issues during deployment, [backup](https://github.com/ansible/awx-operator/tree/devel/roles/backup) or [restoration](https://github.com/ansible/awx-operator/tree/devel/roles/restore). - -> It is possible to set a specific username, password, port, or database, but still have the database managed by the operator. In this case, when creating the postgres-configuration secret, the `type: managed` field should be added. - -**Note**: The variable `sslmode` is valid for `external` databases only. The allowed values are: `prefer`, `disable`, `allow`, `require`, `verify-ca`, `verify-full`. - -Once the secret is created, you can specify it on your spec: - -```yaml ---- -spec: - ... - postgres_configuration_secret: -``` - -#### Migrating data from an old AWX instance - -For instructions on how to migrate from an older version of AWX, see [migration.md](./docs/migration.md). - -#### Managed PostgreSQL Service - -If you don't have access to an external PostgreSQL service, the AWX operator can deploy one for you along side the AWX instance itself. - -The following variables are customizable for the managed PostgreSQL service - -| Name | Description | Default | -| --------------------------------------------- | --------------------------------------------- | ---------------------------------- | -| postgres_image | Path of the image to pull | postgres:12 | -| postgres_init_container_resource_requirements | Database init container resource requirements | requests: {cpu: 10m, memory: 64Mi} | -| postgres_resource_requirements | PostgreSQL container resource requirements | requests: {cpu: 10m, memory: 64Mi} | -| postgres_storage_requirements | PostgreSQL container storage requirements | requests: {storage: 8Gi} | -| postgres_storage_class | PostgreSQL PV storage class | Empty string | -| postgres_data_path | PostgreSQL data path | `/var/lib/postgresql/data/pgdata` | -| postgres_priority_class | Priority class used for PostgreSQL pod | Empty string | - -Example of customization could be: - -```yaml ---- -spec: - ... - postgres_resource_requirements: - requests: - cpu: 500m - memory: 2Gi - limits: - cpu: '1' - memory: 4Gi - postgres_storage_requirements: - requests: - storage: 8Gi - limits: - storage: 50Gi - postgres_storage_class: fast-ssd - postgres_extra_args: - - '-c' - - 'max_connections=1000' -``` - -**Note**: If `postgres_storage_class` is not defined, Postgres will store it's data on a volume using the default storage class for your cluster. - -### Advanced Configuration - -#### Deploying a specific version of AWX - -There are a few variables that are customizable for awx the image management. - -| Name | Description | Default | -| ------------------- | ------------------------- | -------------------------------------- | -| image | Path of the image to pull | quay.io/ansible/awx | -| image_version | Image version to pull | value of DEFAULT_AWX_VERSION or latest | -| image_pull_policy | The pull policy to adopt | IfNotPresent | -| image_pull_secrets | The pull secrets to use | None | -| ee_images | A list of EEs to register | quay.io/ansible/awx-ee:latest | -| redis_image | Path of the image to pull | docker.io/redis | -| redis_image_version | Image version to pull | latest | - -Example of customization could be: - -```yaml ---- -spec: - ... - image: myorg/my-custom-awx - image_version: latest - image_pull_policy: Always - image_pull_secrets: - - pull_secret_name - ee_images: - - name: my-custom-awx-ee - image: myorg/my-custom-awx-ee -``` - -**Note**: The `image` and `image_version` are intended for local mirroring scenarios. Please note that using a version of AWX other than the one bundled with the `awx-operator` is **not** supported. For the default values, check the [main.yml](https://github.com/ansible/awx-operator/blob/devel/roles/installer/defaults/main.yml) file. - -#### Redis container capabilities - -Depending on your kubernetes cluster and settings you might need to grant some capabilities to the redis container so it can start. Set the `redis_capabilities` option so the capabilities are added in the deployment. - -```yaml ---- -spec: - ... - redis_capabilities: - - CHOWN - - SETUID - - SETGID -``` - -#### Privileged Tasks - -Depending on the type of tasks that you'll be running, you may find that you need the task pod to run as `privileged`. This can open yourself up to a variety of security concerns, so you should be aware (and verify that you have the privileges) to do this if necessary. In order to toggle this feature, you can add the following to your custom resource: - -```yaml ---- -spec: - ... - task_privileged: true -``` - -If you are attempting to do this on an OpenShift cluster, you will need to grant the `awx` ServiceAccount the `privileged` SCC, which can be done with: - -``` -$ 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](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/) 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 - -The resource requirements for both, the task and the web containers are configurable - both the lower end (requests) and the upper end (limits). - -| Name | Description | Default | -| -------------------------- | ------------------------------------------------ | ------------------------------------ | -| web_resource_requirements | Web container resource requirements | requests: {cpu: 100m, memory: 128Mi} | -| task_resource_requirements | Task container resource requirements | requests: {cpu: 100m, memory: 128Mi} | -| ee_resource_requirements | EE control plane container resource requirements | requests: {cpu: 100m, memory: 128Mi} | - -Example of customization could be: - -```yaml ---- -spec: - ... - web_resource_requirements: - requests: - cpu: 250m - memory: 2Gi - ephemeral-storage: 100M - limits: - cpu: 1000m - memory: 4Gi - ephemeral-storage: 500M - task_resource_requirements: - requests: - cpu: 250m - memory: 1Gi - ephemeral-storage: 100M - limits: - cpu: 2000m - memory: 2Gi - ephemeral-storage: 500M - ee_resource_requirements: - requests: - cpu: 250m - memory: 100Mi - ephemeral-storage: 100M - limits: - cpu: 500m - memory: 2Gi - ephemeral-storage: 500M -``` - -#### Priority Classes - -The AWX and Postgres pods can be assigned a custom PriorityClass to rank their importance compared to other pods in your cluster, which determines which pods get evicted first if resources are running low. -First, [create your PriorityClass](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) if needed. -Then set the name of your priority class to the control plane and postgres pods as shown below. - -```yaml ---- -apiVersion: awx.ansible.com/v1beta1 -kind: AWX -metadata: - name: awx-demo -spec: - ... - control_plane_priority_class: awx-demo-high-priority - postgres_priority_class: awx-demo-medium-priority -``` -#### Scaling the Web and Task Pods independently - -You can scale replicas up or down for each deployment by using the `web_replicas` or `task_replicas` respectively. You can scale all pods across both deployments by using `replicas` as well. The logic behind these CRD keys acts as such: - -- If you specify the `replicas` field, the key passed will scale both the `web` and `task` replicas to the same number. -- If `web_replicas` or `task_replicas` is ever passed, it will override the existing `replicas` field on the specific deployment with the new key value. - -These new replicas can be constrained in a similar manner to previous single deployments by appending the particular deployment name in front of the constraint used. More about those new constraints can be found below in the [Assigning AWX pods to specific nodes](#assigning-awx-pods-to-specific-nodes) section. -#### Assigning AWX pods to specific nodes - -You can constrain the AWX pods created by the operator to run on a certain subset of nodes. `node_selector` and `postgres_selector` constrains -the AWX pods to run only on the nodes that match all the specified key/value pairs. `tolerations` and `postgres_tolerations` allow the AWX -pods to be scheduled onto nodes with matching taints. -The ability to specify topologySpreadConstraints is also allowed through `topology_spread_constraints` -If you want to use affinity rules for your AWX pod you can use the `affinity` option. - -If you want to constrain the web and task pods individually, you can do so by specificying the deployment type before the specific setting. For -example, specifying `task_tolerations` will allow the AWX task pod to be scheduled onto nodes with matching taints. - -| Name | Description | Default | -| -------------------------------- | ---------------------------------------- | ------- | -| postgres_image | Path of the image to pull | postgres | -| postgres_image_version | Image version to pull | 13 | -| node_selector | AWX pods' nodeSelector | '' | -| web_node_selector | AWX web pods' nodeSelector | '' | -| task_node_selector | AWX task pods' nodeSelector | '' | -| topology_spread_constraints | AWX pods' topologySpreadConstraints | '' | -| web_topology_spread_constraints | AWX web pods' topologySpreadConstraints | '' | -| task_topology_spread_constraints | AWX task pods' topologySpreadConstraints | '' | -| affinity | AWX pods' affinity rules | '' | -| web_affinity | AWX web pods' affinity rules | '' | -| task_affinity | AWX task pods' affinity rules | '' | -| tolerations | AWX pods' tolerations | '' | -| web_tolerations | AWX web pods' tolerations | '' | -| task_tolerations | AWX task pods' tolerations | '' | -| annotations | AWX pods' annotations | '' | -| postgres_selector | Postgres pods' nodeSelector | '' | -| postgres_tolerations | Postgres pods' tolerations | '' | - -Example of customization could be: - -```yaml ---- -spec: - ... - node_selector: | - disktype: ssd - kubernetes.io/arch: amd64 - kubernetes.io/os: linux - topology_spread_constraints: | - - maxSkew: 100 - topologyKey: "topology.kubernetes.io/zone" - whenUnsatisfiable: "ScheduleAnyway" - labelSelector: - matchLabels: - app.kubernetes.io/name: "" - tolerations: | - - key: "dedicated" - operator: "Equal" - value: "AWX" - effect: "NoSchedule" - task_tolerations: | - - key: "dedicated" - operator: "Equal" - value: "AWX_task" - effect: "NoSchedule" - postgres_selector: | - disktype: ssd - kubernetes.io/arch: amd64 - kubernetes.io/os: linux - postgres_tolerations: | - - key: "dedicated" - operator: "Equal" - value: "AWX" - effect: "NoSchedule" - affinity: - nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - preference: - matchExpressions: - - key: another-node-label-key - operator: In - values: - - another-node-label-value - - another-node-label-value - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 - podAffinityTerm: - labelSelector: - matchExpressions: - - key: security - operator: In - values: - - S2 - topologyKey: topology.kubernetes.io/zone -``` - -#### Trusting a Custom Certificate Authority - -In cases which you need to trust a custom Certificate Authority, there are few variables you can customize for the `awx-operator`. - -Trusting a custom Certificate Authority allows the AWX to access network services configured with SSL certificates issued locally, such as cloning a project from from an internal Git server via HTTPS. It is common for these scenarios, experiencing the error [unable to verify the first certificate](https://github.com/ansible/awx-operator/issues/376). - - -| Name | Description | Default | -| -------------------------------- | ---------------------------------------- | --------| -| ldap_cacert_secret | LDAP Certificate Authority secret name | '' | -| ldap_password_secret | LDAP BIND DN Password secret name | '' | -| bundle_cacert_secret | Certificate Authority secret name | '' | -Please note the `awx-operator` will look for the data field `ldap-ca.crt` in the specified secret when using the `ldap_cacert_secret`, whereas the data field `bundle-ca.crt` is required for `bundle_cacert_secret` parameter. - -Example of customization could be: - -```yaml ---- -spec: - ... - ldap_cacert_secret: -custom-certs - ldap_password_secret: -ldap-password - bundle_cacert_secret: -custom-certs -``` - -Create the secret with `kustomization.yaml` file: - -```yaml -.... - -secretGenerator: - - name: -custom-certs - files: - - bundle-ca.crt= - options: - disableNameSuffixHash: true - -... -``` - -Create the secret with CLI: - -* Certificate Authority secret - -``` -# kubectl create secret generic -custom-certs \ - --from-file=ldap-ca.crt= \ - --from-file=bundle-ca.crt= -``` - -* LDAP BIND DN Password secret - -``` -# kubectl create secret generic -ldap-password \ - --from-literal=ldap-password= -``` - -#### Enabling LDAP Integration at AWX bootstrap - -A sample of extra settings can be found as below. All possible options can be found here: https://django-auth-ldap.readthedocs.io/en/latest/reference.html#settings - -> **NOTE:** These values are inserted into a Python file, so pay close attention to which values need quotes and which do not. - -```yaml - - setting: AUTH_LDAP_SERVER_URI - value: >- - "ldaps://ad01.abc.com:636 ldaps://ad02.abc.com:636" - - - setting: AUTH_LDAP_BIND_DN - value: >- - "CN=LDAP User,OU=Service Accounts,DC=abc,DC=com" - - - setting: AUTH_LDAP_USER_SEARCH - value: 'LDAPSearch("DC=abc,DC=com",ldap.SCOPE_SUBTREE,"(sAMAccountName=%(user)s)",)' - - - setting: AUTH_LDAP_GROUP_SEARCH - value: 'LDAPSearch("OU=Groups,DC=abc,DC=com",ldap.SCOPE_SUBTREE,"(objectClass=group)",)' - - - setting: AUTH_LDAP_GROUP_TYPE - value: 'GroupOfNamesType()' - - - setting: AUTH_LDAP_USER_ATTR_MAP - value: '{"first_name": "givenName","last_name": "sn","email": "mail"}' - - - setting: AUTH_LDAP_REQUIRE_GROUP - value: >- - "CN=operators,OU=Groups,DC=abc,DC=com" - - setting: AUTH_LDAP_USER_FLAGS_BY_GROUP - value: { - "is_superuser": [ - "CN=admin,OU=Groups,DC=abc,DC=com" - ] - } - - - - setting: AUTH_LDAP_ORGANIZATION_MAP - value: { - "abc": { - "admins": "CN=admin,OU=Groups,DC=abc,DC=com", - "remove_users": false, - "remove_admins": false, - "users": true - } - } - - - setting: AUTH_LDAP_TEAM_MAP - value: { - "admin": { - "remove": true, - "users": "CN=admin,OU=Groups,DC=abc,DC=com", - "organization": "abc" - } - } -``` - -#### Persisting Projects Directory - -In cases which you want to persist the `/var/lib/projects` directory, there are few variables that are customizable for the `awx-operator`. - -| Name | Description | Default | -| ---------------------------- | ---------------------------------------------------------------------------------------------- | ------------- | -| projects_persistence | Whether or not the /var/lib/projects directory will be persistent | false | -| projects_storage_class | Define the PersistentVolume storage class | '' | -| projects_storage_size | Define the PersistentVolume size | 8Gi | -| projects_storage_access_mode | Define the PersistentVolume access mode | ReadWriteMany | -| projects_existing_claim | Define an existing PersistentVolumeClaim to use (cannot be combined with `projects_storage_*`) | '' | - -Example of customization when the `awx-operator` automatically handles the persistent volume could be: - -```yaml ---- -spec: - ... - projects_persistence: true - projects_storage_class: rook-ceph - projects_storage_size: 20Gi -``` - -#### Custom Volume and Volume Mount Options - -In a scenario where custom volumes and volume mounts are required to either overwrite defaults or mount configuration files. - -| Name | Description | Default | -| ---------------------------------- | -------------------------------------------------------- | ------- | -| extra_volumes | Specify extra volumes to add to the application pod | '' | -| web_extra_volume_mounts | Specify volume mounts to be added to Web container | '' | -| task_extra_volume_mounts | Specify volume mounts to be added to Task container | '' | -| rsyslog_extra_volume_mounts | Specify volume mounts to be added to Rsyslog container | '' | -| ee_extra_volume_mounts | Specify volume mounts to be added to Execution container | '' | -| init_container_extra_volume_mounts | Specify volume mounts to be added to Init container | '' | -| init_container_extra_commands | Specify additional commands for Init container | '' | - - -> :warning: The `ee_extra_volume_mounts` and `extra_volumes` will only take effect to the globally available Execution Environments. For custom `ee`, please [customize the Pod spec](https://docs.ansible.com/ansible-tower/latest/html/administration/external_execution_envs.html#customize-the-pod-spec). - -Example configuration for ConfigMap - -```yaml ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: -extra-config - namespace: -data: - ansible.cfg: | - [defaults] - remote_tmp = /tmp - [ssh_connection] - ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s - custom.py: | - INSIGHTS_URL_BASE = "example.org" - AWX_CLEANUP_PATHS = True -``` -Example spec file for volumes and volume mounts - -```yaml ---- - spec: - ... - extra_volumes: | - - name: ansible-cfg - configMap: - defaultMode: 420 - items: - - key: ansible.cfg - path: ansible.cfg - name: -extra-config - - name: custom-py - configMap: - defaultMode: 420 - items: - - key: custom.py - path: custom.py - name: -extra-config - - name: shared-volume - persistentVolumeClaim: - claimName: my-external-volume-claim - - init_container_extra_volume_mounts: | - - name: shared-volume - mountPath: /shared - - init_container_extra_commands: | - # set proper permissions (rwx) for the awx user - chmod 775 /shared - chgrp 1000 /shared - - ee_extra_volume_mounts: | - - name: ansible-cfg - mountPath: /etc/ansible/ansible.cfg - subPath: ansible.cfg - - task_extra_volume_mounts: | - - name: custom-py - mountPath: /etc/tower/conf.d/custom.py - subPath: custom.py - - name: shared-volume - mountPath: /shared -``` - -> :warning: **Volume and VolumeMount names cannot contain underscores(_)** - -##### Custom Nginx Configuration - -Using the [extra_volumes feature](#custom-volume-and-volume-mount-options), it is possible to extend the nginx.conf. - -1. Create a ConfigMap with the extra settings you want to include in the nginx.conf -2. Create an extra_volumes entry in the AWX spec for this ConfigMap -3. Create an web_extra_volume_mounts entry in the AWX spec to mount this volume - -The AWX nginx config automatically includes /etc/nginx/conf.d/*.conf if present. - -##### Custom Favicon - -You can use custom volume mounts to mount in your own favicon to be displayed in your AWX browser tab. - -First, Create the configmap from a local favicon.ico file. - -```bash -$ oc create configmap favicon-configmap --from-file favicon.ico -``` - -Then specify the extra_volume and web_extra_volume_mounts on your AWX CR spec - -```yaml -spec: - extra_volumes: | - - name: favicon - configMap: - defaultMode: 420 - items: - - key: favicon.ico - path: favicon.ico - name: favicon-configmap - web_extra_volume_mounts: | - - name: favicon - mountPath: /var/lib/awx/public/static/media/favicon.ico - subPath: favicon.ico -``` - -#### Default execution environments from private registries - -In order to register default execution environments from private registries, the Custom Resource needs to know about the pull credentials. Those credentials should be stored as a secret and either specified as `ee_pull_credentials_secret` at the CR spec level, or simply be present on the namespace under the name `-ee-pull-credentials` . Instance initialization will register a `Container registry` type credential on the deployed instance and assign it to the registered default execution environments. - -The secret should be formatted as follows: - -```yaml ---- -apiVersion: v1 -kind: Secret -metadata: - name: -ee-pull-credentials - namespace: -stringData: - url: - username: - password: - ssl_verify: -type: Opaque -``` - -##### Control plane ee from private registry -The images listed in "ee_images" will be added as globally available Execution Environments. The "control_plane_ee_image" will be used to run project updates. In order to use a private image for any of these you'll need to use `image_pull_secrets` to provide a list of k8s pull secrets to access it. Currently the same secret is used for any of these images supplied at install time. - -You can create `image_pull_secret` -``` -kubectl create secret -cp-pull-credentials regcred --docker-server= --docker-username= --docker-password= --docker-email= -``` -If you need more control (for example, to set a namespace or a label on the new secret) then you can customize the Secret before storing it - -Example spec file extra-config - -```yaml ---- -apiVersion: v1 -kind: Secret -metadata: - name: -cp-pull-credentials - namespace: -data: - .dockerconfigjson: -type: kubernetes.io/dockerconfigjson -``` - -#### Exporting Environment Variables to Containers - -If you need to export custom environment variables to your containers. - -| Name | Description | Default | -| ----------------- | ------------------------------------------------------ | ------- | -| task_extra_env | Environment variables to be added to Task container | '' | -| web_extra_env | Environment variables to be added to Web container | '' | -| rsyslog_extra_env | Environment variables to be added to Rsyslog container | '' | -| ee_extra_env | Environment variables to be added to EE container | '' | - -> :warning: The `ee_extra_env` will only take effect to the globally available Execution Environments. For custom `ee`, please [customize the Pod spec](https://docs.ansible.com/ansible-tower/latest/html/administration/external_execution_envs.html#customize-the-pod-spec). - -Example configuration of environment variables - -```yaml - spec: - task_extra_env: | - - name: MYCUSTOMVAR - value: foo - web_extra_env: | - - name: MYCUSTOMVAR - value: foo - rsyslog_extra_env: | - - name: MYCUSTOMVAR - value: foo - ee_extra_env: | - - name: MYCUSTOMVAR - value: foo -``` - -#### CSRF Cookie Secure Setting - -With `csrf_cookie_secure`, you can pass the value for `CSRF_COOKIE_SECURE` to `/etc/tower/settings.py` - -| Name | Description | Default | -| ------------------ | ------------------ | ------- | -| csrf_cookie_secure | CSRF Cookie Secure | '' | - -Example configuration of the `csrf_cookie_secure` setting: - -```yaml - spec: - csrf_cookie_secure: 'False' -``` - -#### Session Cookie Secure Setting - -With `session_cookie_secure`, you can pass the value for `SESSION_COOKIE_SECURE` to `/etc/tower/settings.py` - -| Name | Description | Default | -| --------------------- | --------------------- | ------- | -| session_cookie_secure | Session Cookie Secure | '' | - -Example configuration of the `session_cookie_secure` setting: - -```yaml - spec: - session_cookie_secure: 'False' -``` - -#### Extra Settings - -With`extra_settings`, you can pass multiple custom settings via the `awx-operator`. The parameter `extra_settings` will be appended to the `/etc/tower/settings.py` and can be an alternative to the `extra_volumes` parameter. - -| Name | Description | Default | -| -------------- | -------------- | ------- | -| extra_settings | Extra settings | '' | - -**Note:** Parameters configured in `extra_settings` are set as read-only settings in AWX. As a result, they cannot be changed in the UI after deployment. If you need to change the setting after the initial deployment, you need to change it on the AWX CR spec. - -Example configuration of `extra_settings` parameter - -```yaml - spec: - extra_settings: - - setting: MAX_PAGE_SIZE - value: "500" - - - setting: AUTH_LDAP_BIND_DN - value: "cn=admin,dc=example,dc=com" - - - setting: LOG_AGGREGATOR_LEVEL - value: "'DEBUG'" -``` - -Note for some settings, such as `LOG_AGGREGATOR_LEVEL`, the value may need double quotes. - - -#### No Log -Configure no_log for tasks with no_log - -| Name | Description | Default | -| ------ | -------------------- | ------- | -| no_log | No log configuration | 'true' | - -Example configuration of `no_log` parameter - -```yaml - spec: - no_log: true -``` - -#### Auto upgrade -With this parameter you can influence the behavior during an operator upgrade. -If set to `true`, the operator will upgrade the specific instance directly. -When the value is set to `false`, and we have a running deployment, the operator will not update the AWX instance. -This can be useful when you have multiple AWX instances which you want to upgrade step by step instead of all at once. - - -| Name | Description | Default | -| -------------| ---------------------------------- | ------- | -| auto_upgrade | Automatic upgrade of AWX instances | true | - -Example configuration of `auto_upgrade` parameter - -```yaml - spec: - auto_upgrade: true -``` - -##### Upgrade of instances without auto upgrade - -There are two ways to upgrade instances which are marked with the 'auto_upgrade: false' flag. - -Changing flags: - -- change the auto_upgrade flag on your AWX object to true -- wait until the upgrade process of that instance is finished -- change the auto_upgrade flag on your AWX object back to false - -Delete the deployment: - -- delete the deployment object of your AWX instance -``` -$ kubectl -n awx delete deployment -``` -- wait until the instance gets redeployed - - -#### Service Account - -If you need to modify some `ServiceAccount` proprieties - -| Name | Description | Default | -| --------------------------- | --------------------------------- | ------- | -| service_account_annotations | Annotations to the ServiceAccount | '' | - -Example configuration of environment variables - -```yaml - spec: - service_account_annotations: | - eks.amazonaws.com/role-arn: arn:aws:iam:::role/ -``` - -#### Labeling operator managed objects - -In certain situations labeling of Kubernetes objects managed by the operator -might be desired (e.g. for owner identification purposes). For that -`additional_labels` parameter could be used - -| Name | Description | Default | -| --------------------------- | ---------------------------------------------------------------------------------------- | ------- | -| additional_labels | Additional labels defined on the resource, which should be propagated to child resources | [] | - -Example configuration where only `my/team` and `my/service` labels will be -propagated to child objects (`Deployment`, `Secret`s, `ServiceAccount`, etc): - -```yaml -apiVersion: awx.ansible.com/v1beta1 -kind: AWX -metadata: - name: awx-demo - labels: - my/team: "foo" - my/service: "bar" - my/do-not-inherit: "yes" -spec: - additional_labels: - - my/team - - my/service -... -``` - -#### Pods termination grace period - -During deployment restarts or new rollouts, when old ReplicaSet Pods are being -terminated, the corresponding jobs which are managed (executed or controlled) -by old AWX Pods may end up in `Error` state as there is no mechanism to -transfer them to the newly spawned AWX Pods. To work around the problem one -could set `termination_grace_period_seconds` in AWX spec, which does the -following: - -* It sets the corresponding - [`terminationGracePeriodSeconds`](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination) - Pod spec of the AWX Deployment to the value provided - - > The grace period is the duration in seconds after the processes running in - > the pod are sent a termination signal and the time when the processes are - > forcibly halted with a kill signal - -* It adds a - [`PreStop`](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#hook-handler-execution) - hook script, which will keep AWX Pods in terminating state until it finished, - up to `terminationGracePeriodSeconds`. - - > This grace period applies to the total time it takes for both the PreStop - > hook to execute and for the Container to stop normally - - While the hook script just waits until the corresponding AWX Pod (instance) - no longer has any managed jobs, in which case it finishes with success and - hands over the overall Pod termination process to normal AWX processes. - -One may want to set this value to the maximum duration they accept to wait for -the affected Jobs to finish. Keeping in mind that such finishing jobs may -increase Pods termination time in such situations as `kubectl rollout restart`, -AWX upgrade by the operator, or Kubernetes [API-initiated -evictions](https://kubernetes.io/docs/concepts/scheduling-eviction/api-eviction/). - - -| Name | Description | Default | -| -------------------------------- | --------------------------------------------------------------- | ------- | -| termination_grace_period_seconds | Optional duration in seconds pods needs to terminate gracefully | not set | - -### Uninstall ### - -To uninstall an AWX deployment instance, you basically need to remove the AWX kind related to that instance. For example, to delete an AWX instance named awx-demo, you would do: - -``` -$ kubectl delete awx awx-demo -awx.awx.ansible.com "awx-demo" deleted -``` - -Deleting an AWX instance will remove all related deployments and statefulsets, however, persistent volumes and secrets will remain. To enforce secrets also getting removed, you can use `garbage_collect_secrets: true`. - -**Note**: If you ever intend to recover an AWX from an existing database you will need a copy of the secrets in order to perform a successful recovery. - -### Upgrading - -To upgrade AWX, it is recommended to upgrade the awx-operator to the version that maps to the desired version of AWX. To find the version of AWX that will be installed by the awx-operator by default, check the version specified in the `image_version` variable in `roles/installer/defaults/main.yml` for that particular release. - -Apply the awx-operator.yml for that release to upgrade the operator, and in turn also upgrade your AWX deployment. - -#### Backup - -The first part of any upgrade should be a backup. Note, there are secrets in the pod which work in conjunction with the database. Having just a database backup without the required secrets will not be sufficient for recovering from an issue when upgrading to a new version. See the [backup role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/backup) for information on how to backup your database and secrets. - -In the event you need to recover the backup see the [restore role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/restore). *Before Restoring from a backup*, be sure to: -* delete the old existing AWX CR -* delete the persistent volume claim (PVC) for the database from the old deployment, which has a name like `postgres-13--postgres-13-0` - -**Note**: Do not delete the namespace/project, as that will delete the backup and the backup's PVC as well. - - -#### PostgreSQL Upgrade Considerations - -If there is a PostgreSQL major version upgrade, after the data directory on the PVC is migrated to the new version, the old PVC is kept by default. -This provides the ability to roll back if needed, but can take up extra storage space in your cluster unnecessarily. You can configure it to be deleted automatically -after a successful upgrade by setting the following variable on the AWX spec. - - -```yaml - spec: - postgres_keep_pvc_after_upgrade: False -``` - - -#### v0.14.0 - -##### Cluster-scope to Namespace-scope considerations - -Starting with awx-operator 0.14.0, AWX can only be deployed in the namespace that the operator exists in. This is called a namespace-scoped operator. If you are upgrading from an earlier version, you will want to -delete your existing `awx-operator` service account, role and role binding. - -##### Project is now based on v1.x of the operator-sdk project - -Starting with awx-operator 0.14.0, the project is now based on operator-sdk 1.x. You may need to manually delete your old operator Deployment to avoid issues. - -##### Steps to upgrade - -Delete your old AWX Operator and existing `awx-operator` service account, role and role binding in `default` namespace first: - -``` -$ kubectl -n default delete deployment awx-operator -$ kubectl -n default delete serviceaccount awx-operator -$ kubectl -n default delete clusterrolebinding awx-operator -$ kubectl -n default delete clusterrole awx-operator -``` - -Then install the new AWX Operator by following the instructions in [Basic Install](#basic-install-on-existing-cluster). The `NAMESPACE` environment variable have to be the name of the namespace in which your old AWX instance resides. - -Once the new AWX Operator is up and running, your AWX deployment will also be upgraded. ### Disable IPV6 Starting with AWX Operator release 0.24.0,[IPV6 was enabled in ngnix configuration](https://github.com/ansible/awx-operator/pull/950) which causes diff --git a/docs/user-guide/network-and-tls-configuration.md b/docs/user-guide/network-and-tls-configuration.md index 73b851bad..0eaa0a005 100644 --- a/docs/user-guide/network-and-tls-configuration.md +++ b/docs/user-guide/network-and-tls-configuration.md @@ -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 --- @@ -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 ``` @@ -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 ``` From 2331bbc7cb094c0dad1464aa0c5374da62fea8f5 Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Mon, 31 Jul 2023 16:23:57 +0700 Subject: [PATCH 6/8] fix ingress_hosts tls_secret key being optional --- roles/installer/templates/networking/ingress.yaml.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/installer/templates/networking/ingress.yaml.j2 b/roles/installer/templates/networking/ingress.yaml.j2 index 649517f6b..8c8864eab 100644 --- a/roles/installer/templates/networking/ingress.yaml.j2 +++ b/roles/installer/templates/networking/ingress.yaml.j2 @@ -74,11 +74,13 @@ spec: {% endif %} {% endfor %} tls: -{%- for item in ingress_hosts if item.tls_secret %} +{% for item in ingress_hosts %} +{% if 'tls_secret' in item %} - hosts: - {{ item.hostname }} secretName: {{ item.tls_secret }} -{%- endfor %} +{% endif %} +{% endfor %} {% endif %} {% endif %} From c912d16bcc78e1adfa70baebef05d0ef5328228d Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Thu, 26 Oct 2023 08:58:35 +0700 Subject: [PATCH 7/8] remove fieldDependency:ingress_type:Ingress for Ingress Hosts --- config/manifests/bases/awx-operator.clusterserviceversion.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index 85bf21058..43c984c9c 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -308,7 +308,6 @@ spec: 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 - displayName: Ingress Controller path: ingress_controller x-descriptors: From 72ff0730014bc7906fc6087e833eb42d87569f6d Mon Sep 17 00:00:00 2001 From: Guillaume Lefevre Date: Fri, 5 Jan 2024 17:36:52 +0700 Subject: [PATCH 8/8] fix scenario when neither hostname or ingress_hosts is defined --- roles/installer/templates/networking/ingress.yaml.j2 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/installer/templates/networking/ingress.yaml.j2 b/roles/installer/templates/networking/ingress.yaml.j2 index 8c8864eab..d252e5066 100644 --- a/roles/installer/templates/networking/ingress.yaml.j2 +++ b/roles/installer/templates/networking/ingress.yaml.j2 @@ -24,9 +24,8 @@ spec: ingressClassName: '{{ ingress_class_name }}' {% endif %} rules: -{% if hostname and (not ingress_hosts) %} - - host: {{ hostname }} - http: +{% if not ingress_hosts %} + - http: paths: - path: '{{ ingress_path }}' pathType: '{{ ingress_path_type }}' @@ -35,6 +34,9 @@ spec: name: '{{ ansible_operator_meta.name }}-service' port: number: 80 +{% if hostname %} + host: {{ hostname }} +{% endif %} {% if ingress_controller|lower == "contour" %} - path: '{{ ingress_path.rstrip("/") }}/websocket' pathType: '{{ ingress_path_type }}'