1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 06:51:10 +03:00

Merge pull request #3812 from skinlayers/devel

Add support for kubernetes nodeSelector, tolerations and affinity

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-08-16 16:36:56 +00:00 committed by GitHub
commit 4dc97ac8d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 18 deletions

View File

@ -78,31 +78,32 @@
- postgres_svc_details is defined and postgres_svc_details.rc != 0
- openshift_host is defined
- name: Deploy and Activate Postgres (Kubernetes)
shell: |
helm repo update --tiller-namespace={{ tiller_namespace | default('kube-system') }}
helm upgrade {{ postgresql_service_name }} --install \
--namespace {{ kubernetes_namespace }} \
--set postgresqlUsername={{ pg_username }} \
--set postgresqlPassword={{ pg_password | quote }} \
--set postgresqlDatabase={{ pg_database }} \
--set persistence.size={{ pg_volume_capacity|default('5')}}Gi \
--version="2.0.0" \
--tiller-namespace={{ tiller_namespace | default('kube-system') }} \
{{ '--set persistence.storageClass='+pg_persistence_storageClass if pg_persistence_storageClass is defined else ' ' }} \
{{ '--set resources.limits.cpu='+(pg_cpu_limit | string)+'m' if pg_cpu_limit is defined else ' ' }} \
{{ '--set resources.limits.memory='+(pg_mem_limit | string)+'Gi' if pg_mem_limit is defined else ' ' }} \
stable/postgresql
- name: Deploy PostgreSQL (Kubernetes)
block:
- name: Template PostgreSQL Deployment (Kubernetes)
set_fact:
pg_values: "{{ lookup('template', 'postgresql-values.yml.j2') }}"
no_log: yes
- name: Deploy and Activate Postgres (Kubernetes)
shell: |
helm repo update --tiller-namespace={{ tiller_namespace | default('kube-system') }}
echo {{ pg_values | quote }} | helm upgrade {{ postgresql_service_name }} --install \
--namespace {{ kubernetes_namespace }} \
--version="6.2.1" \
--tiller-namespace={{ tiller_namespace | default('kube-system') }} \
--values - \
stable/postgresql
register: kubernetes_pg_activate
no_log: yes
when:
- pg_hostname is not defined or pg_hostname == ''
- postgres_svc_details is defined and postgres_svc_details.rc != 0
- kubernetes_context is defined
register: kubernetes_pg_activate
no_log: yes
- name: Set postgresql hostname to helm package service (Kubernetes)
set_fact:
pg_hostname: "{{ postgresql_service_name }}-postgresql"
pg_hostname: "{{ postgresql_service_name }}"
when:
- pg_hostname is not defined or pg_hostname == ''
- kubernetes_context is defined

View File

@ -324,6 +324,18 @@ spec:
{% endif %}
{% if memcached_cpu_limit is defined %}
cpu: "{{ memcached_cpu_limit }}m"
{% endif %}
{% if tolerations is defined %}
tolerations:
{{ tolerations | to_nice_yaml(indent=2) | indent(width=8, indentfirst=True) }}
{% endif %}
{% if node_selector is defined %}
nodeSelector:
{{ node_selector | to_nice_yaml(indent=2) | indent(width=8, indentfirst=True) }}
{% endif %}
{% if affinity is defined %}
affinity:
{{ affinity | to_nice_yaml(indent=2) | indent(width=8, indentfirst=True) }}
{% endif %}
volumes:
{% if ca_trust_dir is defined %}

View File

@ -32,6 +32,18 @@ spec:
{% endif %}
{% if management_cpu_limit is defined %}
cpu: "{{ management_cpu_limit }}m"
{% endif %}
{% if tolerations is defined %}
tolerations:
{{ tolerations | to_nice_yaml(indent=2) | indent(width=4, indentfirst=True) }}
{% endif %}
{% if node_selector is defined %}
nodeSelector:
{{ node_selector | to_nice_yaml(indent=2) | indent(width=4, indentfirst=True) }}
{% endif %}
{% if affinity is defined %}
affinity:
{{ affinity | to_nice_yaml(indent=2) | indent(width=4, indentfirst=True) }}
{% endif %}
volumes:
- name: {{ kubernetes_deployment_name }}-application-config

View File

@ -0,0 +1,33 @@
postgresqlUsername: {{ pg_username }}
postgresqlPassword: {{ pg_password }}
postgresqlDatabase: {{ pg_database }}
persistence:
size: {{ pg_volume_capacity|default('5') }}Gi
{% if pg_persistence_storageClass is defined %}
storageClass: {{ pg_persistence_storageClass }}
{% endif %}
{% if pg_cpu_limit is defined or pg_mem_limit is defined %}
resources:
limits:
{% if pg_cpu_limit is defined %}
cpu: {{ pg_cpu_limit | string }}m
{% endif %}
{% if pg_mem_limit is defined %}
memory: {{ pg_mem_limit | string }}Gi
{% endif %}
{% endif %}
{% if tolerations is defined or node_selector is defined or affinity is defined %}
master:
{% if tolerations is defined %}
tolerations:
{{ tolerations | to_nice_yaml(indent=2) | indent(width=4, indentfirst=True) }}
{% endif %}
{% if node_selector is defined %}
nodeSelector:
{{ node_selector | to_nice_yaml(indent=2) | indent(width=4, indentfirst=True) }}
{% endif %}
{% if affinity is defined %}
affinity:
{{ affinity | to_nice_yaml(indent=2) | indent(width=4, indentfirst=True) }}
{% endif %}
{% endif %}