Skip to content

Commit

Permalink
Added rollout strategy override and automation
Browse files Browse the repository at this point in the history
Rollout strategy for deployments is now volume and autoscaler aware.
It will now default to `Recreate` when one or more volumes and a replica of 1 is
found with no autoscaler. This ensures rollouts can still occur when
there is only one replica which would otherwise stall.

Improvement would be to also add volume permission detection, so this
only happens when RWO is the only setting. Since RWX would still work
even with non Recreate strategy.
  • Loading branch information
DreamingRaven committed Nov 24, 2024
1 parent fe7b16e commit 84d6232
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 6 deletions.
4 changes: 2 additions & 2 deletions charts/corvid-test/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ appVersion: 0.1.0
description: A Helm chart for Kubernetes
name: corvid-test
type: application
version: 0.7.0
version: 0.8.0
dependencies:
- name: corvid
version: 0.11.0
version: 0.12.0
repository: "file://../corvid"
5 changes: 3 additions & 2 deletions charts/corvid-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Helm chart for Kubernetes

![Version: 0.7.0](https://img.shields.io/badge/Version-0.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
![Version: 0.8.0](https://img.shields.io/badge/Version-0.8.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

## Installing the Chart

Expand All @@ -18,7 +18,7 @@ $ helm install corvid-test raven/corvid-test

| Repository | Name | Version |
|------------|------|---------|
| file://../corvid | corvid | 0.11.0 |
| file://../corvid | corvid | 0.12.0 |

## Values

Expand All @@ -34,6 +34,7 @@ $ helm install corvid-test raven/corvid-test
| cron.enabled | bool | `false` | enable or disable cronjob |
| cron.schedule | string | `"@midnight"` | schedule for cronjob using Cron syntax https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-syntax |
| cron.suspend | bool | `false` | cronjob will not trigger on schedule but can be manually triggered |
| deployment.strategy | string | `""` | rollout strategy `Recreate` or `RollingUpdate` this chart defaults to Recreate only if we detect a single replica with a volume |
| dnsConfig | object | `{}` | |
| dnsPolicy | string | `""` | |
| envFrom | string | `nil` | |
Expand Down
4 changes: 4 additions & 0 deletions charts/corvid-test/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ command:
args:
runtimeClassName:

deployment:
# -- rollout strategy `Recreate` or `RollingUpdate` this chart defaults to Recreate only if we detect a single replica with a volume
strategy: ""

cron:
# -- enable or disable cronjob
enabled: false
Expand Down
22 changes: 22 additions & 0 deletions charts/corvid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.12.0

Behaviour has changed for single replica deployments with volumes.
If you have a deployment that:

- has a single replica (any of .Values.replicaCount=1, .Values.autoscaling.enabled=false)
- has a volume (any of .Values.volumes>0, .Values.persistence.existingClaim!="", .Values.persistence.enabled=true)

We now default the deployment to `Recreate` rollout strategy instead of `RollingUpdate` to enable rollouts to complete without manual intervention.

You can manually define the rollout strategy if you would rather not rely on this automated behaviour, this is left blank by default but feel free to adjust it as you see fit downstream:

```yaml

deployment:
# -- rollout strategy `Recreate` or `RollingUpdate` this chart defaults to Recreate only if we detect a single replica with a volume
strategy: ""

```

We do check for this key, so you will need to add this to your `values.yaml` else you will get thrown a key error.

## 0.11.0

This is backwards incompatible.
Expand Down
2 changes: 1 addition & 1 deletion charts/corvid/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
appVersion: "0.1.0"
version: 0.11.0
version: 0.12.0
description: Common helm component and utility library
name: corvid
type: library
25 changes: 24 additions & 1 deletion charts/corvid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Common helm component and utility library

![Version: 0.11.0](https://img.shields.io/badge/Version-0.11.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
![Version: 0.12.0](https://img.shields.io/badge/Version-0.12.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

This library chart primarily deals with abstracting common boilerplate into customisable components for re-use.

Expand Down Expand Up @@ -30,6 +30,7 @@ $ helm install corvid raven/corvid
| cron.enabled | bool | `false` | enable or disable cronjob |
| cron.schedule | string | `"@midnight"` | schedule for cronjob using Cron syntax https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-syntax |
| cron.suspend | bool | `false` | cronjob will not trigger on schedule but can be manually triggered |
| deployment.strategy | string | `""` | rollout strategy `Recreate` or `RollingUpdate` this chart defaults to Recreate only if we detect a single replica with a volume |
| envFrom[0].configMapRef.name | string | `"someConfigMap"` | |
| envFrom[0].configMapRef.optional | bool | `false` | |
| envFrom[1].secretRef.name | string | `"someSecret"` | |
Expand Down Expand Up @@ -95,6 +96,28 @@ $ helm install corvid raven/corvid

# Changelog

## 0.12.0

Behaviour has changed for single replica deployments with volumes.
If you have a deployment that:

- has a single replica (any of .Values.replicaCount=1, .Values.autoscaling.enabled=false)
- has a volume (any of .Values.volumes>0, .Values.persistence.existingClaim!="", .Values.persistence.enabled=true)

We now default the deployment to `Recreate` rollout strategy instead of `RollingUpdate` to enable rollouts to complete without manual intervention.

You can manually define the rollout strategy if you would rather not rely on this automated behaviour, this is left blank by default but feel free to adjust it as you see fit downstream:

```yaml

deployment:
# -- rollout strategy `Recreate` or `RollingUpdate` this chart defaults to Recreate only if we detect a single replica with a volume
strategy: ""

```

We do check for this key, so you will need to add this to your `values.yaml` else you will get thrown a key error.

## 0.11.0

This is backwards incompatible.
Expand Down
11 changes: 11 additions & 0 deletions charts/corvid/templates/_deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{{- define "corvid.deploy.tpl" -}}
{{- $hasVolume := (or (ne (len .Values.volumes) 0) (or (ne .Values.persistence.existingClaim "") (.Values.persistence.enabled))) }}
{{- $hasOneReplica := (and (eq (int .Values.replicaCount) 1) (not .Values.autoscaling.enabled)) }}
# has volume: {{ $hasVolume }}
# has 1 replica: {{ $hasOneReplica }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -9,6 +13,13 @@ spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- if .Values.deployment.strategy }}
strategy:
type: {{ .Values.deployment.strategy }}
{{- else if and $hasVolume $hasOneReplica }}
strategy:
type: "Recreate" # detected a single replica with a volume which would block on rollout if Rollout was used
{{- end }}
selector:
matchLabels:
{{- include "corvid.selectorLabels" . | nindent 6 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/corvid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ command:
args:
runtimeClassName:

deployment:
# -- rollout strategy `Recreate` or `RollingUpdate` this chart defaults to Recreate only if we detect a single replica with a volume
strategy: ""

cron:
# -- enable or disable cronjob
enabled: false
Expand Down

0 comments on commit 84d6232

Please sign in to comment.