-
Notifications
You must be signed in to change notification settings - Fork 32
[Kafka] Change Kafka installation - multi namespace support #213
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
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| .idea/* | ||
| charts/mlrun-ce/charts/* | ||
| .DS_Store | ||
| **/.DS_Store | ||
| *.DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| {{- if .Values.kafka.bootstrapAlias.enabled }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: {{ .Values.kafka.bootstrapAlias.name | default "kafka-stream" }} | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| app.kubernetes.io/name: kafka | ||
| app.kubernetes.io/component: bootstrap-alias | ||
| {{- include "mlrun-ce.common.labels" . | nindent 4 }} | ||
| spec: | ||
| type: ClusterIP | ||
| ports: | ||
| - name: client | ||
| port: 9092 | ||
| targetPort: 9092 | ||
| protocol: TCP | ||
| selector: | ||
| strimzi.io/cluster: {{ .Values.kafka.name | default "kafka-stream" }} | ||
| strimzi.io/kind: Kafka | ||
| strimzi.io/name: {{ .Values.kafka.name | default "kafka-stream" }}-kafka | ||
| {{- end }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||
| {{- if .Values.kafka.enabled }} | ||||||||||||||||||||||||||
| apiVersion: kafka.strimzi.io/v1beta2 | ||||||||||||||||||||||||||
| kind: Kafka | ||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||
| name: {{ .Values.kafka.name }} | ||||||||||||||||||||||||||
| namespace: {{ .Values.kafka.namespace | default .Release.Namespace }} | ||||||||||||||||||||||||||
shay79il marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| labels: | ||||||||||||||||||||||||||
| app.kubernetes.io/name: kafka | ||||||||||||||||||||||||||
| app.kubernetes.io/component: cluster | ||||||||||||||||||||||||||
| {{- include "mlrun-ce.common.labels" . | nindent 4 }} | ||||||||||||||||||||||||||
shay79il marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||
| kafka: | ||||||||||||||||||||||||||
| listeners: | ||||||||||||||||||||||||||
| {{- range .Values.kafka.listeners }} | ||||||||||||||||||||||||||
| - name: {{ .name }} | ||||||||||||||||||||||||||
| port: {{ .port }} | ||||||||||||||||||||||||||
| type: {{ .type }} | ||||||||||||||||||||||||||
| tls: {{ .tls }} | ||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||
| {{- range $key, $value := .Values.kafka.config }} | ||||||||||||||||||||||||||
| {{ $key }}: {{ $value | quote }} | ||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||
| {{- if gt (.Values.kafka.zookeeper.replicas | int) 0 }} | ||||||||||||||||||||||||||
| zookeeper: | ||||||||||||||||||||||||||
| replicas: {{ .Values.kafka.zookeeper.replicas }} | ||||||||||||||||||||||||||
|
Comment on lines
+21
to
+26
|
||||||||||||||||||||||||||
| {{- range $key, $value := .Values.kafka.config }} | |
| {{ $key }}: {{ $value | quote }} | |
| {{- end }} | |
| {{- if gt (.Values.kafka.zookeeper.replicas | int) 0 }} | |
| zookeeper: | |
| replicas: {{ .Values.kafka.zookeeper.replicas }} | |
| {{- toYaml .Values.kafka.config | nindent 6 }} | |
| {{- if gt (.Values.kafka.zookeeper.replicas | int) 0 }} | |
| zookeeper: | |
| replicas: {{ .Values.kafka.zookeeper.replicas }} | |
| zookeeper: | |
| replicas: {{ .Values.kafka.zookeeper.replicas }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||
| {{- if .Values.kafka.rbac.enabled -}} | ||||||||||||||
| {{- $operatorNamespace := .Values.kafka.rbac.operatorNamespace | default "controller" -}} | ||||||||||||||
| {{- $kafkaName := .Values.kafka.name | default "kafka-stream" -}} | ||||||||||||||
| {{- $currentNamespace := .Release.Namespace -}} | ||||||||||||||
| --- | ||||||||||||||
| # NetworkPolicy: Allow egress from this namespace to Kafka namespace | ||||||||||||||
| apiVersion: networking.k8s.io/v1 | ||||||||||||||
| kind: NetworkPolicy | ||||||||||||||
| metadata: | ||||||||||||||
| name: allow-kafka-access | ||||||||||||||
| namespace: {{ $currentNamespace }} | ||||||||||||||
| labels: | ||||||||||||||
| app.kubernetes.io/name: mlrun-ce | ||||||||||||||
| app.kubernetes.io/component: kafka-rbac | ||||||||||||||
| app.kubernetes.io/managed-by: {{ .Release.Name }} | ||||||||||||||
| spec: | ||||||||||||||
| # Apply to all pods in this namespace | ||||||||||||||
| podSelector: {} | ||||||||||||||
|
|
||||||||||||||
| policyTypes: | ||||||||||||||
| - Egress | ||||||||||||||
|
|
||||||||||||||
| egress: | ||||||||||||||
| # Allow egress to Kafka namespace | ||||||||||||||
| - to: | ||||||||||||||
| - namespaceSelector: | ||||||||||||||
| matchLabels: | ||||||||||||||
| kubernetes.io/metadata.name: {{ $operatorNamespace }} | ||||||||||||||
| podSelector: | ||||||||||||||
| matchLabels: | ||||||||||||||
| strimzi.io/cluster: {{ $kafkaName }} | ||||||||||||||
| ports: | ||||||||||||||
| - protocol: TCP | ||||||||||||||
| port: 9092 # client listener | ||||||||||||||
| - protocol: TCP | ||||||||||||||
| port: 9093 # controller listener | ||||||||||||||
| - protocol: TCP | ||||||||||||||
| port: 9094 # internal listener | ||||||||||||||
|
|
||||||||||||||
| # Allow DNS resolution (required for service discovery) | ||||||||||||||
| - to: | ||||||||||||||
| - namespaceSelector: | ||||||||||||||
| matchLabels: | ||||||||||||||
| kubernetes.io/metadata.name: kube-system | ||||||||||||||
| podSelector: | ||||||||||||||
| matchLabels: | ||||||||||||||
| k8s-app: kube-dns | ||||||||||||||
| ports: | ||||||||||||||
| - protocol: UDP | ||||||||||||||
| port: 53 | ||||||||||||||
| - protocol: TCP | ||||||||||||||
| port: 53 | ||||||||||||||
|
|
||||||||||||||
| # Allow egress to the internet/other services (optional) | ||||||||||||||
| # Comment out the next section if you want to restrict to Kafka only | ||||||||||||||
| - to: | ||||||||||||||
| - namespaceSelector: {} | ||||||||||||||
| - podSelector: {} | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+54
to
+59
|
||||||||||||||
| # Allow egress to the internet/other services (optional) | |
| # Comment out the next section if you want to restrict to Kafka only | |
| - to: | |
| - namespaceSelector: {} | |
| - podSelector: {} | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| {{- if .Values.kafka.enabled }} | ||
| apiVersion: kafka.strimzi.io/v1beta2 | ||
| kind: KafkaNodePool | ||
| metadata: | ||
| name: {{ .Values.kafka.name }}-pool | ||
| namespace: {{ .Values.kafka.namespace | default .Release.Namespace }} | ||
shay79il marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| labels: | ||
| app.kubernetes.io/name: kafka | ||
| app.kubernetes.io/component: nodepool | ||
| strimzi.io/cluster: {{ .Values.kafka.name }} | ||
| {{- include "mlrun-ce.common.labels" . | nindent 4 }} | ||
| spec: | ||
| replicas: {{ .Values.kafka.replicas }} | ||
| roles: | ||
| - controller | ||
| - broker | ||
| storage: | ||
| type: {{ .Values.kafka.storage.type }} | ||
| size: {{ .Values.kafka.storage.size }} | ||
| {{- if .Values.kafka.storage.class }} | ||
| class: {{ .Values.kafka.storage.class }} | ||
| {{- end }} | ||
|
Comment on lines
+20
to
+22
|
||
| resources: | ||
| requests: | ||
| memory: {{ .Values.kafka.resources.requests.memory }} | ||
| cpu: {{ .Values.kafka.resources.requests.cpu }} | ||
| limits: | ||
| memory: {{ .Values.kafka.resources.limits.memory }} | ||
| cpu: {{ .Values.kafka.resources.limits.cpu }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| {{- if .Values.kafka.rbac.enabled -}} | ||
| {{- $operatorNamespace := .Values.kafka.rbac.operatorNamespace | default "controller" -}} | ||
| {{- $kafkaName := .Values.kafka.name | default "kafka-stream" -}} | ||
| {{- $currentNamespace := .Release.Namespace -}} | ||
| --- | ||
| # ServiceAccount for Kafka client applications | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: kafka-client | ||
| namespace: {{ $currentNamespace }} | ||
| labels: | ||
| app.kubernetes.io/name: mlrun-ce | ||
| app.kubernetes.io/component: kafka-rbac | ||
| app.kubernetes.io/managed-by: {{ .Release.Name }} | ||
| --- | ||
| # Role: Allow managing Kafka resources via CRDs in the operator namespace | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: Role | ||
| metadata: | ||
| name: {{ $currentNamespace }}-kafka-resource-manager | ||
| namespace: {{ $operatorNamespace }} | ||
| labels: | ||
| app.kubernetes.io/name: mlrun-ce | ||
| app.kubernetes.io/component: kafka-rbac | ||
| app.kubernetes.io/managed-by: {{ .Release.Name }} | ||
| user-namespace: {{ $currentNamespace }} | ||
| rules: | ||
| # Allow creating and managing KafkaTopic CRDs | ||
| - apiGroups: | ||
| - kafka.strimzi.io | ||
| resources: | ||
| - kafkatopics | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - create | ||
| - update | ||
| - patch | ||
| - delete | ||
| # Allow checking KafkaTopic status | ||
| - apiGroups: | ||
| - kafka.strimzi.io | ||
| resources: | ||
| - kafkatopics/status | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| # Allow reading KafkaUser CRDs (if using SCRAM auth) | ||
| - apiGroups: | ||
| - kafka.strimzi.io | ||
| resources: | ||
| - kafkausers | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| # Allow reading the Kafka cluster info | ||
| - apiGroups: | ||
| - kafka.strimzi.io | ||
| resources: | ||
| - kafkas | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| --- | ||
| # RoleBinding: Grant Kafka resource management permissions to ServiceAccount | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| name: {{ $currentNamespace }}-kafka-resource-manager | ||
| namespace: {{ $operatorNamespace }} | ||
| labels: | ||
| app.kubernetes.io/name: mlrun-ce | ||
| app.kubernetes.io/component: kafka-rbac | ||
| app.kubernetes.io/managed-by: {{ .Release.Name }} | ||
| user-namespace: {{ $currentNamespace }} | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: kafka-client | ||
| namespace: {{ $currentNamespace }} | ||
| roleRef: | ||
| kind: Role | ||
| name: {{ $currentNamespace }}-kafka-resource-manager | ||
| apiGroup: rbac.authorization.k8s.io | ||
| {{- end }} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value "kafka-stream" is used inline here and in other templates (lines 6, 20, 22), but this value is already defined in values.yaml as .Values.kafka.name. Using 'default' function as a fallback is unnecessary since the value is always provided in values.yaml. Consider removing the default function calls and directly using .Values.kafka.name, or document when this default would be needed.