├── README.md ├── kafka-1-deployment.yaml ├── kafka-1-ip-service.yaml ├── kafka-2-deployment.yaml ├── kafka-2-ip-service.yaml ├── kafka-3-deployment.yaml ├── kafka-3-ip-service.yaml ├── zookeeper-deployment.yaml └── zookeeper-ip-service.yaml /README.md: -------------------------------------------------------------------------------- 1 | By [Dmytro Nasyrov, Founder, CTO at Pharos Production Inc.](https://www.linkedin.com/in/dmytronasyrov/) 2 | And [Pharos Production Inc. - Web3, blockchain, fintech, defi software development services](https://pharosproduction.com) 3 | 4 | # Tutorial How to Deploy Apache Kafka Cluster & ZooKeeper in Kubernetes. 5 | 6 | ## You can find it in our Medium publication 7 | [Pharos Production Medium Article](https://medium.com/pharos-production/how-to-deploy-apache-kafka-cluster-zookeeper-in-kubernetes-c5b04f01ac20). 8 | 9 | Also you're warmely welcome to say hello to us 10 | [Pharos Production - Blockchain and FinTech Software Development](https://pharosproduction.com) 11 | -------------------------------------------------------------------------------- /kafka-1-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: kafka-1-deployment 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | component: kafka-1 10 | template: 11 | metadata: 12 | labels: 13 | component: kafka-1 14 | spec: 15 | containers: 16 | - name: kafka-1 17 | image: pharosproduction/kafka_k8s:v1 18 | resources: 19 | requests: 20 | memory: "256Mi" 21 | cpu: "250m" 22 | limits: 23 | memory: "512Mi" 24 | cpu: "500m" 25 | ports: 26 | - containerPort: 9092 27 | env: 28 | - name: MY_POD_IP 29 | valueFrom: 30 | fieldRef: 31 | fieldPath: status.podIP 32 | - name: KAFKA_ADVERTISED_PORT 33 | value: "9092" 34 | - name: KAFKA_ZOOKEEPER_CONNECT 35 | value: zookeeper-ip-service:2181 36 | - name: KAFKA_ADVERTISED_PORT 37 | value: "9092" 38 | - name: KAFKA_ADVERTISED_HOST_NAME 39 | value: $(MY_POD_IP) 40 | tty: true 41 | livenessProbe: 42 | exec: 43 | command: 44 | - /opt/check.sh 45 | initialDelaySeconds: 30 46 | periodSeconds: 30 47 | readinessProbe: 48 | exec: 49 | command: 50 | - /opt/check.sh 51 | initialDelaySeconds: 30 52 | periodSeconds: 5 53 | # command: 54 | # - /bin/bash 55 | imagePullSecrets: 56 | - name: regcred 57 | -------------------------------------------------------------------------------- /kafka-1-ip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kafka-1-ip-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | component: kafka-1 9 | ports: 10 | - name: kafka 11 | port: 9092 12 | targetPort: 9092 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /kafka-2-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: kafka-2-deployment 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | component: kafka-2 10 | template: 11 | metadata: 12 | labels: 13 | component: kafka-2 14 | spec: 15 | containers: 16 | - name: kafka-2 17 | image: pharosproduction/kafka_k8s:v1 18 | resources: 19 | requests: 20 | memory: "256Mi" 21 | cpu: "250m" 22 | limits: 23 | memory: "512Mi" 24 | cpu: "500m" 25 | ports: 26 | - containerPort: 9092 27 | 28 | env: 29 | - name: MY_POD_IP 30 | valueFrom: 31 | fieldRef: 32 | fieldPath: status.podIP 33 | - name: KAFKA_ADVERTISED_PORT 34 | value: "9092" 35 | - name: KAFKA_ZOOKEEPER_CONNECT 36 | value: zookeeper-ip-service:2181 37 | - name: KAFKA_ADVERTISED_PORT 38 | value: "9092" 39 | - name: KAFKA_ADVERTISED_HOST_NAME 40 | value: $(MY_POD_IP) 41 | tty: true 42 | livenessProbe: 43 | exec: 44 | command: 45 | - /opt/check.sh 46 | initialDelaySeconds: 30 47 | periodSeconds: 30 48 | readinessProbe: 49 | exec: 50 | command: 51 | - /opt/check.sh 52 | initialDelaySeconds: 30 53 | periodSeconds: 5 54 | 55 | imagePullSecrets: 56 | - name: regcred 57 | -------------------------------------------------------------------------------- /kafka-2-ip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kafka-2-ip-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | component: kafka-2 9 | ports: 10 | - name: kafka 11 | port: 9092 12 | targetPort: 9092 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /kafka-3-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: kafka-3-deployment 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | component: kafka-3 10 | template: 11 | metadata: 12 | labels: 13 | component: kafka-3 14 | spec: 15 | containers: 16 | - name: kafka-3 17 | image: pharosproduction/kafka_k8s:v1 18 | resources: 19 | requests: 20 | memory: "256Mi" 21 | cpu: "250m" 22 | limits: 23 | memory: "512Mi" 24 | cpu: "500m" 25 | ports: 26 | - containerPort: 9092 27 | 28 | env: 29 | - name: MY_POD_IP 30 | valueFrom: 31 | fieldRef: 32 | fieldPath: status.podIP 33 | - name: KAFKA_ADVERTISED_PORT 34 | value: "9092" 35 | - name: KAFKA_ZOOKEEPER_CONNECT 36 | value: zookeeper-ip-service:2181 37 | - name: KAFKA_ADVERTISED_PORT 38 | value: "9092" 39 | - name: KAFKA_ADVERTISED_HOST_NAME 40 | value: $(MY_POD_IP) 41 | tty: true 42 | livenessProbe: 43 | exec: 44 | command: 45 | - /opt/check.sh 46 | initialDelaySeconds: 30 47 | periodSeconds: 30 48 | readinessProbe: 49 | exec: 50 | command: 51 | - /opt/check.sh 52 | initialDelaySeconds: 30 53 | periodSeconds: 5 54 | 55 | imagePullSecrets: 56 | - name: regcred 57 | -------------------------------------------------------------------------------- /kafka-3-ip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kafka-3-ip-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | component: kafka-3 9 | ports: 10 | - name: kafka 11 | port: 9092 12 | targetPort: 9092 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /zookeeper-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: zookeeper-deployment 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | component: zookeeper 10 | template: 11 | metadata: 12 | labels: 13 | component: zookeeper 14 | spec: 15 | containers: 16 | - name: zookeeper 17 | image: pharosproduction/zookeeper_k8s:v4 18 | resources: 19 | requests: 20 | memory: "64Mi" 21 | cpu: "125m" 22 | limits: 23 | memory: "128Mi" 24 | cpu: "250m" 25 | ports: 26 | - containerPort: 2181 27 | tty: true 28 | livenessProbe: 29 | exec: 30 | command: 31 | - /opt/check.sh 32 | initialDelaySeconds: 30 33 | periodSeconds: 30 34 | readinessProbe: 35 | exec: 36 | command: 37 | - /opt/check.sh 38 | initialDelaySeconds: 30 39 | periodSeconds: 5 40 | imagePullSecrets: 41 | - name: regcred 42 | -------------------------------------------------------------------------------- /zookeeper-ip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: zookeeper-ip-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | component: zookeeper 9 | ports: 10 | - name: zookeeper 11 | port: 2181 12 | targetPort: 2181 13 | 14 | 15 | 16 | --------------------------------------------------------------------------------