Skip to content

Commit 9aee5a6

Browse files
committed
Hubot: update and standardize
1 parent 765da7e commit 9aee5a6

File tree

8 files changed

+139
-13
lines changed

8 files changed

+139
-13
lines changed

hubot/files/scripts/health-check.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function(robot) {
2+
robot.router.get('/healthz', (req, res) => {
3+
res.json({ok: 200});
4+
});
5+
};

hubot/templates/_helpers.tpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1616
{{- end -}}
1717

1818
{{- define "hubot.environment" -}}
19+
1920
{{- $fullname := include "hubot.fullname" . -}}
2021
{{- range $key := keys .Values.configEnvs }}
2122
- name: {{ $key }}
@@ -24,11 +25,18 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
2425
name: {{ $fullname }}
2526
key: {{ $key }}
2627
{{- end }}
28+
{{- if .Values.redis.enabled }}
29+
- name: REDIS_URL
30+
valueFrom:
31+
secretKeyRef:
32+
name: {{ $fullname }}
33+
key: REDIS_URL
34+
{{- end }}
2735
{{- range $key := keys .Values.secretEnvs }}
2836
- name: {{ $key }}
2937
valueFrom:
3038
secretKeyRef:
3139
name: {{ $fullname }}
3240
key: {{ $key }}
33-
{{- end }}
41+
{{- end -}}
3442
{{- end -}}

hubot/templates/configmap.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ metadata:
88
heritage: {{ .Release.Service }}
99
release: {{ .Release.Name }}
1010
data:
11+
{{- define "hubot.inlineconfigs" }}
12+
{{- end }}
13+
{{- define "hubot.fileconfigs" -}}
14+
{{- range $path, $bytes := .Files.Glob "files/**" }}
15+
{{ $path | trimPrefix "files/" }}: |-
16+
{{- printf "%s" $bytes | nindent 2 }}
17+
{{- end -}}
18+
{{- end -}}
1119
{{- range $key, $value := .Values.configEnvs }}
12-
{{ $key }}: {{ $value | b64enc | quote }}
20+
{{ $key }}: {{ $value | quote }}
1321
{{- end }}
14-
{{- range $key, $value := .Values.configFiles }}
15-
{{ $key }}: {{ $value | b64enc | quote }}
22+
{{- range $key, $value := merge .Values.configFiles (include "hubot.inlineconfigs" . | fromYaml) (include "hubot.fileconfigs" . | fromYaml) }}
23+
{{ $key | replace "/" "-" }}: |-
24+
{{- $value | nindent 4 }}
1625
{{- end }}

hubot/templates/deployment.yaml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,38 @@ spec:
4444
imagePullPolicy: {{ .Values.image.pullPolicy }}
4545
env:
4646
{{- include "hubot.environment" . | nindent 12 }}
47-
# livenessProbe:
48-
# httpGet:
49-
# path: /
50-
# port: {{/* .Values.service.internalPort */}}
51-
# readinessProbe:
52-
# httpGet:
53-
# path: /
54-
# port: {{/* .Values.service.internalPort */}}
47+
ports:
48+
- name: http
49+
containerPort: {{ .Values.service.internalPort }}
50+
livenessProbe:
51+
httpGet:
52+
path: /healthz
53+
port: {{ .Values.service.internalPort }}
54+
initialDelaySeconds: 10
55+
readinessProbe:
56+
httpGet:
57+
path: /healthz
58+
port: {{ .Values.service.internalPort }}
59+
initialDelaySeconds: 10
5560
resources:
5661
{{- toYaml .Values.resources | nindent 12 }}
62+
volumeMounts:
63+
{{- range $key := keys (merge .Values.configFiles (include "hubot.inlineconfigs" . | fromYaml) (include "hubot.fileconfigs" . | fromYaml)) }}
64+
- mountPath: /code/{{ $key }}
65+
name: config
66+
subPath: {{ $key | replace "/" "-" }}
67+
readOnly: true
68+
{{- end }}
69+
{{- range $key := keys .Values.secretFiles }}
70+
- mountPath: /code/{{ $key }}
71+
name: secret
72+
subPath: {{ $key | replace "/" "-" }}
73+
readOnly: true
74+
{{- end }}
75+
volumes:
76+
- name: config
77+
configMap:
78+
name: {{ template "hubot.fullname" . }}
79+
- name: secret
80+
secret:
81+
secretName: {{ template "hubot.fullname" . }}

