From c70de7acf2fadcaf0938db84146bf253e1ed0811 Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Wed, 18 Aug 2021 17:46:06 +0530 Subject: [PATCH] fix: selector issues when upgrading (#30) * fix: selector issues when upgrading * fix: labels for all k8s objects * doc: update readme to add upgrade notes --- charts/chatwoot/Chart.yaml | 2 +- charts/chatwoot/README.md | 18 +++++++++++++++ charts/chatwoot/templates/_helpers.tpl | 23 ------------------- charts/chatwoot/templates/env-configmap.yaml | 6 +++-- charts/chatwoot/templates/ingress.yaml | 5 +++- charts/chatwoot/templates/migrations-job.yaml | 5 +++- charts/chatwoot/templates/serviceaccount.yaml | 5 +++- charts/chatwoot/templates/web-deployment.yaml | 16 +++++++++---- charts/chatwoot/templates/web-service.yaml | 8 +++++-- .../chatwoot/templates/worker-deployment.yaml | 15 ++++++++---- 10 files changed, 63 insertions(+), 40 deletions(-) diff --git a/charts/chatwoot/Chart.yaml b/charts/chatwoot/Chart.yaml index c3e2f9d..8d52551 100644 --- a/charts/chatwoot/Chart.yaml +++ b/charts/chatwoot/Chart.yaml @@ -31,7 +31,7 @@ sources: - http://www.chatwoot.com # This is the chart version. -version: 0.5.6 +version: 0.6.0 # This is the application version. appVersion: "v1.18.2" diff --git a/charts/chatwoot/README.md b/charts/chatwoot/README.md index f6841ae..0519200 100644 --- a/charts/chatwoot/README.md +++ b/charts/chatwoot/README.md @@ -110,6 +110,7 @@ The command removes all the Kubernetes components associated with the chart and | `env.REDIS_SENTINELS` | Redis Sentinel can be used by passing list of sentinel host and ports. For example, `sentinel_host1:port1`, `sentinel_host2:port2` | `""` | | `env.REDIS_SENTINEL_MASTER_NAME` | Redis sentinel master name is required when using sentinel. | `""` | | `env.REDIS_URL` | REDIS url | `"redis://:redis@chatwoot-chatwoot-redis-master:6379"` | + ### Logging variables | Name | Type | Default Value | @@ -117,6 +118,7 @@ The command removes all the Kubernetes components associated with the chart and | `env.RAILS_LOG_TO_STDOUT` | string | `"true"` | | `env.LOG_LEVEL` | string | `"info"` | | `env.LOG_SIZE` | string | `"500"` | + ### Third party credentials | Name | Type | Default Value | @@ -212,3 +214,19 @@ PostgreSQL is installed along with the chart if you choose the default setup. To ## Redis Redis is installed along with the chart if you choose the default setup. To use an external Redis DB, please set `redis.enabled` to `false` and set the variables under the Redis section above + + +## Upgrading + + +## From 0.5.x to 0.6.x + +Existing labels were causing issues with `helm upgrade`. `0.6.x` introduces breaking changes related to selector +labels used for deployements. Please delete your helm release and recreate. Deleting your helm release will +not delete your persistent volumes used for redis and postgres and as such your data should be safe. + +``` +helm delete chatwoot +helm repo update +helm install chatwoot chatwoot/chatwoot +``` diff --git a/charts/chatwoot/templates/_helpers.tpl b/charts/chatwoot/templates/_helpers.tpl index 7b71ae5..3ad0038 100644 --- a/charts/chatwoot/templates/_helpers.tpl +++ b/charts/chatwoot/templates/_helpers.tpl @@ -60,26 +60,3 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} - - -{{- define "rails.labels" }} -{{- include "chatwoot.labels" . }} -component: rails -name: {{ .Values.services.name}} -version: {{ .Values.image.tag }} -{{- end }} - -{{- define "sidekiq.labels" }} -{{- include "chatwoot.labels" . }} -component: rails -name: sidekiq -{{- end }} - -{{- define "migration-job.labels" }} -{{- include "chatwoot.labels" . }} -component: db-migration -name: db-migration -version: {{ .Values.image.tag}} -chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" -release: "{{ .Release.Name }}" -{{- end }} diff --git a/charts/chatwoot/templates/env-configmap.yaml b/charts/chatwoot/templates/env-configmap.yaml index 0ca5d5e..e7e4b09 100644 --- a/charts/chatwoot/templates/env-configmap.yaml +++ b/charts/chatwoot/templates/env-configmap.yaml @@ -3,8 +3,10 @@ kind: ConfigMap metadata: creationTimestamp: null labels: - {{- include "chatwoot.labels" . | nindent 4 }} - + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" name: env data: {{- range $key, $value := .Values.env}} diff --git a/charts/chatwoot/templates/ingress.yaml b/charts/chatwoot/templates/ingress.yaml index eacb2c8..a2b5ce6 100644 --- a/charts/chatwoot/templates/ingress.yaml +++ b/charts/chatwoot/templates/ingress.yaml @@ -10,7 +10,10 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - {{- include "chatwoot.labels" . | nindent 4 }} + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/chatwoot/templates/migrations-job.yaml b/charts/chatwoot/templates/migrations-job.yaml index 59e81bb..ed427d1 100644 --- a/charts/chatwoot/templates/migrations-job.yaml +++ b/charts/chatwoot/templates/migrations-job.yaml @@ -3,7 +3,10 @@ kind: Job metadata: name: "{{ .Release.Name }}-migrate" labels: - {{- include "migration-job.labels" . | nindent 4}} + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" annotations: # This is what defines this resource as a hook. Without this line, the # job is considered part of the release. diff --git a/charts/chatwoot/templates/serviceaccount.yaml b/charts/chatwoot/templates/serviceaccount.yaml index 1273d72..75ed872 100644 --- a/charts/chatwoot/templates/serviceaccount.yaml +++ b/charts/chatwoot/templates/serviceaccount.yaml @@ -4,7 +4,10 @@ kind: ServiceAccount metadata: name: {{ include "chatwoot.serviceAccountName" . }} labels: - {{- include "chatwoot.labels" . | nindent 4 }} + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/chatwoot/templates/web-deployment.yaml b/charts/chatwoot/templates/web-deployment.yaml index fc78d01..c194a28 100644 --- a/charts/chatwoot/templates/web-deployment.yaml +++ b/charts/chatwoot/templates/web-deployment.yaml @@ -4,19 +4,25 @@ metadata: name: {{ template "chatwoot.fullname" . }}-web creationTimestamp: null labels: - {{- include "rails.labels" . | nindent 4}} + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" spec: replicas: {{ int .Values.web.replica }} selector: matchLabels: - {{- include "rails.labels" . | nindent 6 }} + app: {{ template "chatwoot.fullname" . }} + release: "{{ .Release.Name }}" + role: web strategy: {} template: metadata: - creationTimestamp: null labels: - {{- include "rails.labels" . | nindent 8 }} + app: {{ template "chatwoot.fullname" . }} + release: "{{ .Release.Name }}" + role: web spec: containers: - args: @@ -33,7 +39,7 @@ spec: - docker/entrypoints/rails.sh env: {{- include "chatwoot.environ" . }} - image: "{{ .Values.image.repository}}:{{ .Values.image.tag}}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" name: {{ .Chart.Name }}-web ports: - containerPort: {{ int .Values.services.internlPort }} diff --git a/charts/chatwoot/templates/web-service.yaml b/charts/chatwoot/templates/web-service.yaml index cb428a0..a488451 100644 --- a/charts/chatwoot/templates/web-service.yaml +++ b/charts/chatwoot/templates/web-service.yaml @@ -4,7 +4,10 @@ metadata: name: {{ template "chatwoot.fullname" . }} creationTimestamp: null labels: - {{- include "rails.labels" . | nindent 4}} + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" {{- with .Values.services.annotations }} annotations: {{- toYaml . | nindent 4 }} @@ -16,6 +19,7 @@ spec: targetPort: {{ int .Values.services.targetPort }} type: {{ .Values.services.type }} selector: - {{- include "rails.labels" . | nindent 4}} + app: {{ template "chatwoot.fullname" . }} + role: web status: loadBalancer: {} diff --git a/charts/chatwoot/templates/worker-deployment.yaml b/charts/chatwoot/templates/worker-deployment.yaml index 74d076c..49d9f01 100644 --- a/charts/chatwoot/templates/worker-deployment.yaml +++ b/charts/chatwoot/templates/worker-deployment.yaml @@ -1,21 +1,28 @@ apiVersion: apps/v1 kind: Deployment metadata: + name: {{ template "chatwoot.fullname" . }}-worker creationTimestamp: null labels: - {{- include "sidekiq.labels" . | nindent 4 }} - name: {{ template "chatwoot.fullname" . }}-worker + app: {{ template "chatwoot.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" spec: replicas: {{ int .Values.worker.replica }} selector: matchLabels: - {{- include "sidekiq.labels" . | nindent 6 }} + app: {{ template "chatwoot.fullname" . }} + release: "{{ .Release.Name }}" + role: worker strategy: {} template: metadata: creationTimestamp: null labels: - {{- include "sidekiq.labels" . | nindent 8 }} + app: {{ template "chatwoot.fullname" . }} + release: "{{ .Release.Name }}" + role: worker spec: containers: - args: