Skip to content

Commit c275c06

Browse files
weltekialexellis
authored andcommitted
Add deployment template for jetstream-queue-worker
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent 9240d6f commit c275c06

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{{- if and .Values.async (eq .Values.nats.queueMode "jetstream") }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
labels:
6+
app: {{ template "openfaas.name" . }}
7+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
component: queue-worker
9+
heritage: {{ .Release.Service }}
10+
release: {{ .Release.Name }}
11+
name: queue-worker
12+
namespace: {{ .Release.Namespace | quote }}
13+
spec:
14+
replicas: {{ .Values.queueWorker.replicas }}
15+
selector:
16+
matchLabels:
17+
app: queue-worker
18+
template:
19+
metadata:
20+
annotations:
21+
prometheus.io/scrape: "true"
22+
prometheus.io/port: "8081"
23+
labels:
24+
app: queue-worker
25+
spec:
26+
volumes:
27+
{{- if .Values.openfaasPro }}
28+
- name: license
29+
secret:
30+
secretName: openfaas-license
31+
{{- end }}
32+
containers:
33+
- name: queue-worker
34+
resources:
35+
{{- .Values.queueWorker.resources | toYaml | nindent 12 }}
36+
image: {{ .Values.jetstreamQueueWorker.image }}
37+
imagePullPolicy: {{ .Values.openfaasImagePullPolicy }}
38+
command:
39+
- "jetstream-queue-worker"
40+
{{- if .Values.openfaasPro }}
41+
- "-license-file=/var/secrets/license/license"
42+
{{- end }}
43+
env:
44+
{{- if .Values.nats.external.enabled }}
45+
- name: nats_host
46+
value: "{{ .Values.nats.external.host }}"
47+
- name: nats_port
48+
value: "{{ .Values.nats.external.port }}"
49+
{{- else }}
50+
- name: nats_host
51+
value: "nats.{{ .Release.Namespace }}.svc.{{ .Values.kubernetesDNSDomain }}"
52+
{{- end}}
53+
- name: nats_stream
54+
value: "{{ .Values.nats.channel }}"
55+
- name: nats_durable
56+
value: "{{ .Values.jetstreamQueueWorker.durableName }}"
57+
- name: gateway_address
58+
value: "http://gateway.{{ .Release.Namespace }}.svc.{{ .Values.kubernetesDNSDomain }}"
59+
- name: ack_wait
60+
value: "{{ .Values.queueWorker.ackWait }}"
61+
- name: max_inflight
62+
value: "{{ .Values.queueWorker.maxInflight }}"
63+
64+
# OpenFaaS PRO license required
65+
- name: "max_retry_attempts"
66+
value: "{{ .Values.queueWorkerPro.maxRetryAttempts }}"
67+
- name: "max_retry_wait"
68+
value: "{{ .Values.queueWorkerPro.maxRetryWait }}"
69+
- name: "initial_retry_wait"
70+
value: "{{ .Values.queueWorkerPro.initialRetryWait }}"
71+
- name: "retry_http_codes"
72+
value: "{{ .Values.queueWorkerPro.httpRetryCodes }}"
73+
- name: print_request_body
74+
value: "{{ .Values.queueWorkerPro.printRequestBody }}"
75+
- name: print_response_body
76+
value: "{{ .Values.queueWorkerPro.printResponseBody }}"
77+
78+
volumeMounts:
79+
{{- if .Values.openfaasPro }}
80+
- name: license
81+
readOnly: true
82+
mountPath: "/var/secrets/license"
83+
{{- end }}
84+
{{- with .Values.nodeSelector }}
85+
nodeSelector:
86+
{{ toYaml . | indent 8 }}
87+
{{- end }}
88+
{{- with .Values.affinity }}
89+
affinity:
90+
{{ toYaml . | indent 8 }}
91+
{{- end }}
92+
{{- with .Values.tolerations }}
93+
tolerations:
94+
{{ toYaml . | indent 8 }}
95+
{{- end }}
96+
{{- end }}

chart/openfaas/templates/queueworker-dep.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.async }}
1+
{{- if and .Values.async (not (eq .Values.nats.queueMode "jetstream")) }}
22
apiVersion: apps/v1
33
kind: Deployment
44
metadata:

chart/openfaas/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ operator:
172172
requests:
173173
memory: "120Mi"
174174
cpu: "50m"
175+
176+
# The values for jetstreamQueueWorker are merged with those under
177+
# the "queueWorkerPro" and "queueWorker" section
178+
#
179+
# Enable automatically when nats.queueMode is set to "jetstream"
180+
jetstreamQueueWorker:
181+
image: docker.io/welteki2/jetstream-queue-worker:dev-amd64
182+
durableName: "faas-workers"
175183

176184
# OpenFaaS Pro
177185
# The values for queueWorkerPro are merged with those under

0 commit comments

Comments
 (0)