Skip to content

Commit

Permalink
feat: include pdb (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
marbonilla authored May 24, 2024
1 parent b26f433 commit 6e66dd1
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ The following configuration options are available:
- `DRYDOCK_POD_LIFECYCLE`: Whether to enable pod lifecycle. Defaults to `true`.
- `DRYDOCK_MIGRATE_FROM`: it allows defining the version of the OpenedX platform we are migrating from. It accepts the integer value mapping the origin release, for instance, `13`(maple) or `14`(nutmeg). When this variable is set, a group of `release-specific upgrade jobs` are added to the Kubernetes manifests. These jobs are applied to the cluster in a suitable order (thanks to the GitOps implementation with ArgoCD + sync waves) to guarantee the correct behavior of the platform in the new version. This brings the `tutor k8s upgrade <https://github.com/overhangio/tutor/blob/v16.1.8/tutor/commands/k8s.py#L486>`_ command to the GitOps pattern. The release-specific upgrade jobs are supported from release `13`(maple). Defaults to `0` (which disables release-specific upgrade jobs)
- `DRYDOCK_POST_INIT_DEPLOYMENTS`: A list of Kubernetes deployments to be applied after the initialization jobs. There are specific deployments that won't report a healthy status in ArgoCD unless the initialization requirements are guaranteed (for instance, database users creation). Thanks to the ArgoCD sync waves feature, the deployments defined in this variable can be synchronized in a phase after the execution of the initialization jobs in order to prevent OpenedX environment syncing failures. In most cases this variable should not be changed. Defaults to `["lms", "cms", "lms-worker", "cms-worker", "forum"]`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_MFE` : The minimum available percentage for the MFE's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_FORUM` : The minimum available percentage for the FORUM's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CADDY` : The minimum available percentage for the CADDY's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS` : The minimum available percentage for the LMS's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER` : The minimum available percentage for the LMS WORKER's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS` : The minimum available percentage for the CMS's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER` : The minimum available percentage for the worker's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.

.. note::
You also need to set `DRYDOCK_INIT_JOBS` to `true` to enable the release-specific upgrade jobs in the case of a platform migration.
Expand Down
1 change: 1 addition & 0 deletions drydock/patches/kustomization-resources
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- plugins/drydock/k8s/multipurpose-jobs.yml
- plugins/drydock/k8s/pdb/openedx-pdb.yml
{%- if DRYDOCK_INIT_JOBS %}
- plugins/drydock/k8s/jobs.yml
{%- endif %}
Expand Down
7 changes: 7 additions & 0 deletions drydock/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ def get_sync_waves_for_resource(resource_name: str) -> SYNC_WAVES_ORDER_ATTRS_TY
"lms-worker",
"cms-worker",
],
"PDB_MINAVAILABLE_PERCENTAGE_LMS": 0,
"PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER": 0,
"PDB_MINAVAILABLE_PERCENTAGE_CMS": 0,
"PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER": 0,
"PDB_MINAVAILABLE_PERCENTAGE_MFE": 0,
"PDB_MINAVAILABLE_PERCENTAGE_FORUM": 0,
"PDB_MINAVAILABLE_PERCENTAGE_CADDY": 0,
},
# Add here settings that don't have a reasonable default for all users. For
# instance: passwords, secret keys, etc.
Expand Down
84 changes: 84 additions & 0 deletions drydock/templates/drydock/k8s/pdb/openedx-pdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{%- if MFE_HOST is defined and DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_MFE > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: mfe-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_MFE}}%
selector:
matchLabels:
app.kubernetes.io/name: mfe
{%- endif %}
{%- if FORUM_DOCKER_IMAGE is defined and DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_FORUM > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: forum-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_FORUM}}%
selector:
matchLabels:
app.kubernetes.io/name: forum
{%- endif %}
{%- if DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CADDY > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: caddy-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CADDY}}%
selector:
matchLabels:
app.kubernetes.io/name: caddy
{%- endif %}
{%- if DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: lms-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS}}%
selector:
matchLabels:
app.kubernetes.io/name: lms
{%- endif %}
{%- if DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: lms-worker-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER}}%
selector:
matchLabels:
app.kubernetes.io/name: lms-worker
{%- endif %}
{%- if DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: cms-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS}}%
selector:
matchLabels:
app.kubernetes.io/name: cms
{%- endif %}
{%- if DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER > 0 %}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: cms-worker-pdb
spec:
minAvailable: {{DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER}}%
selector:
matchLabels:
app.kubernetes.io/name: cms-worker
{%- endif %}

0 comments on commit 6e66dd1

Please sign in to comment.