mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
Add Affinity Rules for Kafka/Zookeeper pods (#2918)
* Add Affinity Rules for Kafka/Zookeeper pods * Update Chart.yaml * Use soft requirement instead of hard by default for antiaffinity
This commit is contained in:
committed by
Vic Iglesias
parent
54f82ea525
commit
774779c484
@@ -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
|
||||
|
||||
+19
-14
@@ -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`
|
||||
|
||||
|
||||
@@ -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 }}"
|
||||
|
||||
@@ -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:
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user