Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions molecule/default/tasks/eda_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,56 @@
fail_msg: "API Deployment topologySpreadConstraints do not match the CR: {{ _constraints }}"
vars:
_constraints: "{{ api_deployment.resources[0].spec.template.spec.topologySpreadConstraints }}"

- name: Add a node selector for the UI pods to the EDA CR
kubernetes.core.k8s:
state: patched
api_version: eda.ansible.com/v1alpha1
kind: EDA
namespace: '{{ namespace }}'
name: '{{ eda_cr_name }}'
definition:
spec:
ui:
node_selector:
kubernetes.io/os: linux
when: not (ui_disabled | bool)

- name: Wait for the UI Deployment to pick up the node selector
kubernetes.core.k8s_info:
api_version: apps/v1
kind: Deployment
namespace: '{{ namespace }}'
name: '{{ eda_cr_name }}-ui'
register: ui_deployment
until:
- ui_deployment.resources | length > 0
- "ui_deployment.resources[0].spec.template.spec.nodeSelector == {'kubernetes.io/os': 'linux'}"
retries: 30
delay: 10
when: not (ui_disabled | bool)

- name: Remove the UI node selector from the EDA CR
kubernetes.core.k8s_json_patch:
api_version: eda.ansible.com/v1alpha1
kind: EDA
namespace: '{{ namespace }}'
name: '{{ eda_cr_name }}'
patch:
- op: remove
path: /spec/ui/node_selector/kubernetes.io~1os
when: not (ui_disabled | bool)

- name: Wait for the UI Deployment to remove the node selector
kubernetes.core.k8s_info:
api_version: apps/v1
kind: Deployment
namespace: '{{ namespace }}'
name: '{{ eda_cr_name }}-ui'
register: ui_deployment
until:
- ui_deployment.resources | length > 0
- (ui_deployment.resources[0].spec.template.spec.nodeSelector | default({}, true)) == {}
retries: 30
delay: 10
when: not (ui_disabled | bool)
52 changes: 51 additions & 1 deletion roles/eda/tasks/deploy_eda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,63 @@

- name: Apply UI deployment resources if UI is enabled
k8s:
state: "{{ 'present' if not ui_disabled else 'absent' }}"
apply: yes
state: present
definition: "{{ lookup('template', item + '.yaml.j2') }}"
wait: no
loop:
- 'eda-ui.service'
- 'eda-ui.deployment'
- 'eda-ui.ingress'
when: not ui_disabled

- name: Read UI deployment placement
kubernetes.core.k8s_info:
api_version: apps/v1
kind: Deployment
name: "{{ ansible_operator_meta.name }}-ui"
namespace: "{{ ansible_operator_meta.namespace }}"
register: _ui_deployment
when: not ui_disabled

- name: Reconcile UI deployment placement
kubernetes.core.k8s_json_patch:
api_version: apps/v1
kind: Deployment
name: "{{ ansible_operator_meta.name }}-ui"
namespace: "{{ ansible_operator_meta.namespace }}"
patch:
- op: add
path: /spec/template/spec/nodeSelector
value: "{{ combined_ui.node_selector }}"
- op: add
path: /spec/template/spec/tolerations
value: "{{ combined_ui.tolerations }}"
- op: add
path: /spec/template/spec/affinity
value: "{{ combined_ui.affinity }}"
- op: add
path: /spec/template/spec/topologySpreadConstraints
value: "{{ combined_ui.topology_spread_constraints | default([]) }}"
when:
- not ui_disabled
- _ui_deployment.resources | length > 0
- >-
(_ui_deployment.resources[0].spec.template.spec.nodeSelector | default({}, true)) != combined_ui.node_selector
or (_ui_deployment.resources[0].spec.template.spec.tolerations | default([], true)) != combined_ui.tolerations
or (_ui_deployment.resources[0].spec.template.spec.affinity | default({}, true)) != combined_ui.affinity
or (_ui_deployment.resources[0].spec.template.spec.topologySpreadConstraints | default([], true)) != (combined_ui.topology_spread_constraints | default([]))

- name: Remove UI deployment resources if UI is disabled
k8s:
state: absent
definition: "{{ lookup('template', item + '.yaml.j2') }}"
wait: no
loop:
- 'eda-ui.service'
- 'eda-ui.deployment'
- 'eda-ui.ingress'
when: ui_disabled

- name: Apply API Route or Ingress if UI is disabled
k8s:
Expand Down
Loading