Skip to content

Commit

Permalink
Add optional Credentials to nats-kafka (#845)
Browse files Browse the repository at this point in the history
* Add optional userCredentials to nats-kafka

* Add nats-kafka credentials key and name

* Update nats-kafka readme to include nats credential usecase

* Update helm/charts/nats-kafka/templates/configmap.yaml

Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com>

* Update helm/charts/nats-kafka/templates/deployment.yaml

Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com>

* Update helm/charts/nats-kafka/templates/deployment.yaml

Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com>

* bump patch version

* Add nats kafka values credentials clarity

---------

Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com>
  • Loading branch information
ChrisDizenzo1047 and caleblloyd committed Dec 14, 2023
1 parent 0760c47 commit f3ba282
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
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: []

0 comments on commit f3ba282

Please sign in to comment.