Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

idle_deployment - Scale down deployments to put EDA into an idle state: #272

Merged
merged 1 commit into from
Feb 11, 2025
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
6 changes: 6 additions & 0 deletions config/crd/bases/eda.ansible.com_edas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,9 @@ spec:
description: 'Defines Redis Deployment replicas'
format: int32
type: integer
default: 1
minimum: 0
maximum: 1
node_selector:
additionalProperties:
type: string
Expand Down Expand Up @@ -2823,6 +2826,9 @@ spec:
force_drop_db:
description: Force drop the database before restoring. USE WITH CAUTION!
type: boolean
idle_deployment:
description: Scale down deployments to put EDA into an idle state
type: boolean
status:
description: Status defines the observed state of EDA
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ spec:
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: Scale down deployments to put EDA into an idle state
displayName: Idle EDA
path: idle_deployment
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- urn:alm:descriptor:com.tectonic.ui:hidden
- displayName: No Log Configuration
path: no_log
x-descriptors:
Expand Down
3 changes: 3 additions & 0 deletions roles/eda/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,6 @@ admin_password_secret: ''

# Disable UI container's nginx ipv6 listener
ipv6_disabled: false

# idle_deployment - Scale down deployments to put EDA into an idle state
idle_deployment: false
93 changes: 93 additions & 0 deletions roles/eda/tasks/idle_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
- name: Scale down EDA Deployments
kubernetes.core.k8s:
state: present
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ item }}"
namespace: "{{ ansible_operator_meta.namespace }}"
spec:
replicas: 0
loop:
- '{{ ansible_operator_meta.name }}-activation-worker'
- '{{ api_server_name }}'
- '{{ ansible_operator_meta.name }}-default-worker'
- '{{ event_stream_server_name }}'
- '{{ ansible_operator_meta.name }}-scheduler'

- name: Scale down EDA ui if enabled
kubernetes.core.k8s:
state: present
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ ansible_operator_meta.name }}-ui"
namespace: "{{ ansible_operator_meta.namespace }}"
spec:
replicas: 0
when: not ui_disabled

- name: Check for an external Redis cache
ansible.builtin.import_role:
name: redis
tasks_from: check_external_config
when: redis_type | length == 0 or redis_type == 'unmanaged'

- name: Check for the default Redis configuration
ansible.builtin.import_role:
name: redis
tasks_from: check_default_config
when: redis_type | length == 0 or redis_type == 'managed'

- name: Create a default Redis configuration
ansible.builtin.import_role:
name: redis
tasks_from: create_default_config
when: redis_type | length == 0

- name: Scale down Redis Deployment
kubernetes.core.k8s:
state: present
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ ansible_operator_meta.name }}-redis"
namespace: "{{ ansible_operator_meta.namespace }}"
spec:
replicas: 0
when: redis_type == "managed"

- name: Combine postgres default and custom vars for each component
ansible.builtin.import_role:
name: postgres
tasks_from: combine_defaults

- name: Determine and set postgres configuration secret and variables
ansible.builtin.import_role:
name: postgres
tasks_from: set_configuration_secret

- name: Set variables to be used in Postgres templates
ansible.builtin.import_role:
name: postgres
tasks_from: set_variables

- name: Scale down PostgreSQL Statefulset
kubernetes.core.k8s:
state: present
definition:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: "{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}"
namespace: "{{ ansible_operator_meta.namespace }}"
spec:
replicas: 0
when: managed_database

- name: End Playbook
ansible.builtin.meta: end_play
4 changes: 4 additions & 0 deletions roles/eda/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
include_role:
name: common

- name: Idle EDA
include_tasks: idle_deployment.yml
when: idle_deployment | bool

- name: Setup Redis
include_role:
name: redis
Expand Down
1 change: 1 addition & 0 deletions roles/postgres/templates/postgres.statefulset.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
app.kubernetes.io/managed-by: 'eda-operator'
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
Expand Down