mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-26 21:33:14 +00:00
This allows for doing stuff like this on the custom resource: ``` security_context_settings: runAsUser: 1000 runAsGroup: 0 ``` I added `snakeCaseParameters: False` because without it, variables like `runAsUser` become `run_as_user`... and that doesnt work.
422 lines
16 KiB
Django/Jinja
422 lines
16 KiB
Django/Jinja
# AWX Deployment.
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: '{{ ansible_operator_meta.name }}'
|
|
namespace: '{{ ansible_operator_meta.namespace }}'
|
|
labels:
|
|
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
|
app.kubernetes.io/version: '{{ _image_version }}'
|
|
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
|
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
|
app.kubernetes.io/component: '{{ deployment_type }}'
|
|
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
|
spec:
|
|
replicas: {{ replicas }}
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
|
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
|
app.kubernetes.io/component: '{{ deployment_type }}'
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
|
app.kubernetes.io/version: '{{ _image_version }}'
|
|
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
|
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
|
app.kubernetes.io/component: '{{ deployment_type }}'
|
|
spec:
|
|
serviceAccountName: '{{ ansible_operator_meta.name }}'
|
|
{% if image_pull_secret %}
|
|
imagePullSecrets:
|
|
- name: {{ image_pull_secret }}
|
|
{% endif %}
|
|
{% if bundle_ca_crt or projects_persistence|bool or init_container_extra_commands %}
|
|
initContainers:
|
|
- name: init
|
|
image: '{{ _init_container_image }}'
|
|
imagePullPolicy: '{{ image_pull_policy }}'
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
{% if bundle_ca_crt %}
|
|
mkdir -p /etc/pki/ca-trust/extracted/{java,pem,openssl,edk2}
|
|
update-ca-trust
|
|
{% endif %}
|
|
{% if projects_persistence|bool %}
|
|
chmod 775 /var/lib/awx/projects
|
|
chgrp 1000 /var/lib/awx/projects
|
|
{% endif %}
|
|
{% if init_container_extra_commands %}
|
|
{{ init_container_extra_commands | indent(width=14) }}
|
|
{% endif %}
|
|
volumeMounts:
|
|
{% if bundle_ca_crt %}
|
|
- name: "ca-trust-extracted"
|
|
mountPath: "/etc/pki/ca-trust/extracted"
|
|
- name: "{{ ansible_operator_meta.name }}-bundle-cacert"
|
|
mountPath: /etc/pki/ca-trust/source/anchors/bundle-ca.crt
|
|
subPath: bundle-ca.crt
|
|
readOnly: true
|
|
{% endif %}
|
|
{% if projects_persistence|bool %}
|
|
- name: "{{ ansible_operator_meta.name }}-projects"
|
|
mountPath: "/var/lib/awx/projects"
|
|
{% endif %}
|
|
{% if init_container_extra_volume_mounts -%}
|
|
{{ init_container_extra_volume_mounts | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
{% endif %}
|
|
containers:
|
|
- image: '{{ _redis_image }}'
|
|
imagePullPolicy: '{{ image_pull_policy }}'
|
|
name: redis
|
|
{% if redis_capabilities is defined and redis_capabilities %}
|
|
securityContext:
|
|
capabilities:
|
|
add: {{ redis_capabilities }}
|
|
{% endif %}
|
|
args: ["redis-server", "/etc/redis.conf"]
|
|
volumeMounts:
|
|
- name: {{ ansible_operator_meta.name }}-redis-config
|
|
mountPath: "/etc/redis.conf"
|
|
subPath: redis.conf
|
|
readOnly: true
|
|
- name: {{ ansible_operator_meta.name }}-redis-socket
|
|
mountPath: "/var/run/redis"
|
|
- name: "{{ ansible_operator_meta.name }}-redis-data"
|
|
mountPath: "/data"
|
|
- image: '{{ _image }}'
|
|
name: '{{ ansible_operator_meta.name }}-web'
|
|
{% if web_command %}
|
|
command: {{ web_command }}
|
|
{% endif %}
|
|
{% if web_args %}
|
|
args: {{ web_args }}
|
|
{% endif %}
|
|
imagePullPolicy: '{{ image_pull_policy }}'
|
|
ports:
|
|
- containerPort: 8052
|
|
{% if ingress_type | lower == 'route' and route_tls_termination_mechanism | lower == 'passthrough' %}
|
|
- containerPort: 8053
|
|
{% endif %}
|
|
volumeMounts:
|
|
{% if bundle_ca_crt %}
|
|
- name: "ca-trust-extracted"
|
|
mountPath: "/etc/pki/ca-trust/extracted"
|
|
- name: "{{ ansible_operator_meta.name }}-bundle-cacert"
|
|
mountPath: /etc/pki/ca-trust/source/anchors/bundle-ca.crt
|
|
subPath: bundle-ca.crt
|
|
readOnly: true
|
|
{% endif %}
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
mountPath: "/etc/tower/conf.d/execution_environments.py"
|
|
subPath: execution_environments.py
|
|
readOnly: true
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
mountPath: "/etc/tower/conf.d/credentials.py"
|
|
subPath: credentials.py
|
|
readOnly: true
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
mountPath: "/etc/tower/conf.d/ldap.py"
|
|
subPath: ldap.py
|
|
readOnly: true
|
|
{% if ingress_type | lower == 'route' and route_tls_termination_mechanism | lower == 'passthrough' %}
|
|
- name: "{{ ansible_operator_meta.name }}-nginx-certs"
|
|
mountPath: "/etc/nginx/pki"
|
|
readOnly: true
|
|
{% endif %}
|
|
{% if ldap_cacert_ca_crt %}
|
|
- name: "{{ ansible_operator_meta.name }}-ldap-cacert"
|
|
mountPath: /etc/openldap/certs/ldap-ca.crt
|
|
subPath: ldap-ca.crt
|
|
readOnly: true
|
|
{% endif %}
|
|
- name: "{{ secret_key_secret_name }}"
|
|
mountPath: /etc/tower/SECRET_KEY
|
|
subPath: SECRET_KEY
|
|
readOnly: true
|
|
- name: {{ ansible_operator_meta.name }}-settings
|
|
mountPath: /etc/tower/settings.py
|
|
subPath: settings.py
|
|
readOnly: true
|
|
- name: {{ ansible_operator_meta.name }}-nginx-conf
|
|
mountPath: /etc/nginx/nginx.conf
|
|
subPath: nginx.conf
|
|
readOnly: true
|
|
- name: {{ ansible_operator_meta.name }}-redis-socket
|
|
mountPath: "/var/run/redis"
|
|
- name: supervisor-socket
|
|
mountPath: "/var/run/supervisor"
|
|
- name: rsyslog-socket
|
|
mountPath: "/var/run/awx-rsyslog"
|
|
- name: rsyslog-dir
|
|
mountPath: "/var/lib/awx/rsyslog"
|
|
- name: "{{ ansible_operator_meta.name }}-projects"
|
|
mountPath: "/var/lib/awx/projects"
|
|
{% if development_mode | bool %}
|
|
- name: awx-devel
|
|
mountPath: "/awx_devel"
|
|
{% endif %}
|
|
{% if web_extra_volume_mounts -%}
|
|
{{ web_extra_volume_mounts | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
env:
|
|
- name: MY_POD_NAMESPACE
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
{% if development_mode | bool %}
|
|
- name: AWX_KUBE_DEVEL
|
|
value: "1"
|
|
{% endif %}
|
|
{% if web_extra_env -%}
|
|
{{ web_extra_env | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
resources: {{ web_resource_requirements }}
|
|
- image: '{{ _image }}'
|
|
name: '{{ ansible_operator_meta.name }}-task'
|
|
imagePullPolicy: '{{ image_pull_policy }}'
|
|
{% if task_privileged == true %}
|
|
securityContext:
|
|
privileged: true
|
|
{% endif %}
|
|
{% if task_command %}
|
|
command: {{ task_command }}
|
|
{% endif %}
|
|
{% if task_args %}
|
|
args: {{ task_args }}
|
|
{% endif %}
|
|
volumeMounts:
|
|
{% if bundle_ca_crt %}
|
|
- name: "ca-trust-extracted"
|
|
mountPath: "/etc/pki/ca-trust/extracted"
|
|
- name: "{{ ansible_operator_meta.name }}-bundle-cacert"
|
|
mountPath: /etc/pki/ca-trust/source/anchors/bundle-ca.crt
|
|
subPath: bundle-ca.crt
|
|
readOnly: true
|
|
{% endif %}
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
mountPath: "/etc/tower/conf.d/execution_environments.py"
|
|
subPath: execution_environments.py
|
|
readOnly: true
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
mountPath: "/etc/tower/conf.d/credentials.py"
|
|
subPath: credentials.py
|
|
readOnly: true
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
mountPath: "/etc/tower/conf.d/ldap.py"
|
|
subPath: ldap.py
|
|
readOnly: true
|
|
- name: "{{ secret_key_secret_name }}"
|
|
mountPath: /etc/tower/SECRET_KEY
|
|
subPath: SECRET_KEY
|
|
readOnly: true
|
|
- name: {{ ansible_operator_meta.name }}-settings
|
|
mountPath: /etc/tower/settings.py
|
|
subPath: settings.py
|
|
readOnly: true
|
|
- name: {{ ansible_operator_meta.name }}-redis-socket
|
|
mountPath: "/var/run/redis"
|
|
- name: supervisor-socket
|
|
mountPath: "/var/run/supervisor"
|
|
- name: rsyslog-socket
|
|
mountPath: "/var/run/awx-rsyslog"
|
|
- name: rsyslog-dir
|
|
mountPath: "/var/lib/awx/rsyslog"
|
|
- name: "{{ ansible_operator_meta.name }}-receptor-config"
|
|
mountPath: "/etc/receptor/receptor.conf"
|
|
subPath: receptor.conf
|
|
readOnly: true
|
|
- name: receptor-socket
|
|
mountPath: "/var/run/receptor"
|
|
- name: "{{ ansible_operator_meta.name }}-projects"
|
|
mountPath: "/var/lib/awx/projects"
|
|
{% if development_mode | bool %}
|
|
- name: awx-devel
|
|
mountPath: "/awx_devel"
|
|
{% endif %}
|
|
{% if task_extra_volume_mounts -%}
|
|
{{ task_extra_volume_mounts | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
env:
|
|
- name: SUPERVISOR_WEB_CONFIG_PATH
|
|
value: "/etc/supervisord.conf"
|
|
- name: AWX_SKIP_MIGRATIONS
|
|
value: "1"
|
|
- name: MY_POD_UID
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.uid
|
|
- name: MY_POD_IP
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: status.podIP
|
|
- name: MY_POD_NAMESPACE
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
{% if development_mode | bool %}
|
|
- name: AWX_KUBE_DEVEL
|
|
value: "1"
|
|
{% endif %}
|
|
{% if task_extra_env -%}
|
|
{{ task_extra_env | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
resources: {{ task_resource_requirements }}
|
|
- image: '{{ _control_plane_ee_image }}'
|
|
name: '{{ ansible_operator_meta.name }}-ee'
|
|
imagePullPolicy: '{{ image_pull_policy }}'
|
|
resources: {{ ee_resource_requirements }}
|
|
args: ['receptor', '--config', '/etc/receptor/receptor.conf']
|
|
volumeMounts:
|
|
{% if bundle_ca_crt %}
|
|
- name: "ca-trust-extracted"
|
|
mountPath: "/etc/pki/ca-trust/extracted"
|
|
- name: "{{ ansible_operator_meta.name }}-bundle-cacert"
|
|
mountPath: /etc/pki/ca-trust/source/anchors/bundle-ca.crt
|
|
subPath: bundle-ca.crt
|
|
readOnly: true
|
|
{% endif %}
|
|
- name: "{{ ansible_operator_meta.name }}-receptor-config"
|
|
mountPath: "/etc/receptor/receptor.conf"
|
|
subPath: receptor.conf
|
|
readOnly: true
|
|
- name: receptor-socket
|
|
mountPath: "/var/run/receptor"
|
|
- name: "{{ ansible_operator_meta.name }}-projects"
|
|
mountPath: "/var/lib/awx/projects"
|
|
{% if ee_extra_volume_mounts -%}
|
|
{{ ee_extra_volume_mounts | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
env:
|
|
{% if development_mode | bool %}
|
|
- name: SDB_NOTIFY_HOST
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: status.podIP
|
|
{% endif %}
|
|
{% if ee_extra_env -%}
|
|
{{ ee_extra_env | indent(width=12, indentfirst=True) }}
|
|
{% endif %}
|
|
{% if node_selector %}
|
|
nodeSelector:
|
|
{{ node_selector | indent(width=8) }}
|
|
{% endif %}
|
|
{% if tolerations %}
|
|
tolerations:
|
|
{{ tolerations | indent(width=8) }}
|
|
{% endif %}
|
|
{% if projects_persistence|bool or (security_context_settings|length) %}
|
|
securityContext:
|
|
{% if projects_persistence|bool %}
|
|
fsGroup: 1000
|
|
{% endif %}
|
|
{% if security_context_settings|length %}
|
|
{{ security_context_settings | to_nice_yaml | indent(8) }}
|
|
{% endif %}
|
|
{% endif %}
|
|
volumes:
|
|
{% if bundle_ca_crt %}
|
|
- name: "ca-trust-extracted"
|
|
emptyDir: {}
|
|
- name: "{{ ansible_operator_meta.name }}-bundle-cacert"
|
|
secret:
|
|
secretName: "{{ bundle_cacert_secret }}"
|
|
items:
|
|
- key: bundle-ca.crt
|
|
path: 'bundle-ca.crt'
|
|
{% endif %}
|
|
{% if ingress_type | lower == 'route' and route_tls_termination_mechanism | lower == 'passthrough' %}
|
|
- name: "{{ ansible_operator_meta.name }}-nginx-certs"
|
|
secret:
|
|
secretName: "{{ route_tls_secret }}"
|
|
items:
|
|
- key: tls.key
|
|
path: 'web.key'
|
|
- key: tls.crt
|
|
path: 'web.crt'
|
|
{% endif %}
|
|
{% if ldap_cacert_ca_crt %}
|
|
- name: "{{ ansible_operator_meta.name }}-ldap-cacert"
|
|
secret:
|
|
secretName: "{{ ldap_cacert_secret }}"
|
|
items:
|
|
- key: ldap-ca.crt
|
|
path: 'ldap-ca.crt'
|
|
{% endif %}
|
|
- name: "{{ ansible_operator_meta.name }}-application-credentials"
|
|
secret:
|
|
secretName: "{{ ansible_operator_meta.name }}-app-credentials"
|
|
items:
|
|
- key: credentials.py
|
|
path: 'credentials.py'
|
|
- key: ldap.py
|
|
path: 'ldap.py'
|
|
- key: execution_environments.py
|
|
path: 'execution_environments.py'
|
|
- name: "{{ secret_key_secret_name }}"
|
|
secret:
|
|
secretName: '{{ secret_key_secret_name }}'
|
|
items:
|
|
- key: secret_key
|
|
path: SECRET_KEY
|
|
- name: {{ ansible_operator_meta.name }}-settings
|
|
configMap:
|
|
name: '{{ ansible_operator_meta.name }}-{{ deployment_type }}-configmap'
|
|
items:
|
|
- key: settings
|
|
path: settings.py
|
|
- name: {{ ansible_operator_meta.name }}-nginx-conf
|
|
configMap:
|
|
name: '{{ ansible_operator_meta.name }}-{{ deployment_type }}-configmap'
|
|
items:
|
|
- key: nginx_conf
|
|
path: nginx.conf
|
|
- name: {{ ansible_operator_meta.name }}-redis-config
|
|
configMap:
|
|
name: {{ ansible_operator_meta.name }}-{{ deployment_type }}-configmap
|
|
items:
|
|
- key: redis_conf
|
|
path: redis.conf
|
|
- name: {{ ansible_operator_meta.name }}-redis-socket
|
|
emptyDir: {}
|
|
- name: {{ ansible_operator_meta.name }}-redis-data
|
|
emptyDir: {}
|
|
- name: supervisor-socket
|
|
emptyDir: {}
|
|
- name: rsyslog-socket
|
|
emptyDir: {}
|
|
- name: receptor-socket
|
|
emptyDir: {}
|
|
- name: rsyslog-dir
|
|
emptyDir: {}
|
|
- name: {{ ansible_operator_meta.name }}-receptor-config
|
|
configMap:
|
|
name: '{{ ansible_operator_meta.name }}-{{ deployment_type }}-configmap'
|
|
items:
|
|
- key: receptor_conf
|
|
path: receptor.conf
|
|
- name: "{{ ansible_operator_meta.name }}-projects"
|
|
{% if projects_persistence|bool %}
|
|
persistentVolumeClaim:
|
|
{% if projects_existing_claim %}
|
|
claimName: {{ projects_existing_claim }}
|
|
{% else %}
|
|
claimName: '{{ ansible_operator_meta.name }}-projects-claim'
|
|
{% endif %}
|
|
{% else %}
|
|
emptyDir: {}
|
|
{% endif %}
|
|
{% if development_mode | bool %}
|
|
- name: awx-devel
|
|
hostPath:
|
|
path: /awx_devel
|
|
{% endif %}
|
|
{% if extra_volumes -%}
|
|
{{ extra_volumes | indent(width=8, indentfirst=True) }}
|
|
{% endif %}
|