From dd6975858ae6e8b14c90d4ee2a9b357dcbf93bec Mon Sep 17 00:00:00 2001 From: George Date: Mon, 5 Sep 2022 17:12:18 +0300 Subject: [PATCH] feat: setting env for slack and telegram from helm (#270) --- helm/oncall/README.md | 28 ++++++++++++++++ helm/oncall/templates/_env.tpl | 34 ++++++++++++++++++++ helm/oncall/templates/celery/_deployment.tpl | 2 ++ helm/oncall/templates/engine/deployment.yaml | 2 ++ helm/oncall/values.yaml | 13 ++++++++ 5 files changed, 79 insertions(+) diff --git a/helm/oncall/README.md b/helm/oncall/README.md index 7dc7dcd3..80d0d809 100644 --- a/helm/oncall/README.md +++ b/helm/oncall/README.md @@ -83,6 +83,34 @@ helm upgrade \ grafana/oncall ``` +### Set up Slack and Telegram + +You can set up Slack connection via following variables: + +``` +oncall: + slack: + enabled: true + command: ~ + clientId: ~ + clientSecret: ~ + apiToken: ~ + apiTokenCommon: ~ +``` + +`oncall.slack.command` is used for changing default bot slash command, +`oncall`. In slack, it could be called via `/`. + +To set up Telegram tokem and webhook url use: + +``` +oncall: + telegram: + enabled: true + token: ~ + webhookUrl: ~ +``` + ### Set up external access Grafana OnCall can be connected to the external monitoring systems or grafana deployed to the other cluster. Nginx Ingress Controller and Cert Manager charts are included in the helm chart with the default configuration. diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index b1769b83..ed3c2f83 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -23,6 +23,40 @@ value: "1024" {{- end }} +{{- define "snippet.oncall.slack.env" -}} +{{- if .Values.oncall.slack.enabled -}} +- name: FEATURE_SLACK_INTEGRATION_ENABLED + value: {{ .Values.oncall.slack.enabled | toString | title | quote }} +- name: SLACK_SLASH_COMMAND_NAME + value: "/{{ .Values.oncall.slack.commandName | default "oncall" }}" +- name: SLACK_CLIENT_OAUTH_ID + value: {{ .Values.oncall.slack.clientId | default "" | quote }} +- name: SLACK_CLIENT_OAUTH_SECRET + value: {{ .Values.oncall.slack.clientSecret | default "" | quote }} +- name: SLACK_API_TOKEN + value: {{ .Values.oncall.slack.apiToken | default "" | quote }} +- name: SLACK_API_TOKEN_COMMON + value: {{ .Values.oncall.slack.apiTokenCommon | default "" | quote }} +{{- else -}} +- name: FEATURE_SLACK_INTEGRATION_ENABLED + value: {{ .Values.oncall.slack.enabled | toString | title | quote }} +{{- end -}} +{{- end }} + +{{- define "snippet.oncall.telegram.env" -}} +{{- if .Values.oncall.telegram.enabled -}} +- name: FEATURE_TELEGRAM_INTEGRATION_ENABLED + value: {{ .Values.oncall.telegram.enabled | toString | title | quote }} +- name: TELEGRAM_WEBHOOK_URL + value: {{ .Values.oncall.telegram.webhookUrl | default "" | quote }} +- name: TELEGRAM_TOKEN + value: {{ .Values.oncall.telegram.token | default "" | quote }} +{{- else -}} +- name: FEATURE_TELEGRAM_INTEGRATION_ENABLED + value: {{ .Values.oncall.telegram.enabled | toString | title | quote }} +{{- end -}} +{{- end }} + {{- define "snippet.celery.env" -}} - name: CELERY_WORKER_QUEUE value: "default,critical,long,slack,telegram,webhook,celery" diff --git a/helm/oncall/templates/celery/_deployment.tpl b/helm/oncall/templates/celery/_deployment.tpl index e8a7d40c..45e50a0d 100644 --- a/helm/oncall/templates/celery/_deployment.tpl +++ b/helm/oncall/templates/celery/_deployment.tpl @@ -39,6 +39,8 @@ spec: env: {{- include "snippet.celery.env" . | nindent 12 }} {{- include "snippet.oncall.env" . | nindent 12 }} + {{- include "snippet.oncall.slack.env" . | nindent 12 }} + {{- include "snippet.oncall.telegram.env" . | nindent 12 }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/templates/engine/deployment.yaml b/helm/oncall/templates/engine/deployment.yaml index 9c9d0f76..391e0077 100644 --- a/helm/oncall/templates/engine/deployment.yaml +++ b/helm/oncall/templates/engine/deployment.yaml @@ -45,6 +45,8 @@ spec: protocol: TCP env: {{- include "snippet.oncall.env" . | nindent 12 }} + {{- include "snippet.oncall.slack.env" . | nindent 12 }} + {{- include "snippet.oncall.telegram.env" . | nindent 12 }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index 95ab565e..324498c7 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -40,6 +40,19 @@ celery: # cpu: 100m # memory: 128Mi +oncall: + slack: + enabled: false + command: ~ + clientId: ~ + clientSecret: ~ + apiToken: ~ + apiTokenCommon: ~ + telegram: + enabled: false + token: ~ + webhookUrl: ~ + # Whether to run django database migrations automatically migrate: enabled: true