2 # Copyright © 2022 Nordix Foundation
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 Create a Strimzi KafkaUser.
20 include "common.kafkauser" .
22 Strimzi kafka provides cluster access via its custom resource definition KafkaUser
23 which is deployed using its User Operator component.
24 See more info here - https://github.com/strimzi/strimzi-kafka-operator/blob/main/helm-charts/helm3/strimzi-kafka-operator/crds/044-Crd-kafkauser.yaml
25 This allows fine grained access control per user towards the kafka cluster.
26 See more info here - https://strimzi.io/docs/operators/latest/configuring.html#proc-configuring-kafka-user-str
28 The kafka user definition is defined as part of .Values per component.
29 For general use by OOM components, the following list of acl types should suffice:
30 type: group (Used by the client app to be added to a particular kafka consumer group)
31 type: topic (1 or more kafka topics that the client needs to access. Commonly [Read,Write])
33 Note: The template will use the following default values.
35 spec.authentication.type: scram-sha-512 (dictated by the available broker listeners on the kafka cluster)
36 spec.authorization.type: simple (Only type supported by strimzi at present)
37 spec.authorization.acls.resource.patternType: literal
43 - name: sdc (mandatory)
44 suffix: mysuffix (optional. Will be appended (with a hyphen) to the "name" entry. ie "sdc-mysuffix")
45 type: group (mandatory. Type "group" is used by the client as it's kafka consumer group)
46 operations: [Read] (mandatory. List of at least 1)
49 patternType: prefix (optional. In this example, the user will be provided Read and Write access to all topics named "SDC-DISTR*")
50 operations: [Read, Write]
52 {{- define "common.kafkauser" -}}
53 {{- $global := .global }}
54 apiVersion: kafka.strimzi.io/v1beta2
57 name: {{ include "common.name" . }}-ku
59 strimzi.io/cluster: {{ include "common.release" . }}-strimzi
62 type: {{ .Values.kafkaUser.authenticationType | default "scram-sha-512" }}
64 type: {{ .Values.kafkaUser.authorizationType | default "simple" }}
66 {{- range $acl := .Values.kafkaUser.acls }}
69 patternType: {{ $acl.patternType | default "literal" }}
70 name: {{ ternary (printf "%s-%s" $acl.name $acl.suffix) $acl.name (hasKey $acl "suffix") }}
72 {{- range $operation := $acl.operations }}
79 Create a Strimzi KafkaTopic.
81 include "common.kafkatopic" .
83 Strimzi kafka provides kafka topic management via its custom resource definition KafkaTopic
84 which is deployed using its Topic Operator component.
85 See more info here - https://github.com/strimzi/strimzi-kafka-operator/blob/main/helm-charts/helm3/strimzi-kafka-operator/crds/043-Crd-kafkatopic.yaml
87 Note: KafkaTopic names should adhere to kubernetes object naming conventions - https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
88 maximum length of 253 characters and consist of lower case alphanumeric characters, -, and .
90 Note: The template will use the following default values.
92 spec.config.retention.ms: 7200000 (defaults to 2 hrs retention for kafka topic logs)
93 spec.config.segment.bytes: 1073741824 (defaults to 1gb)
94 spec.partitions: 6 (defaults to (2 * (default.replication.factor)) defined by the strimzi broker conf)
95 spec.replicas: 3 (defaults to default.replication.factor defined by the strimzi broker conf. Must be > 0 and <= (num of broker replicas))
97 The kafka topic definition is defined as part of .Values per component.
102 - name: my-new-topic (mandatory)
103 retentionMs: 7200000 (optional. Defaults to 2hrs)
104 segmentBytes: 1073741824 (optional. Defaults to 1gb)
105 suffix: my-suffix (optional. Will be appended (with a hyphen) to the "name" value. ie "my-new-topic-my-suffix")
106 - name: my.other.topic
107 suffix: some.other-suffix
109 {{- define "common.kafkatopic" -}}
110 {{- $global := .global }}
111 {{- range $topic := .Values.kafkaTopic }}
112 apiVersion: kafka.strimzi.io/v1beta2
115 {{- if (hasKey $topic "strimziTopicName") }}
116 name: {{ ($topic.strimziTopicName) }}-kt
118 name: {{ ($topic.name) | lower }}-kt
121 strimzi.io/cluster: {{ include "common.release" $ }}-strimzi
123 {{- if (hasKey $topic "partitions") }}
124 partitions: {{ $topic.partitions }}
126 {{- if (hasKey $topic "replicas") }}
127 replicas: {{ $topic.replicas }}
129 topicName: {{ ternary (printf "%s-%s" $topic.name $topic.suffix) $topic.name (hasKey $topic "suffix") }}
131 retention.ms: {{ $topic.retentionMs | default "7200000" }}
132 segment.bytes: {{ $topic.segmentBytes | default "1073741824"}}