[incubator/kafka] Add ability to mount secrets (#7233)

* [incubator/kafka] Add ability to mount secrets

* Provide the ability to mount secrets in the kafka brokers. This is useful when using custom authorizers.
* Add ability to pass environment variables

* [incubator/kafka] Update Readme, incorporate review suggestions
This commit is contained in:
Ravi Kumar
2018-08-26 19:19:39 -07:00
committed by k8s-ci-robot
parent aea0233510
commit f0fd1a8d82
4 changed files with 41 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v1
description: Apache Kafka is publish-subscribe messaging rethought as a distributed
commit log.
name: kafka
version: 0.8.8
version: 0.9.0
appVersion: 4.1.2
keywords:
- kafka
+1
View File
@@ -80,6 +80,7 @@ following configurable parameters:
| `external.annotations` | Additional annotations for the external service. | `{}` |
| `rbac.enabled` | Enable a service account and role for the init container to use in an RBAC enabled cluster | `false` |
| `configurationOverrides` | `Kafka ` [configuration setting][brokerconfigs] overrides in the dictionary format | `{ offsets.topic.replication.factor: 3 }` |
| `secrets` | `{}` | Pass any secrets to the kafka pods. Each secret will be passed as an environment variable by default. The secret can also be mounted to a specific path (in addition to environment variable) if required. Environment variable names are generated as: `<secretName>_<secretKey>` (All upper case)|
| `additionalPorts` | Additional ports to expose on brokers. Useful when the image exposes metrics (like prometheus, etc.) through a javaagent instead of a sidecar | `{}` |
| `readinessProbe.initialDelaySeconds` | Number of seconds before probe is initiated. | `30` |
| `readinessProbe.periodSeconds` | How often (in seconds) to perform the probe. | `10` |
@@ -173,6 +173,15 @@ spec:
- name: KAFKA_JMX_PORT
value: "{{ .Values.jmx.port }}"
{{- end }}
{{- range $secret := .Values.secrets }}
{{- range $key := $secret.keys }}
- name: {{ (print $secret.name "_" $key) | upper }}
valueFrom:
secretKeyRef:
name: {{ $secret.name }}
key: {{ $key }}
{{- end }}
{{- end }}
# This is required because the Downward API does not yet support identification of
# pod numbering in statefulsets. Thus, we are required to specify a command which
# allows us to extract the pod ID for usage as the Kafka Broker ID.
@@ -188,6 +197,16 @@ spec:
volumeMounts:
- name: datadir
mountPath: {{ .Values.persistence.mountPath | quote }}
{{- range $secret := .Values.secrets }}
{{- if $secret.mountPath }}
{{- range $key := $secret.keys }}
- name: {{ include "kafka.fullname" $ }}-{{ $secret.name }}
mountPath: {{ $secret.mountPath }}
subPath: {{ $key }}
readOnly: true
{{- end }}
{{- end }}
{{- end }}
volumes:
{{- if not .Values.persistence.enabled }}
- name: datadir
@@ -202,6 +221,11 @@ spec:
name: {{ include "kafka.fullname" . }}-metrics
{{- end }}
{{- end }}
{{- range .Values.secrets }}
- name: {{ include "kafka.fullname" $ }}-{{ .name }}
secret:
secretName: {{ .name }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
+15
View File
@@ -40,6 +40,21 @@ podManagementPolicy: OrderedReady
rbac:
enabled: false
## Useful if using any custom authorizer
## Pass in some secrets to use (if required)
# secrets:
# - name: myKafkaSecret
# keys:
# - username
# - password
# # mountPath: /opt/kafka/secret
# - name: myZkSecret
# keys:
# - user
# - pass
# mountPath: /opt/zookeeper/secret
## The name of the storage class which the cluster should use.
# storageClass: default