Skip to content

Commit 941b8a9

Browse files
committed
Merge branch 'yGuy/master' into release
Support Helm chart
2 parents 798e880 + c6e5471 commit 941b8a9

File tree

8 files changed

+248
-0
lines changed

8 files changed

+248
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ docker compose down
213213
```
214214

215215

216+
## Deploy to Kubernetes with Helm
217+
The chatgpt-mattermost-bot chart deploys a containerized chatgpt-mattermost-bot instance which will connect to a running mattermost container in the same kubernetes cluster. Chart uses 'mattermost-team-edition' and the 'mattermost' namespace by default. Uses environment variables MATTERMOST_TOKEN and OPENAI_API_KEY.
218+
```bash
219+
helm upgrade chatgpt-mattermost-bot ./helm/chatgpt-mattermost-bot \
220+
--create-namespace \
221+
--install \
222+
-n mattermost \
223+
-f ./helm/chatgpt-mattermost-bot/values.yaml \
224+
--set config.MATTERMOST_TOKEN="$MATTERMOST_TOKEN" \
225+
--set config.OPENAI_API_KEY="$OPENAI_API_KEY"
226+
```
227+
216228
## Example Conversation
217229

218230
Here's an example chat that I just had with our bot:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: chatgpt-mattermost-bot
3+
description: A ChatGPT-powered Chatbot for Mattermost
4+
type: application
5+
version: 2.1.2
6+
appVersion: v2.1.2
7+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chatgpt-mattermost-bot.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "chatgpt-mattermost-bot.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "chatgpt-mattermost-bot.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "chatgpt-mattermost-bot.labels" -}}
37+
helm.sh/chart: {{ include "chatgpt-mattermost-bot.chart" . }}
38+
{{ include "chatgpt-mattermost-bot.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "chatgpt-mattermost-bot.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "chatgpt-mattermost-bot.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "chatgpt-mattermost-bot.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "chatgpt-mattermost-bot.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "chatgpt-mattermost-bot.fullname" . }}-config
5+
labels:
6+
app: chatgpt-mattermost-bot
7+
{{- include "chatgpt-mattermost-bot.labels" . | nindent 4 }}
8+
data:
9+
MATTERMOST_URL: "{{ required "MATTERMOST_URL is required" .Values.config.MATTERMOST_URL }}"
10+
OPENAI_MODEL_NAME: "{{ .Values.config.OPENAI_MODEL_NAME | default "gpt-3.5-turbo" }}"
11+
OPENAI_MAX_TOKENS: "{{ .Values.config.OPENAI_MAX_TOKENS | default "2000" }}"
12+
OPENAI_TEMPERATURE: "{{ .Values.config.OPENAI_TEMPERATURE | default "1" }}"
13+
YFILES_SERVER_URL: "{{ .Values.config.YFILES_SERVER_URL | default "" }}"
14+
NODE_EXTRA_CA_CERTS: "{{ .Values.config.NODE_EXTRA_CA_CERTS | default "" }}"
15+
MATTERMOST_BOTNAME: "{{ .Values.config.MATTERMOST_BOTNAME | default "@chatgpt" }}"
16+
PLUGINS: "{{ .Values.config.PLUGINS | default "graph-plugin, image-plugin" }}"
17+
DEBUG_LEVEL: "{{ .Values.config.DEBUG_LEVEL | default "INFO" }}"
18+
BOT_CONTEXT_MSG: "{{ .Values.config.BOT_CONTEXT_MSG | default "100" }}"
19+
NODE_ENV: "{{ .Values.config.NODE_ENV | default "production" }}"
20+
21+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "chatgpt-mattermost-bot.fullname" . }}-secret
5+
labels:
6+
app: chatgpt-mattermost-bot
7+
{{- include "chatgpt-mattermost-bot.labels" . | nindent 4 }}
8+
stringData:
9+
MATTERMOST_TOKEN: "{{ required "MATTERMOST_TOKEN is required" .Values.config.MATTERMOST_TOKEN }}"
10+
OPENAI_API_KEY: "{{ required "OPENAI_API_KEY is required" .Values.config.OPENAI_API_KEY }}"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "chatgpt-mattermost-bot.fullname" . }}
5+
labels:
6+
{{- include "chatgpt-mattermost-bot.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "chatgpt-mattermost-bot.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "chatgpt-mattermost-bot.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
serviceAccountName: {{ include "chatgpt-mattermost-bot.serviceAccountName" . }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
containers:
31+
- name: {{ .Chart.Name }}
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 12 }}
34+
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
envFrom:
37+
- configMapRef:
38+
name: {{ include "chatgpt-mattermost-bot.fullname" . }}-config
39+
- secretRef:
40+
name: {{ include "chatgpt-mattermost-bot.fullname" . }}-secret
41+
livenessProbe:
42+
exec:
43+
command:
44+
- pidof
45+
- node
46+
initialDelaySeconds: 5
47+
periodSeconds: 15
48+
failureThreshold: 4
49+
resources:
50+
{{- toYaml .Values.resources | nindent 12 }}
51+
{{- with .Values.nodeSelector }}
52+
nodeSelector:
53+
{{- toYaml . | nindent 8 }}
54+
{{- end }}
55+
{{- with .Values.affinity }}
56+
affinity:
57+
{{- toYaml . | nindent 8 }}
58+
{{- end }}
59+
{{- with .Values.tolerations }}
60+
tolerations:
61+
{{- toYaml . | nindent 8 }}
62+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "chatgpt-mattermost-bot.serviceAccountName" . }}
6+
labels:
7+
{{- include "chatgpt-mattermost-bot.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
image:
2+
registry: ghcr.io/yguy
3+
repository: chatgpt-mattermost-bot
4+
pullPolicy: IfNotPresent
5+
# Overrides the image tag whose default is the chart appVersion.
6+
tag: "v2.1.2"
7+
8+
imagePullSecrets: []
9+
10+
replicaCount: 1
11+
12+
nameOverride: ""
13+
fullnameOverride: "chatgpt-mattermost-bot"
14+
15+
config: # required: example: description:
16+
MATTERMOST_URL: "" # yes https://mattermost.server The URL to the server. This is used for connecting the bot to the Mattermost API
17+
MATTERMOST_TOKEN: "" # yes abababacdcdcd The authentication token from the logged in mattermost bot
18+
OPENAI_API_KEY: "" # yes sk-234234234234234234 The OpenAI API key to authenticate with OpenAI
19+
OPENAI_MODEL_NAME: "" # no gpt-3.5-turbo The OpenAI language model to use, defaults to gpt-3.5-turbo
20+
OPENAI_MAX_TOKENS: "" # no 2000 The maximum number of tokens to pass to the OpenAI API, defaults to 2000
21+
OPENAI_TEMPERATURE: "" # no 0.2 The sampling temperature to use, between 0 and 2, defaults to 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
22+
YFILES_SERVER_URL: "" # no http://localhost:3835 The URL to the yFiles graph service for embedding auto-generated diagrams.
23+
NODE_EXTRA_CA_CERTS: "" # no /file/to/cert.crt a link to a certificate file to pass to node.js for authenticating self-signed certificates
24+
MATTERMOST_BOTNAME: "" # no "@chatgpt" the name of the bot user in Mattermost, defaults to '@chatgpt'
25+
PLUGINS: "" # no graph-plugin, image-plugin The enabled plugins of the bot. By default, all plugins (grpah-plugin and image-plugin) are enabled.
26+
DEBUG_LEVEL: "" # no TRACE a debug level used for logging activity, defaults to INFO
27+
BOT_CONTEXT_MSG: "" # no 15 The number of previous messages which are appended to the conversation with ChatGPT, defaults to 100
28+
NODE_ENV: "" # no development The mode NodeJS runs in. Defaults to production
29+
30+
31+
serviceAccount:
32+
create: true
33+
annotations: {}
34+
name: ""
35+
36+
podAnnotations: {}
37+
38+
podSecurityContext:
39+
runAsNonRoot: true
40+
runAsUser: 10001
41+
runAsGroup: 10002
42+
43+
securityContext:
44+
runAsNonRoot: true
45+
runAsUser: 10001
46+
runAsGroup: 10002
47+
readOnlyRootFilesystem: true
48+
allowPrivilegeEscalation: false
49+
50+
resources: {}
51+
52+
autoscaling:
53+
enabled: false
54+
minReplicas: 1
55+
maxReplicas: 100
56+
targetCPUUtilizationPercentage: 80
57+
58+
nodeSelector: {}
59+
60+
tolerations: []
61+
62+
affinity: {}

0 commit comments

Comments
 (0)