Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional Credentials to nats-kafka #845

Merged
merged 8 commits into from
Dec 14, 2023
2 changes: 1 addition & 1 deletion helm/charts/nats-kafka/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
version: 0.15.2
version: 0.15.3
appVersion: 1.4.2
type: application
name: nats-kafka
Expand Down
28 changes: 28 additions & 0 deletions helm/charts/nats-kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,31 @@ natskafka:
topic: bar
subject: baz
```

**Using Nats Credentials**

If you need a nats credential for authentication:

```yaml
natskafka:
nats:
servers:
- "nats://1.2.3.4:4222"
credentials:
secret:
name: nats-sys-creds
key: sys.creds
connect:
- type: "NATSToKafka"
brokers:
- "1.2.3.4:9092"
id: whizz
topic: bar
subject: bang
- type: "KafkaToNATS"
brokers:
- "1.2.3.4:9092"
id: foo
topic: bar
subject: baz
```
3 changes: 3 additions & 0 deletions helm/charts/nats-kafka/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ data:
ConnectTimeout: {{ .Values.natskafka.nats.connectTimeout }},
MaxReconnects: {{ .Values.natskafka.nats.maxReconnects }},
ReconnectWait: {{ .Values.natskafka.nats.reconnectWait }},
{{- with .Values.natskafka.nats.credentials }}
UserCredentials: /etc/nats-kafka/creds/{{ .secret.key }},
{{- end }}
}

{{ if or .Values.natskafka.monitoring.httpPort .Values.natskafka.monitoring.httpsPort }}
Expand Down
10 changes: 10 additions & 0 deletions helm/charts/nats-kafka/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ spec:
mountPath: /etc/nats-kafka/tls
readOnly: true
{{ end }}
{{- if .Values.natskafka.nats.credentials }}
- name: creds-volume
mountPath: /etc/nats-kafka/creds
readOnly: true
{{- end }}
{{- if .Values.natskafka.additionalVolumeMounts }}
{{- toYaml .Values.natskafka.additionalVolumeMounts | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -83,6 +88,11 @@ spec:
secret:
secretName: {{ .Values.natskafka.monitoring.tls.secret }}
{{ end }}
{{- with .Values.natskafka.nats.credentials }}
- name: creds-volume
secret:
secretName: {{ .secret.name }}
{{- end }}
{{- if .Values.natskafka.additionalVolumes }}
{{- toYaml .Values.natskafka.additionalVolumes | nindent 8 }}
{{- end }}
8 changes: 8 additions & 0 deletions helm/charts/nats-kafka/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ natskafka:
connectTimeout: 5000
maxReconnects: 120
reconnectWait: 5000

# The credentials file to load in to connect to the NATS Server.
#
# credentials:
# secret:
# name: nats-sys-creds
# key: sys.creds

connect: []