-
Notifications
You must be signed in to change notification settings - Fork 44
/
jpoode_kafka.yaml
108 lines (108 loc) · 3.05 KB
/
jpoode_kafka.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.resources.services.kafka }}
labels:
app: jpoode-kafka
spec:
ports:
- port: 9092
name: ode-kafkaserver
clusterIP: None
selector:
app: jpoode-kafka
---
# limits the number of pods that are down simultaneously
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: ode-kafka-pdb
spec:
selector:
matchLabels:
app: jpoode-kafka
maxUnavailable: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: jpoode-kafka
spec:
selector:
matchLabels:
app: jpoode-kafka
serviceName: {{ .Values.resources.services.kafka }}
replicas: {{ .Values.replicas.jpoode_kafka }}
podManagementPolicy: Parallel
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: jpoode-kafka
spec:
terminationGracePeriodSeconds: 300
containers:
- name: k8skafka
imagePullPolicy: Always
image: confluentinc/cp-kafka:6.2.0
resources:
requests:
memory: "1Gi"
cpu: "0.5"
ports:
- containerPort: 9092
name: ode-kafkaserver
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SERVICE_NAME
value: {{ .Values.resources.services.kafka }}
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: KAFKA_HEAP_OPTS
value: "-Xms512M -Xmx512M"
- name: KAFKA_ZOOKEEPER_CONNECT
value: {{ .Values.resources.services.zookeeper }}
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "1"
- name: KAFKA_NUM_PARTITIONS
value: "{{ .Values.replicas.jpoode_kafka }}"
# This is required because the Downward API does not yet support identification of
# pod numbering in statefulsets. Thus, we are required to specify a command which
# allows us to extract the pod ID for usage as the Kafka Broker ID.
# See: https://github.com/kubernetes/kubernetes/issues/31218
command:
- sh
- -exc
- |
export KAFKA_BROKER_ID=${HOSTNAME##*-} && \
export KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://${POD_NAME}.${SERVICE_NAME}.${POD_NAMESPACE}:9092 && \
exec /etc/confluent/docker/run
volumeMounts:
- name: datadir
mountPath: /var/lib/kafka
securityContext:
runAsUser: 1000
fsGroup: 1000
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi