Skip to content

Commit

Permalink
feat: make migration helm hook optional (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav-14 authored Oct 22, 2024
1 parent ee49929 commit 4ae344a
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 67 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
| Readme | Chart Version | App Version | Description | Hub |
|--------|---------------|-------------|-------------|-----|
| [Agent](./charts/agent/README.md) | v2.1.0 |v2.0.18 | Formance Membership Agent Helm Chart | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/agent)](https://artifacthub.io/packages/search?repo=agent) |
| [Cloudprem](./charts/cloudprem/README.md) | v2.0.0-beta.27 |v0.35.3 | Formance control-plane | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/cloudprem)](https://artifacthub.io/packages/search?repo=cloudprem) |
| [Cloudprem](./charts/cloudprem/README.md) | v2.0.0-beta.28 |v0.35.3 | Formance control-plane | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/cloudprem)](https://artifacthub.io/packages/search?repo=cloudprem) |
| [Console](./charts/console/README.md) | v1.0.0-beta.8 |9431e5f4b4b1a03cb8f02ef1676507b9c023f2bb | Formance Console | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/console)](https://artifacthub.io/packages/search?repo=console) |
| [Core](./charts/core/README.md) | v1.0.0-beta.6 |latest | Formance Core Library | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/core)](https://artifacthub.io/packages/search?repo=core) |
| [Demo](./charts/demo/README.md) | 2.0.0 |latest | Formance Private Regions Demo | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/demo)](https://artifacthub.io/packages/search?repo=demo) |
| [Membership](./charts/membership/README.md) | v1.0.0-beta.16 |v0.35.3 | Formance Membership API. Manage stacks, organizations, regions, invitations, users, roles, and permissions. | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/membership)](https://artifacthub.io/packages/search?repo=membership) |
| [Membership](./charts/membership/README.md) | v1.0.0-beta.17 |v0.35.3 | Formance Membership API. Manage stacks, organizations, regions, invitations, users, roles, and permissions. | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/membership)](https://artifacthub.io/packages/search?repo=membership) |
| [Portal](./charts/portal/README.md) | v1.0.0-beta.7 |764bb7e199e1d2882e4d5cd205eada0ef0abc283 | Formance Portal | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/portal)](https://artifacthub.io/packages/search?repo=portal) |
| [Regions](./charts/regions/README.md) | v2.1.1 |latest | Formance Private Regions Helm Chart | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/regions)](https://artifacthub.io/packages/search?repo=regions) |
| [Stargate](./charts/stargate/README.md) | 0.5.2 |latest | Formance Stargate gRPC Gateway | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/stargate)](https://artifacthub.io/packages/search?repo=stargate) |
| [Stargate](./charts/stargate/README.md) | 0.5.3 |latest | Formance Stargate gRPC Gateway | [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/stargate)](https://artifacthub.io/packages/search?repo=stargate) |

## How to contribute

Expand Down
6 changes: 3 additions & 3 deletions charts/cloudprem/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dependencies:
- name: membership
repository: file://../membership
version: v1.0.0-beta.16
version: v1.0.0-beta.17
- name: portal
repository: file://../portal
version: v1.0.0-beta.7
- name: console
repository: file://../console
version: v1.0.0-beta.8
digest: sha256:6e958c482ab5d378e0865db3c361080a48783cbdaa71796d8429bc3f5918e0ef
generated: "2024-10-18T12:59:12.667370019Z"
digest: sha256:c9a539130c6925ceebf921eccad619291c50494407326c88bcb8d07f92582b52
generated: "2024-10-19T22:04:44.764593072Z"
4 changes: 2 additions & 2 deletions charts/cloudprem/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "v2.0.0-beta.27"
version: "v2.0.0-beta.28"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand All @@ -45,7 +45,7 @@ sources: []

dependencies:
- name: membership
version: v1.0.0-beta.16
version: v1.0.0-beta.17
repository: file://../membership
condition: membership.enabled
- name: portal
Expand Down
23 changes: 13 additions & 10 deletions charts/cloudprem/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/cloudprem)](https://artifacthub.io/packages/search?repo=cloudprem)
![Version: v2.0.0-beta.27](https://img.shields.io/badge/Version-v2.0.0--beta.27-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.35.3](https://img.shields.io/badge/AppVersion-v0.35.3-informational?style=flat-square)
![Version: v2.0.0-beta.28](https://img.shields.io/badge/Version-v2.0.0--beta.28-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.35.3](https://img.shields.io/badge/AppVersion-v0.35.3-informational?style=flat-square)

# Formance Cloudprem Helm Chart

Expand Down Expand Up @@ -421,6 +421,14 @@ Dex:
| membership.dex.ingress.tls | list | `[]` | Dex ingress tls |
| membership.dex.resources | object | `{}` | Dex resources |

### Membership Feature

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| membership.feature.disableEvents | bool | `true` | Membership feature disable events |
| membership.feature.managedStacks | bool | `true` | Membership feature managed stacks |
| membership.feature.migrationHooks | bool | `true` | Run migration in a hook |

### Postgresql configuration

| Key | Type | Default | Description |
Expand All @@ -435,10 +443,10 @@ Dex:
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| global.nats.auth.existingSecret | string | `""` | |
| global.nats.auth.password | string | `nil` | |
| global.nats.auth.password | string | `""` | |
| global.nats.auth.secretKeys.password | string | `"password"` | |
| global.nats.auth.secretKeys.username | string | `"username"` | |
| global.nats.auth.user | string | `nil` | |
| global.nats.auth.user | string | `""` | |
| global.nats.enabled | bool | `false` | |
| global.platform.membership.oidc.host | string | `"dex.{{ .Values.global.serviceHost }}"` | is the host for the oidc |
| global.platform.membership.oidc.scheme | string | `"https"` | is the scheme for the issuer |
Expand Down Expand Up @@ -500,11 +508,8 @@ Dex:
| membership.config.job | object | `{"garbageCollector":{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"0 0 * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]},"stackLifeCycle":{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"*/30 * * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]}}` | CronJob to manage the stack life cycle and the garbage collector |
| membership.config.job.garbageCollector | object | `{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"0 0 * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]}` | Clean expired tokens and refresh tokens after X time |
| membership.config.job.stackLifeCycle | object | `{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"*/30 * * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]}` | Job create 2 jobs to eaither warn or prune a stacks This does not change the state of the stack WARN: Mark stack Disposable -> trigger a mail PRUNE: Mark stack Warned -> trigger a mail It blocks stack cycles if supendend It is highly recommended to enable it as it is the only way we control |
| membership.config.migration.annotations | object | `{"helm.sh/hook":"pre-upgrade","helm.sh/hook-delete-policy":"before-hook-creation,hook-succeeded,hook-failed"}` | Membership job migration annotations |
| membership.config.migration.annotations."helm.sh/hook" | string | `"pre-upgrade"` | Membership migration helm hook |
| membership.config.migration.annotations."helm.sh/hook-delete-policy" | string | `"before-hook-creation,hook-succeeded,hook-failed"` | Membership migration hook delete policy |
| membership.config.migration.serviceAccount.annotations."helm.sh/hook" | string | `"pre-upgrade"` | Membership migration helm hook |
| membership.config.migration.serviceAccount.annotations."helm.sh/hook-delete-policy" | string | `"before-hook-creation,hook-succeeded,hook-failed"` | Membership migration hook delete policy |
| membership.config.migration.annotations | object | `{}` | Membership job migration annotations |
| membership.config.migration.serviceAccount.annotations | object | `{}` | |
| membership.config.migration.serviceAccount.create | bool | `true` | |
| membership.config.migration.serviceAccount.name | string | `""` | |
| membership.config.migration.ttlSecondsAfterFinished | string | `""` | |
Expand Down Expand Up @@ -533,8 +538,6 @@ Dex:
| membership.config.stack.minimalStackModules[3] | string | `"Gateway"` | |
| membership.debug | bool | `false` | Membership debug |
| membership.dev | bool | `false` | Membership dev |
| membership.feature.disableEvents | bool | `true` | Membership feature disable events |
| membership.feature.managedStacks | bool | `true` | Membership feature managed stacks |
| membership.fullnameOverride | string | `""` | Membership fullname override |
| membership.image.pullPolicy | string | `"IfNotPresent"` | Membership image pull policy |
| membership.image.repository | string | `"ghcr.io/formancehq/membership"` | Membership image repository |
Expand Down
2 changes: 1 addition & 1 deletion charts/membership/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "v1.0.0-beta.16"
version: "v1.0.0-beta.17"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
23 changes: 13 additions & 10 deletions charts/membership/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# membership

![Version: v1.0.0-beta.16](https://img.shields.io/badge/Version-v1.0.0--beta.16-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.35.3](https://img.shields.io/badge/AppVersion-v0.35.3-informational?style=flat-square)
![Version: v1.0.0-beta.17](https://img.shields.io/badge/Version-v1.0.0--beta.17-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.35.3](https://img.shields.io/badge/AppVersion-v0.35.3-informational?style=flat-square)

Formance Membership API. Manage stacks, organizations, regions, invitations, users, roles, and permissions.

Expand Down Expand Up @@ -103,6 +103,14 @@ Kubernetes: `>=1.14.0-0`
| dex.ingress.tls | list | `[]` | Dex ingress tls |
| dex.resources | object | `{}` | Dex resources |

### Membership Feature

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| feature.disableEvents | bool | `true` | Membership feature disable events |
| feature.managedStacks | bool | `true` | Membership feature managed stacks |
| feature.migrationHooks | bool | `true` | Run migration in a hook |

### Postgresql configuration

| Key | Type | Default | Description |
Expand All @@ -117,10 +125,10 @@ Kubernetes: `>=1.14.0-0`
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| global.nats.auth.existingSecret | string | `""` | |
| global.nats.auth.password | string | `nil` | |
| global.nats.auth.password | string | `""` | |
| global.nats.auth.secretKeys.password | string | `"password"` | |
| global.nats.auth.secretKeys.username | string | `"username"` | |
| global.nats.auth.user | string | `nil` | |
| global.nats.auth.user | string | `""` | |
| global.nats.enabled | bool | `false` | |
| additionalEnv | list | `[]` | |
| affinity | object | `{}` | Membership affinity |
Expand All @@ -135,11 +143,8 @@ Kubernetes: `>=1.14.0-0`
| config.job | object | `{"garbageCollector":{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"0 0 * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]},"stackLifeCycle":{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"*/30 * * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]}}` | CronJob to manage the stack life cycle and the garbage collector |
| config.job.garbageCollector | object | `{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"0 0 * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]}` | Clean expired tokens and refresh tokens after X time |
| config.job.stackLifeCycle | object | `{"concurrencyPolicy":"Forbid","enabled":false,"resources":{},"restartPolicy":"Never","schedule":"*/30 * * * *","startingDeadlineSeconds":200,"suspend":false,"tolerations":[],"volumeMounts":[],"volumes":[]}` | Job create 2 jobs to eaither warn or prune a stacks This does not change the state of the stack WARN: Mark stack Disposable -> trigger a mail PRUNE: Mark stack Warned -> trigger a mail It blocks stack cycles if supendend It is highly recommended to enable it as it is the only way we control |
| config.migration.annotations | object | `{"helm.sh/hook":"pre-upgrade","helm.sh/hook-delete-policy":"before-hook-creation,hook-succeeded,hook-failed"}` | Membership job migration annotations |
| config.migration.annotations."helm.sh/hook" | string | `"pre-upgrade"` | Membership migration helm hook |
| config.migration.annotations."helm.sh/hook-delete-policy" | string | `"before-hook-creation,hook-succeeded,hook-failed"` | Membership migration hook delete policy |
| config.migration.serviceAccount.annotations."helm.sh/hook" | string | `"pre-upgrade"` | Membership migration helm hook |
| config.migration.serviceAccount.annotations."helm.sh/hook-delete-policy" | string | `"before-hook-creation,hook-succeeded,hook-failed"` | Membership migration hook delete policy |
| config.migration.annotations | object | `{}` | Membership job migration annotations |
| config.migration.serviceAccount.annotations | object | `{}` | |
| config.migration.serviceAccount.create | bool | `true` | |
| config.migration.serviceAccount.name | string | `""` | |
| config.migration.ttlSecondsAfterFinished | string | `""` | |
Expand Down Expand Up @@ -168,8 +173,6 @@ Kubernetes: `>=1.14.0-0`
| config.stack.minimalStackModules[3] | string | `"Gateway"` | |
| debug | bool | `false` | Membership debug |
| dev | bool | `false` | Membership dev |
| feature.disableEvents | bool | `true` | Membership feature disable events |
| feature.managedStacks | bool | `true` | Membership feature managed stacks |
| fullnameOverride | string | `""` | Membership fullname override |
| image.pullPolicy | string | `"IfNotPresent"` | Membership image pull policy |
| image.repository | string | `"ghcr.io/formancehq/membership"` | Membership image repository |
Expand Down
16 changes: 16 additions & 0 deletions charts/membership/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,19 @@ staticClients:
{{- end }}
{{- end }}
{{- end }}

{{- define "migrations.job.annotations" -}}
{{- if and (not .Release.IsInstall) .Values.feature.migrationHooks }}
helm.sh/hook: pre-upgrade
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed
helm.sh/hook-weight: "10"
{{- end }}
{{- end }}

{{- define "migrations.job.sa.annotations" -}}
{{- if and (not .Release.IsInstall) .Values.feature.migrationHooks }}
helm.sh/hook: pre-upgrade
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed
helm.sh/hook-weight: "-10"
{{- end }}
{{- end }}
3 changes: 1 addition & 2 deletions charts/membership/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "core.fullname" . }}
labels:
{{- include "core.labels" . | nindent 4 }}
{{- with .Values.config.migration.annotations }}
{{- with merge .Values.config.migration.annotations (include "migrations.job.annotations" . | fromYaml) }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down Expand Up @@ -52,7 +52,6 @@ spec:
{{- include "core.env.common" . | nindent 10 }}
{{- include "core.nats.env" . | nindent 10 }}
{{- end }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/membership/templates/job_sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "membership.job.serviceAccountName" . }}
labels:
{{- include "core.labels" . | nindent 4 }}
{{- with .Values.config.migration.serviceAccount.annotations }}
{{- with merge .Values.config.migration.serviceAccount.annotations (include "migrations.job.sa.annotations" . | fromYaml) }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
25 changes: 7 additions & 18 deletions charts/membership/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,7 @@
"migration": {
"properties": {
"annotations": {
"properties": {
"helm.sh/hook": {
"type": "string"
},
"helm.sh/hook-delete-policy": {
"type": "string"
}
},
"properties": {},
"type": "object"
},
"postgresql": {
Expand Down Expand Up @@ -239,14 +232,7 @@
"serviceAccount": {
"properties": {
"annotations": {
"properties": {
"helm.sh/hook": {
"type": "string"
},
"helm.sh/hook-delete-policy": {
"type": "string"
}
},
"properties": {},
"type": "object"
},
"create": {
Expand Down Expand Up @@ -546,6 +532,9 @@
},
"managedStacks": {
"type": "boolean"
},
"migrationHooks": {
"type": "boolean"
}
},
"type": "object"
Expand Down Expand Up @@ -619,7 +608,7 @@
"type": "string"
},
"password": {
"type": "null"
"type": "string"
},
"secretKeys": {
"properties": {
Expand All @@ -633,7 +622,7 @@
"type": "object"
},
"user": {
"type": "null"
"type": "string"
}
},
"type": "object"
Expand Down
Loading

0 comments on commit 4ae344a

Please sign in to comment.