diff --git a/incubator/kafka/Chart.yaml b/incubator/kafka/Chart.yaml index c46d705db4..0cd2168ae4 100755 --- a/incubator/kafka/Chart.yaml +++ b/incubator/kafka/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 description: Apache Kafka is publish-subscribe messaging rethought as a distributed commit log. name: kafka -version: 0.2.4 +version: 0.2.5 keywords: - kafka - zookeeper diff --git a/incubator/kafka/README.md b/incubator/kafka/README.md index f593e9059e..1a23385cc1 100644 --- a/incubator/kafka/README.md +++ b/incubator/kafka/README.md @@ -51,20 +51,25 @@ This chart includes a ZooKeeper chart as a dependency to the Kafka cluster in its `requirement.yaml` by default. The chart can be customized using the following configurable parameters: -| Parameter | Description | Default | -| ------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------- | -| `image` | Kafka Container image name | `solsson/kafka` | -| `imageTag` | Kafka Container image tag | `0.11.0.0` | -| `imagePullPolicy` | Kafka Container pull policy | `Always` | -| `replicas` | Kafka Brokers | `3` | -| `component` | Kafka k8s selector key | `kafka` | -| `resources` | Kafka resource requests and limits | `{}` | -| `dataDirectory` | Kafka data directory | `/opt/kafka/data` | -| `storage` | Kafka Persistent volume size | `1Gi` | -| `schema-registry.enabled` | If True, installs Schema Registry Chart | `false` | -| `zookeeper.enabled` | If True, installs Zookeeper Chart | `true` | -| `zookeeper.url` | URL of Zookeeper Cluster (unneeded if installing Zookeeper Chart) | `""` | -| `zookeeper.port` | Port of Zookeeper Cluster | `2181` | +| Parameter | Description | Default | +| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | +| `image` | Kafka Container image name | `solsson/kafka` | +| `imageTag` | Kafka Container image tag | `1.0.0` | +| `imagePullPolicy` | Kafka Container pull policy | `Always` | +| `kafkaAntiAffinityEnabled` | If `true`, apply anti-affinity rules between kafka pods. | `true` | +| `kafkaAntiAffinity` | If `hard` disallow colocation of Kafka pods, if `soft`, make a best effort-attempt to prevent colocation. | `soft` | +| `replicas` | Kafka Brokers | `3` | +| `component` | Kafka k8s selector key | `kafka` | +| `resources` | Kafka resource requests and limits | `{}` | +| `dataDirectory` | Kafka data directory | `/opt/kafka/data` | +| `storage` | Kafka Persistent volume size | `1Gi` | +| `schema-registry.enabled` | If True, installs Schema Registry Chart | `false` | +| `zookeeperAntiAffinityEnabled` | If `true`, apply anti-affinity rules between kafka and zookeeper pods. | `true` | +| `zookeeperAntiAffinity` | If `hard` disallow colocation of Kafka and Zookeeper pods, if `soft`, make a best effort-attempt to prevent colocation | `soft` | +| `zookeeperAntiAffinityPodName` | Pod Metadata app label of zookeeper pods for anti-affinity rules for use with `In` prefix of affinity rules. | `zookeeper` | +| `zookeeper.enabled` | If True, installs Zookeeper Chart | `true` | +| `zookeeper.url` | URL of Zookeeper Cluster (unneeded if installing Zookeeper Chart) | `""` | +| `zookeeper.port` | Port of Zookeeper Cluster | `2181` | Specify parameters using `--set key=value[,key=value]` argument to `helm install` diff --git a/incubator/kafka/templates/statefulset.yaml b/incubator/kafka/templates/statefulset.yaml index 04471b329f..a17c2f2d0e 100644 --- a/incubator/kafka/templates/statefulset.yaml +++ b/incubator/kafka/templates/statefulset.yaml @@ -16,6 +16,47 @@ spec: app: {{ include "kafka.name" . | quote }} release: {{ .Release.Name | quote }} spec: + {{ if or .Values.kafkaAntiAffinityEnabled .Values.zookeeperAntiAffinityEnabled }} + affinity: + podAntiAffinity: + {{ if or (eq .Values.kafkaAntiAffinity "hard") (eq .Values.zookeeperAntiAffinity "hard") }} + requiredDuringSchedulingIgnoredDuringExecution: + {{ if and .Values.kafkaAntiAffinityEnabled (eq .Values.kafkaAntiAffinity "hard") }} + - topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: {{ include "kafka.name" . | quote }} + release: {{ .Release.Name | quote }} + {{ end }} + {{ if and .Values.zookeeperAntiAffinityEnabled (eq .Values.zookeeperAntiAffinity "hard") }} + - topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: {{ .Values.zookeeperAntiAffinityPodName }} + release: {{ .Release.Name | quote }} + {{ end }} + {{ end }} + {{ if or (eq .Values.kafkaAntiAffinity "soft") (eq .Values.zookeeperAntiAffinity "soft") }} + preferredDuringSchedulingIgnoredDuringExecution: + {{ if and .Values.kafkaAntiAffinityEnabled (eq .Values.kafkaAntiAffinity "soft") }} + - weight: 1 + podAffinityTerm: + topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: {{ include "kafka.name" . | quote }} + release: {{ .Release.Name | quote }} + {{ end }} + {{ if and .Values.zookeeperAntiAffinityEnabled (eq .Values.zookeeperAntiAffinity "soft") }} + - weight: 1 + podAffinityTerm: + topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: {{ .Values.zookeeperAntiAffinityPodName }} + {{ end }} + {{ end }} + {{ end }} containers: - name: {{ template "kafka.name" . }}-broker image: "{{ .Values.image }}:{{ .Values.imageTag }}" diff --git a/incubator/kafka/values.yaml b/incubator/kafka/values.yaml index 2df1f72696..8ae28667da 100644 --- a/incubator/kafka/values.yaml +++ b/incubator/kafka/values.yaml @@ -36,6 +36,29 @@ storage: "1Gi" ## its logs dataDirectory: "/opt/kafka/data" +## Attempt to prevent Kafka pods from being colocated with eachother. +kafkaAntiAffinityEnabled: true +## Prevent Kafka pods from being colocated on the same node. +## `hard` means the scheduler must satisfy the constraints or the pod fails to schedule +## `soft` means the scheduler makes a best-effort to satisfy the constraint and schedules it where +## it can if the constraints cannot be met. +## See: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature +kafkaAntiAffinity: "soft" + +## Attempt to prevent Kafka and Zookeeper pods from being colocated. +zookeeperAntiAffinityEnabled: true +## Prevent Kafka and Zookeeper pods from being colocated. +## `hard` means the scheduler must satisfy the constraints or the pod fails to schedule +## `soft` means the scheduler makes a best-effort to satisfy the constraint and schedules it where +## it can if the constraints cannot be met. +## See: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature +zookeeperAntiAffinity: "soft" +## The zookeeper pod name which K8s will fuzzy-match against to prevent kafka +## pods from being colocated with zookeeper. If you have more than one zookeeper +## installation in your cluster, make sure to use a more specific pod name to +## indicate which zookeeper pods should be filtered. +zookeeperAntiAffinityPodName: "zookeeper" + # ------------------------------------------------------------------------------ # Zookeeper: # ------------------------------------------------------------------------------