Add chart kafka 32.4.3

This commit is contained in:
wbsong111
2025-09-08 09:52:45 +09:00
parent 02e7a7f905
commit e265ffe794
68 changed files with 10884 additions and 0 deletions
@@ -0,0 +1,23 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- $replicaCount := int .Values.controller.replicaCount }}
{{- if and (include "kafka.controller.createSecretConfig" .) (gt $replicaCount 0) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-secret-configuration" (include "kafka.controller.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
server-secret.properties: {{ include "kafka.controller.secretConfig" . | b64enc }}
{{- end }}
@@ -0,0 +1,56 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{/*
Return the Kafka controller configuration.
ref: https://kafka.apache.org/documentation/#configuration
*/}}
{{- define "kafka.controller.config" -}}
{{- if or .Values.config .Values.controller.config }}
{{- include "common.tplvalues.render" (dict "value" (coalesce .Values.controller.config .Values.config) "context" .) }}
{{- else }}
# Listeners configuration
listeners: {{ include "kafka.listeners" (dict "isController" true "context" .) }}
listener.security.protocol.map: {{ include "kafka.securityProtocolMap" (dict "isController" true "context" .) }}
{{- if not .Values.controller.controllerOnly }}
advertised.listeners: {{ include "kafka.advertisedListeners" . }}
inter.broker.listener.name: {{ .Values.listeners.interbroker.name }}
{{- end }}
# Kafka data logs directory
log.dir: {{ printf "%s/data" .Values.controller.persistence.mountPath }}
# Kafka application logs directory
logs.dir: {{ .Values.controller.logPersistence.mountPath }}
# KRaft node role
process.roles: {{ ternary "controller" "controller,broker" .Values.controller.controllerOnly }}
# Common Kafka Configuration
{{ include "kafka.commonConfig" . }}
{{- end -}}
{{- end -}}
{{- $replicaCount := int .Values.controller.replicaCount }}
{{- if and (include "kafka.controller.createConfigmap" .) (gt $replicaCount 0) }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-configuration" (include "kafka.controller.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
{{- $configuration := include "kafka.controller.config" . | fromYaml -}}
{{- if or .Values.overrideConfiguration .Values.controller.overrideConfiguration }}
{{- $overrideConfiguration := include "common.tplvalues.render" (dict "value" .Values.overrideConfiguration "context" .) | fromYaml }}
{{- $controllerOverrideConfiguration := include "common.tplvalues.render" (dict "value" .Values.controller.overrideConfiguration "context" .) | fromYaml }}
{{- $configuration = mustMergeOverwrite $configuration $overrideConfiguration $controllerOverrideConfiguration }}
{{- end }}
server.properties: |-
{{- range $key, $value := $configuration }}
{{ $key }}={{ include "common.tplvalues.render" (dict "value" $value "context" $) }}
{{- end }}
{{- end }}
@@ -0,0 +1,43 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.controller.autoscaling.hpa.enabled }}
apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "kafka.controller.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if or .Values.controller.autoscaling.hpa.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.controller.autoscaling.hpa.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: {{ template "common.capabilities.statefulset.apiVersion" . }}
kind: StatefulSet
name: {{ template "kafka.controller.fullname" . }}
minReplicas: {{ .Values.controller.autoscaling.hpa.minReplicas }}
maxReplicas: {{ .Values.controller.autoscaling.hpa.maxReplicas }}
metrics:
{{- if .Values.controller.autoscaling.hpa.targetCPU }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.controller.autoscaling.hpa.targetCPU }}
{{- end }}
{{- if .Values.controller.autoscaling.hpa.targetMemory }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.controller.autoscaling.hpa.targetMemory }}
{{- end }}
{{- end }}
@@ -0,0 +1,101 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- $replicaCount := int .Values.controller.replicaCount }}
{{- if and .Values.networkPolicy.enabled (or (gt $replicaCount 0) .Values.controller.autoscaling.hpa.enabled) }}
kind: NetworkPolicy
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
metadata:
name: {{ template "kafka.controller.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.controller.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
policyTypes:
- Ingress
- Egress
{{- if .Values.networkPolicy.allowExternalEgress }}
egress:
- {}
{{- else }}
egress:
# Allow dns resolution
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow internal communications between nodes
- ports:
- port: {{ .Values.listeners.controller.containerPort }}
{{- if not .Values.controller.controllerOnly }}
- port: {{ .Values.listeners.client.containerPort }}
- port: {{ .Values.listeners.interbroker.containerPort }}
{{- range $listener := .Values.listeners.extraListeners }}
- port: {{ $listener.containerPort }}
{{- end }}
{{- end }}
{{- if .Values.externalAccess.enabled }}
- port: {{ .Values.listeners.external.containerPort }}
{{- end }}
to:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
{{- if .Values.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
ingress:
# Allow client connections
- ports:
- port: {{ .Values.listeners.controller.containerPort }}
{{- if not .Values.controller.controllerOnly }}
- port: {{ .Values.listeners.client.containerPort }}
- port: {{ .Values.listeners.interbroker.containerPort }}
{{- range $listener := .Values.listeners.extraListeners }}
- port: {{ $listener.containerPort }}
{{- end }}
{{- end }}
{{- if .Values.externalAccess.enabled }}
- port: {{ .Values.listeners.external.containerPort }}
{{- end }}
{{- if .Values.metrics.jmx.enabled }}
- port: {{ .Values.metrics.jmx.containerPorts.metrics }}
{{- end }}
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
{{- if and .Values.networkPolicy.addExternalClientAccess (not .Values.controller.controllerOnly) }}
- podSelector:
matchLabels:
{{ template "common.names.fullname" . }}-client: "true"
{{- end }}
{{- if .Values.networkPolicy.ingressPodMatchLabels }}
- podSelector:
matchLabels: {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressPodMatchLabels "context" $ ) | nindent 14 }}
{{- end }}
{{- if .Values.networkPolicy.ingressNSMatchLabels }}
- namespaceSelector:
matchLabels: {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressNSMatchLabels "context" $ ) | nindent 14 }}
{{- if .Values.networkPolicy.ingressNSPodMatchLabels }}
podSelector:
matchLabels: {{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.ingressNSPodMatchLabel "context" $ ) | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,30 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.controller.pdb.create }}
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ template "kafka.controller.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if .Values.controller.pdb.minAvailable }}
minAvailable: {{ .Values.controller.pdb.minAvailable }}
{{- end }}
{{- if or .Values.controller.pdb.maxUnavailable (not .Values.controller.pdb.minAvailable) }}
maxUnavailable: {{ .Values.controller.pdb.maxUnavailable | default 1 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.controller.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- end }}
@@ -0,0 +1,425 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
kind: StatefulSet
metadata:
name: {{ template "kafka.controller.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
podManagementPolicy: {{ .Values.controller.podManagementPolicy }}
{{- if not .Values.controller.autoscaling.hpa.enabled }}
replicas: {{ .Values.controller.replicaCount }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.controller.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
serviceName: {{ printf "%s-headless" (include "kafka.controller.fullname" .) | trunc 63 | trimSuffix "-" }}
updateStrategy: {{- include "common.tplvalues.render" (dict "value" .Values.controller.updateStrategy "context" $ ) | nindent 4 }}
{{- if .Values.controller.minReadySeconds }}
minReadySeconds: {{ .Values.controller.minReadySeconds }}
{{- end }}
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
annotations:
{{- if include "kafka.controller.createConfigmap" . }}
checksum/configuration: {{ include (print $.Template.BasePath "/controller-eligible/configmap.yaml") . | sha256sum }}
{{- end }}
{{- if or (include "kafka.createSaslSecret" .) (not .Values.existingKraftSecret) }}
checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
{{- end }}
{{- if include "kafka.createTlsSecret" . }}
checksum/tls-secret: {{ include (print $.Template.BasePath "/tls-secret.yaml") . | sha256sum }}
{{- end }}
{{- if include "kafka.metrics.jmx.createConfigmap" . }}
checksum/jmx-configuration: {{ include (print $.Template.BasePath "/metrics/jmx-configmap.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.controller.podAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.controller.podAnnotations "context" $) | nindent 8 }}
{{- end }}
spec:
{{- include "kafka.imagePullSecrets" . | nindent 6 }}
automountServiceAccountToken: {{ .Values.controller.automountServiceAccountToken }}
{{- if .Values.controller.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.controller.hostAliases "context" $) | nindent 8 }}
{{- end }}
hostNetwork: {{ .Values.controller.hostNetwork }}
hostIPC: {{ .Values.controller.hostIPC }}
{{- if .Values.controller.schedulerName }}
schedulerName: {{ .Values.controller.schedulerName | quote }}
{{- end }}
{{- if .Values.controller.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.controller.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.controller.podAffinityPreset "component" "controller-eligible" "customLabels" $podLabels "topologyKey" .Values.controller.topologyKey "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.controller.podAntiAffinityPreset "component" "controller-eligible" "customLabels" $podLabels "topologyKey" .Values.controller.topologyKey "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.controller.nodeAffinityPreset.type "key" .Values.controller.nodeAffinityPreset.key "values" .Values.controller.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.controller.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.controller.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.controller.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.controller.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.controller.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.controller.topologySpreadConstraints "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.controller.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
{{- end }}
{{- if .Values.controller.priorityClassName }}
priorityClassName: {{ .Values.controller.priorityClassName }}
{{- end }}
{{- if .Values.controller.runtimeClassName }}
runtimeClassName: {{ .Values.controller.runtimeClassName }}
{{- end }}
{{- if .Values.controller.podSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.controller.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "kafka.serviceAccountName" . }}
enableServiceLinks: {{ .Values.controller.enableServiceLinks }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy }}
{{- end }}
{{- if .Values.dnsConfig }}
dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.dnsConfig "context" $) | nindent 8 }}
{{- end }}
initContainers:
{{- if and .Values.defaultInitContainers.volumePermissions.enabled .Values.controller.persistence.enabled }}
{{- include "kafka.defaultInitContainers.volumePermissions" (dict "context" . "role" "controller") | nindent 8 }}
{{- end }}
{{- if and .Values.externalAccess.enabled .Values.defaultInitContainers.autoDiscovery.enabled (or .Values.externalAccess.controller.forceExpose (not .Values.controller.controllerOnly)) }}
{{- include "kafka.defaultInitContainers.autoDiscovery" (dict "context" . "role" "controller") | nindent 8 }}
{{- end }}
{{- include "kafka.defaultInitContainers.prepareConfig" (dict "context" . "role" "controller") | nindent 8 }}
{{- if .Values.controller.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" .Values.controller.initContainers "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" .Values.initContainers "context" $ ) | nindent 8 }}
{{- end }}
containers:
- name: kafka
image: {{ include "kafka.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.controller.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.controller.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
{{- else if .Values.controller.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.controller.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.controller.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.controller.args "context" $) | nindent 12 }}
{{- end }}
env:
- name: KAFKA_HEAP_OPTS
value: {{ coalesce .Values.controller.heapOpts .Values.heapOpts | quote }}
- name: KAFKA_CFG_PROCESS_ROLES
value: {{ ternary "controller" "controller,broker" .Values.controller.controllerOnly | quote }}
- name: KAFKA_INITIAL_CONTROLLERS_FILE
value: /shared/initial-controllers.txt
{{- include "kafka.commonEnv" . | nindent 12 }}
{{- if .Values.controller.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.controller.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
{{- if or .Values.controller.extraEnvVarsCM .Values.extraEnvVarsCM .Values.controller.extraEnvVarsSecret .Values.extraEnvVarsSecret }}
envFrom:
{{- if .Values.controller.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.controller.extraEnvVarsCM "context" $) }}
{{- end }}
{{- if .Values.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }}
{{- end }}
{{- if .Values.controller.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.controller.extraEnvVarsSecret "context" $) }}
{{- end }}
{{- if .Values.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
{{- end }}
{{- end }}
ports:
- name: controller
containerPort: {{ .Values.listeners.controller.containerPort }}
{{- if not .Values.controller.controllerOnly }}
- name: client
containerPort: {{ .Values.listeners.client.containerPort }}
- name: interbroker
containerPort: {{ .Values.listeners.interbroker.containerPort }}
{{- if .Values.externalAccess.enabled }}
- name: external
containerPort: {{ .Values.listeners.external.containerPort }}
{{- end }}
{{- if and .Values.listeners.extraListeners (not .Values.controller.controllerOnly) }}
{{- include "kafka.extraListeners.containerPorts" . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.controller.extraContainerPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.controller.extraContainerPorts "context" $) | nindent 12 }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.controller.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.controller.customLivenessProbe "context" $) | nindent 12 }}
{{- else if .Values.controller.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.controller.livenessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- pgrep
- -f
- kafka
{{- end }}
{{- if .Values.controller.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.controller.customReadinessProbe "context" $) | nindent 12 }}
{{- else if .Values.controller.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.controller.readinessProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: "controller"
{{- end }}
{{- if .Values.controller.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.controller.customStartupProbe "context" $) | nindent 12 }}
{{- else if .Values.controller.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.controller.startupProbe "enabled") "context" $) | nindent 12 }}
tcpSocket:
port: "controller"
{{- end }}
{{- end }}
{{- if .Values.controller.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.controller.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.controller.resources }}
resources: {{- toYaml .Values.controller.resources | nindent 12 }}
{{- else if ne .Values.controller.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.controller.resourcesPreset) | nindent 12 }}
{{- end }}
volumeMounts:
- name: data
mountPath: {{ .Values.controller.persistence.mountPath }}
- name: logs
mountPath: {{ .Values.controller.logPersistence.mountPath }}
- name: kafka-config
mountPath: /opt/bitnami/kafka/config/server.properties
subPath: server.properties
- name: tmp
mountPath: /tmp
- name: init-shared
mountPath: /shared
{{- if or .Values.log4j2 .Values.existingLog4j2ConfigMap }}
- name: log4j2-config
mountPath: /opt/bitnami/kafka/config/log4j2.yaml
subPath: log4j2.yaml
{{- end }}
{{- if include "kafka.sslEnabled" . }}
- name: kafka-shared-certs
mountPath: /opt/bitnami/kafka/config/certs
readOnly: true
{{- end }}
{{- if and .Values.usePasswordFiles (include "kafka.saslEnabled" .) }}
- name: kafka-sasl
mountPath: /opt/bitnami/kafka/config/secrets
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.controller.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.controller.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.metrics.jmx.enabled }}
- name: jmx-exporter
image: {{ include "kafka.metrics.jmx.image" . }}
imagePullPolicy: {{ .Values.metrics.jmx.image.pullPolicy | quote }}
{{- if .Values.metrics.jmx.containerSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.metrics.jmx.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
command:
- java
args:
- -XX:MaxRAMPercentage=100
- -XshowSettings:vm
- -jar
- jmx_prometheus_standalone.jar
- {{ .Values.metrics.jmx.containerPorts.metrics | quote }}
- /etc/jmx-kafka/jmx-kafka-prometheus.yml
{{- end }}
ports:
- name: metrics
containerPort: {{ .Values.metrics.jmx.containerPorts.metrics }}
{{- if .Values.metrics.jmx.resources }}
resources: {{- toYaml .Values.metrics.jmx.resources | nindent 12 }}
{{- else if ne .Values.metrics.jmx.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.metrics.jmx.resourcesPreset) | nindent 12 }}
{{- end }}
{{- if .Values.metrics.jmx.livenessProbe.enabled }}
livenessProbe: {{- omit .Values.metrics.jmx.livenessProbe "enabled" | toYaml | nindent 12 }}
tcpSocket:
port: metrics
{{- end }}
{{- if .Values.metrics.jmx.readinessProbe.enabled }}
readinessProbe: {{- omit .Values.metrics.jmx.readinessProbe "enabled" | toYaml | nindent 12 }}
httpGet:
path: /
port: metrics
{{- end }}
volumeMounts:
- name: jmx-config
mountPath: /etc/jmx-kafka
{{- end }}
{{- if .Values.controller.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.controller.sidecars "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
- name: kafka-configmaps
configMap:
name: {{ include "kafka.controller.configmapName" . }}
- name: kafka-secret-config
{{- if (include "kafka.controller.secretConfigExists" .) }}
secret:
secretName: {{ include "kafka.controller.secretConfigName" . }}
{{- else }}
emptyDir: {}
{{- end }}
- name: kafka-config
emptyDir: {}
- name: tmp
emptyDir: {}
- name: init-shared
emptyDir: {}
{{- if or .Values.log4j2 .Values.existingLog4j2ConfigMap }}
- name: log4j2-config
configMap:
name: {{ include "kafka.log4j2.configMapName" . }}
{{- end }}
{{- if .Values.metrics.jmx.enabled }}
- name: jmx-config
configMap:
name: {{ include "kafka.metrics.jmx.configmapName" . }}
{{- end }}
{{- if include "kafka.sslEnabled" . }}
- name: kafka-shared-certs
emptyDir: {}
{{- if or .Values.tls.existingSecret .Values.tls.autoGenerated.enabled }}
- name: kafka-certs
projected:
defaultMode: 256
sources:
- secret:
name: {{ include "kafka.tlsSecretName" . }}
{{- if .Values.tls.jksTruststoreSecret }}
- secret:
name: {{ .Values.tls.jksTruststoreSecret }}
{{- end }}
{{- end }}
{{- end }}
{{- if and .Values.usePasswordFiles (include "kafka.saslEnabled" .) }}
- name: kafka-sasl
projected:
sources:
- secret:
name: {{ include "kafka.saslSecretName" . }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.controller.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.controller.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- if not .Values.controller.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.controller.persistence.existingClaim }}
- name: data
persistentVolumeClaim:
claimName: {{ printf "%s" (tpl .Values.controller.persistence.existingClaim .) }}
{{- end }}
{{- if not .Values.controller.logPersistence.enabled }}
- name: logs
emptyDir: {}
{{- else if .Values.controller.logPersistence.existingClaim }}
- name: logs
persistentVolumeClaim:
claimName: {{ printf "%s" (tpl .Values.controller.logPersistence.existingClaim .) }}
{{- end }}
{{- if or (and .Values.controller.persistence.enabled (not .Values.controller.persistence.existingClaim)) (and .Values.controller.logPersistence.enabled (not .Values.controller.logPersistence.existingClaim)) }}
{{- if .Values.controller.persistentVolumeClaimRetentionPolicy.enabled }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.controller.persistentVolumeClaimRetentionPolicy.whenDeleted }}
whenScaled: {{ .Values.controller.persistentVolumeClaimRetentionPolicy.whenScaled }}
{{- end }}
volumeClaimTemplates:
{{- if and .Values.controller.persistence.enabled (not .Values.controller.persistence.existingClaim) }}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
{{- if .Values.controller.persistence.annotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.controller.persistence.annotations "context" $) | nindent 10 }}
{{- end }}
{{- if .Values.controller.persistence.labels }}
labels: {{- include "common.tplvalues.render" (dict "value" .Values.controller.persistence.labels "context" $) | nindent 10 }}
{{- end }}
spec:
accessModes:
{{- range .Values.controller.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.controller.persistence.size | quote }}
{{- include "common.storage.class" (dict "persistence" .Values.controller.persistence "global" .Values.global) | nindent 8 }}
{{- if .Values.controller.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.controller.persistence.selector "context" $) | nindent 10 }}
{{- end -}}
{{- end }}
{{- if and .Values.controller.logPersistence.enabled (not .Values.controller.logPersistence.existingClaim) }}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: logs
{{- if .Values.controller.logPersistence.annotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.controller.logPersistence.annotations "context" $) | nindent 10 }}
{{- end }}
spec:
accessModes:
{{- range .Values.controller.logPersistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.controller.logPersistence.size | quote }}
{{- include "common.storage.class" (dict "persistence" .Values.controller.logPersistence "global" .Values.global) | nindent 8 }}
{{- if .Values.controller.logPersistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.controller.logPersistence.selector "context" $) | nindent 10 }}
{{- end -}}
{{- end }}
{{- end }}
@@ -0,0 +1,77 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.externalAccess.enabled }}
{{- $fullname := include "kafka.controller.fullname" . }}
{{- if or .Values.externalAccess.controller.forceExpose (not .Values.controller.controllerOnly)}}
{{- $replicaCount := .Values.controller.replicaCount | int }}
{{- range $i := until $replicaCount }}
{{- $targetPod := printf "%s-%d" $fullname $i }}
{{- $_ := set $ "targetPod" $targetPod }}
apiVersion: v1
kind: Service
metadata:
name: {{ printf "%s-%d-external" $fullname $i | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" $ | quote }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.externalAccess.controller.service.labels $.Values.commonLabels ) "context" $ ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: kafka
pod: {{ $targetPod }}
{{- if or $.Values.externalAccess.controller.service.annotations $.Values.commonAnnotations $.Values.externalAccess.controller.service.loadBalancerAnnotations }}
annotations:
{{- if and (not (empty $.Values.externalAccess.controller.service.loadBalancerAnnotations)) (eq (len $.Values.externalAccess.controller.service.loadBalancerAnnotations) $replicaCount) }}
{{ include "common.tplvalues.render" ( dict "value" (index $.Values.externalAccess.controller.service.loadBalancerAnnotations $i) "context" $) | nindent 4 }}
{{- end }}
{{- if or $.Values.externalAccess.controller.service.annotations $.Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $.Values.externalAccess.controller.service.annotations $.Values.commonAnnotations ) "context" $ ) }}
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ $.Values.externalAccess.controller.service.type }}
{{- if eq $.Values.externalAccess.controller.service.type "LoadBalancer" }}
allocateLoadBalancerNodePorts: {{ $.Values.externalAccess.controller.service.allocateLoadBalancerNodePorts }}
{{- if (not (empty $.Values.externalAccess.controller.service.loadBalancerClass)) }}
loadBalancerClass: {{ $.Values.externalAccess.controller.service.loadBalancerClass }}
{{- end }}
{{- if and (not (empty $.Values.externalAccess.controller.service.loadBalancerIPs)) (eq (len $.Values.externalAccess.controller.service.loadBalancerIPs) $replicaCount) }}
loadBalancerIP: {{ index $.Values.externalAccess.controller.service.loadBalancerIPs $i }}
{{- end }}
{{- if $.Values.externalAccess.controller.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{- toYaml $.Values.externalAccess.controller.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
{{- end }}
publishNotReadyAddresses: {{ $.Values.externalAccess.controller.service.publishNotReadyAddresses }}
ports:
- name: tcp-kafka
port: {{ $.Values.externalAccess.controller.service.ports.external }}
{{- if le (add $i 1) (len $.Values.externalAccess.controller.service.nodePorts) }}
nodePort: {{ index $.Values.externalAccess.controller.service.nodePorts $i }}
{{- else }}
nodePort: null
{{- end }}
targetPort: external
{{- if $.Values.externalAccess.controller.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" $.Values.externalAccess.controller.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
{{- if and (eq $.Values.externalAccess.controller.service.type "NodePort") (le (add $i 1) (len $.Values.externalAccess.controller.service.externalIPs)) }}
externalIPs: [{{ index $.Values.externalAccess.controller.service.externalIPs $i | quote }}]
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $.Values.controller.podLabels $.Values.commonLabels ) "context" $ ) }}
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: kafka
app.kubernetes.io/component: controller-eligible
statefulset.kubernetes.io/pod-name: {{ $targetPod }}
{{- with $.Values.externalAccess.controller.service.ipFamilyPolicy }}
ipFamilyPolicy: {{ . | quote }}
{{- end }}
{{- with $.Values.externalAccess.controller.service.ipFamilies }}
ipFamilies:
{{- . | toYaml | nindent 2 }}
{{- end }}
---
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,48 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
apiVersion: v1
kind: Service
metadata:
name: {{ printf "%s-headless" (include "kafka.controller.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.headless.controller.labels .Values.commonLabels ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if or .Values.service.headless.controller.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.headless.controller.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
{{- if not .Values.controller.controllerOnly }}
- name: tcp-interbroker
port: {{ .Values.service.ports.interbroker }}
protocol: TCP
targetPort: interbroker
- name: tcp-client
port: {{ .Values.service.ports.client }}
protocol: TCP
targetPort: client
{{- end }}
- name: tcp-controller
protocol: TCP
port: {{ .Values.service.ports.controller }}
targetPort: controller
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.controller.podLabels .Values.commonLabels ) "context" . ) }}
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- with .Values.service.headless.ipFamilyPolicy }}
ipFamilyPolicy: {{ . | quote }}
{{- end }}
{{- with .Values.service.headless.ipFamilies }}
ipFamilies:
{{- . | toYaml | nindent 2 }}
{{- end }}
@@ -0,0 +1,45 @@
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and (include "common.capabilities.apiVersions.has" ( dict "version" "autoscaling.k8s.io/v1/VerticalPodAutoscaler" "context" . )) .Values.controller.autoscaling.vpa.enabled }}
apiVersion: {{ include "common.capabilities.vpa.apiVersion" . }}
kind: VerticalPodAutoscaler
metadata:
name: {{ template "kafka.controller.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: controller-eligible
app.kubernetes.io/part-of: kafka
{{- if or .Values.controller.autoscaling.vpa.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.controller.autoscaling.vpa.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
resourcePolicy:
containerPolicies:
- containerName: kafka
{{- with .Values.controller.autoscaling.vpa.controlledResources }}
controlledResources:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.autoscaling.vpa.maxAllowed }}
maxAllowed:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.autoscaling.vpa.minAllowed }}
minAllowed:
{{- toYaml . | nindent 8 }}
{{- end }}
targetRef:
apiVersion: {{ (include "common.capabilities.statefulset.apiVersion" .) }}
kind: StatefulSet
name: {{ template "kafka.controller.fullname" . }}
{{- if .Values.controller.autoscaling.vpa.updatePolicy }}
updatePolicy:
{{- with .Values.controller.autoscaling.vpa.updatePolicy.updateMode }}
updateMode: {{ . }}
{{- end }}
{{- end }}
{{- end }}