Kafka partition reassignment with horizontal pod autoscaling

1/24/2019

I am using a Horizontal Pod Autoscaling script (HPA.yaml) for Kafka Broker pods which scales out and scales in broker pods based on CPU and memory utilization metrics as given below. However, Kafka internally does not handle partition reassignment when broker nodes are added or removed. Is there any way to do it when scale in or scale out takes place.

HPA.yaml

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: kafka-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1beta1
    kind: StatefulSet
    name: {{ include "kafka.fullname" . }}
  minReplicas: {{ .Values.replicas }}
  maxReplicas: 5
  metrics:
  - type: Resource
    resource:
      name: cpu
      targetAverageUtilization: 40
  - type: Resource
    resource:
      name: memory
      targetAverageValue: 8000Mi

Is there any way to automate reassignment of partitions whenever scale in or scale out takes place.

-- amankedia
apache-kafka
kubernetes
kubernetes-helm

0 Answers