hubot/templates/ingress.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $serviceName := include "hubot.fullname" . -}}
3+
{{- $servicePort := .Values.service.externalPort -}}
4+
{{- $ingressPaths := .Values.ingress.paths -}}
5+
apiVersion: extensions/v1beta1
6+
kind: Ingress
7+
metadata:
8+
name: {{ template "hubot.fullname" . }}
9+
labels:
10+
app: {{ template "hubot.name" . }}
11+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
12+
heritage: {{ .Release.Service }}
13+
release: {{ .Release.Name }}
14+
annotations:
15+
{{- range $key, $value := .Values.ingress.annotations }}
16+
{{ $key }}: {{ $value | quote }}
17+
{{- end }}
18+
spec:
19+
rules:
20+
{{- range .Values.ingress.hosts }}
21+
- host: {{ . }}
22+
http:
23+
paths:
24+
{{- range $ingressPaths }}
25+
- path: {{ . }}
26+
backend:
27+
serviceName: {{ $serviceName }}
28+
servicePort: {{ $servicePort }}
29+
{{- end -}}
30+
{{- end -}}
31+
{{- if .Values.ingress.tls }}
32+
tls:
33+
{{- toYaml .Values.ingress.tls | nindent 4 }}
34+
{{- end -}}
35+
{{- end -}}

hubot/templates/secret.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ metadata:
99
release: {{ .Release.Name }}
1010
type: Opaque
1111
data:
12+
{{- if .Values.redis.enabled }}
13+
REDIS_URL: {{ printf "redis://:%s@%s:6379/0" .Values.redis.redisPassword (include "redis.fullname" .) | b64enc | quote }}
14+
{{- end }}
1215
{{- range $key, $value := .Values.secretEnvs }}
1316
{{ $key }}: {{ $value | b64enc | quote }}
1417
{{- end }}
1518
{{- range $key, $value := .Values.secretFiles }}
16-
{{ $key }}: {{ $value | b64enc | quote }}
19+
{{ $key | replace "/" "-" }}: {{ $value | b64enc | quote }}
1720
{{- end }}
1821

hubot/templates/service.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "hubot.fullname" . }}
5+
labels:
6+
app: {{ template "hubot.name" . }}
7+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
8+
heritage: {{ .Release.Service }}
9+
release: {{ .Release.Name }}
10+
spec:
11+
type: {{ .Values.service.type }}
12+
ports:
13+
- port: {{ .Values.service.externalPort }}
14+
targetPort: {{ .Values.service.internalPort }}
15+
protocol: TCP
16+
name: {{ .Values.service.name }}
17+
selector:
18+
app: {{ template "hubot.name" . }}
19+
release: {{ .Release.Name }}

hubot/values.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,28 @@ resources: {}
3030
# cpu: 100m
3131
# memory: 128Mi
3232

33+
service:
34+
name: hubot
35+
type: ClusterIP
36+
externalPort: 80
37+
internalPort: 8080
38+
39+
ingress:
40+
enabled: false
41+
# Used to create Ingress record (should used with service.type: ClusterIP).
42+
hosts:
43+
- chart-example.local
44+
paths:
45+
- /
46+
annotations:
47+
# kubernetes.io/ingress.class: nginx
48+
# kubernetes.io/tls-acme: "true"
49+
tls:
50+
# Secrets must be manually created in the namespace.
51+
# - secretName: chart-example-tls
52+
# hosts:
53+
# - chart-example.local
54+
3355
configEnvs: {}
3456

3557
configFiles: {}

0 commit comments

Comments
 (0)