Skip to content

Commit

Permalink
feat: simplify chart naming and variables (#11)
Browse files Browse the repository at this point in the history
* chore: refactor chart name

* chore: rename to chatwoot-web and chatwoot-worker

* chore: Refactor Chart.yaml
  • Loading branch information
vishnu-narayanan committed Jul 23, 2021
1 parent 4404547 commit 7bba2c3
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 42 deletions.
23 changes: 16 additions & 7 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@ dependencies:
name: redis
repository: https://charts.bitnami.com/bitnami
version: 14.7.2
name: chatwoot-helm
description: A Helm chart for deploying Chatwoot on Kubernetes.
type: Application
name: chatwoot
description: Open-source customer engagement suite, an alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥
type: application
keywords:
- chatwoot
- open source
- helm
- kubernetes
- customer support
- chat
- ruby
- rails
- crm

type: application
maintainers:
- name: vishnu-narayanan
email: vishnu@chatwoot.com
- name: sojan-official
email: sojan@chatwoot.com

version: 0.3.0
#This is the chart version.
version: 0.4.0

#This is application version.
appVersion: "1.16.0"
2 changes: 1 addition & 1 deletion templates/_env_rails.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "chatwoot-helm.environ" }}
{{- define "chatwoot.environ" }}

- name: ACTIVE_STORAGE_SERVICE
valueFrom:
Expand Down
30 changes: 15 additions & 15 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chatwoot_helm.name" -}}
{{- define "chatwoot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -10,7 +10,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "chatwoot_helm.fullname" -}}
{{- define "chatwoot.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "chatwoot_helm.chart" -}}
{{- define "chatwoot.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "chatwoot_helm.labels" -}}
helm.sh/chart: {{ include "chatwoot_helm.chart" . }}
{{ include "chatwoot_helm.selectorLabels" . }}
{{- define "chatwoot.labels" -}}
helm.sh/chart: {{ include "chatwoot.chart" . }}
{{ include "chatwoot.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,55 +45,55 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "chatwoot_helm.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chatwoot_helm.name" . }}
{{- define "chatwoot.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chatwoot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "chatwoot_helm.serviceAccountName" -}}
{{- define "chatwoot.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "chatwoot_helm.fullname" .) .Values.serviceAccount.name }}
{{- default (include "chatwoot.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


{{- define "postgres.labels" }}
{{- include "chatwoot_helm.labels" . }}
{{- include "chatwoot.labels" . }}
component: database
name: {{ .Values.applicationArch.storage.db.name }}
version: {{ .Values.applicationArch.storage.db.version | quote }}
{{- end }}


{{- define "redis.labels" }}
{{- include "chatwoot_helm.labels" . }}
{{- include "chatwoot.labels" . }}
component: dataStore
name: {{ .Values.applicationArch.storage.dataStore.name}}
version: {{ .Values.applicationArch.storage.dataStore.version}}
{{- end }}


{{- define "rails.labels" }}
{{- include "chatwoot_helm.labels" . }}
{{- include "chatwoot.labels" . }}
component: rails
name: {{ .Values.applicationArch.rails.name}}
version: {{ .Values.applicationArch.rails.version}}
{{- end }}

{{- define "sidekiq.labels" }}
{{- include "chatwoot_helm.labels" . }}
{{- include "chatwoot.labels" . }}
component: rails
name: {{ .Values.applicationArch.backgroundProc.name}}
version: {{ .Values.applicationArch.backgroundProc.version}}
{{- end }}

{{- define "migration-job.labels" }}
{{- include "chatwoot_helm.labels" . }}
{{- include "chatwoot.labels" . }}
component: db-migration
name: db-migration
version: {{ .Values.applicationArch.rails.version}}
Expand Down
3 changes: 1 addition & 2 deletions templates/env-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ kind: ConfigMap
metadata:
creationTimestamp: null
labels:
{{- include "chatwoot_helm.labels" . | nindent 4 }}
{{- include "chatwoot.labels" . | nindent 4 }}

name: env
data:
{{- range $key, $value := .Values.env}}
{{ $key }}: {{ $value | quote }}
{{- end }}

4 changes: 2 additions & 2 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "chatwoot_helm.fullname" . -}}
{{- $fullName := include "chatwoot.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
Expand All @@ -10,7 +10,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "chatwoot_helm.labels" . | nindent 4 }}
{{- include "chatwoot.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/migrations-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ spec:
- rails
- db:chatwoot_prepare
env:
{{- include "chatwoot-helm.environ" . }}
{{- include "chatwoot.environ" . }}
imagePullPolicy: {{ .Values.deployment.image.imagePullPolicy }}
4 changes: 2 additions & 2 deletions templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "chatwoot_helm.serviceAccountName" . }}
name: {{ include "chatwoot.serviceAccountName" . }}
labels:
{{- include "chatwoot_helm.labels" . | nindent 4 }}
{{- include "chatwoot.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
6 changes: 3 additions & 3 deletions templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "chatwoot_helm.fullname" . }}-test-connection"
name: "{{ include "chatwoot.fullname" . }}-test-connection"
labels:
{{- include "chatwoot_helm.labels" . | nindent 4 }}
{{- include "chatwoot.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "chatwoot_helm.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include "chatwoot.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.applicationArch.rails.name }}-deployment
name: {{ template "chatwoot.fullname" . }}-web
creationTimestamp: null
labels:
{{- include "rails.labels" . | nindent 4}}
Expand Down Expand Up @@ -32,9 +32,9 @@ spec:
command:
- docker/entrypoints/rails.sh
env:
{{- include "chatwoot-helm.environ" . }}
{{- include "chatwoot.environ" . }}
image: "{{ .Values.deployment.image.dockerHub.chatwoot.owner }}/{{ .Values.deployment.image.dockerHub.chatwoot.repository }}:{{ .Values.deployment.image.dockerHub.chatwoot.tag }}"
name: {{ .Values.deployment.image.dockerHub.chatwoot.name }}
name: {{ .Chart.Name }}-web
ports:
- containerPort: {{ int .Values.deployment.image.dockerHub.chatwoot.port }}
imagePullPolicy: {{ .Values.deployment.image.imagePullPolicy }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: chatwoot-service
name: {{ template "chatwoot.fullname" . }}
creationTimestamp: null
labels:
{{- include "rails.labels" . | nindent 4}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
{{- include "sidekiq.labels" . | nindent 4 }}
name: {{ .Values.applicationArch.backgroundProc.name }}-sidekiq-deployment
name: {{ template "chatwoot.fullname" . }}-worker
spec:
replicas: {{ int .Values.deployment.image.dockerHub.chatwoot.replicaCount }}
selector:
Expand All @@ -25,9 +25,9 @@ spec:
- -C
- config/sidekiq.yml
env:
{{- include "chatwoot-helm.environ" . }}
{{- include "chatwoot.environ" . }}
image: "{{ .Values.deployment.image.dockerHub.chatwoot.owner }}/{{ .Values.deployment.image.dockerHub.chatwoot.repository }}:{{ .Values.deployment.image.dockerHub.chatwoot.tag }}"
name: sidekiq
name: {{ .Chart.Name }}-workers
resources: {}
imagePullPolicy: {{ .Values.deployment.image.imagePullPolicy }}

Expand Down
4 changes: 2 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Default values for chatwoot_helm.
# Default values for chatwoot.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
applicationArch:
Expand Down Expand Up @@ -46,7 +46,7 @@ deployment:

services:
rails:
name: rails-3000
name: chatwoot
port: 3000
targetPort: 3000
type: LoadBalancer
Expand Down

0 comments on commit 7bba2c3

Please sign in to comment.