forked from confluentinc/cp-helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NOTES.txt
84 lines (64 loc) · 2.71 KB
/
NOTES.txt
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
{{- if (index .Values "cp-zookeeper" "enabled") -}}
## ------------------------------------------------------
## Zookeeper
## ------------------------------------------------------
Connection string for Confluent Kafka:
{{ .Release.Name }}-cp-zookeeper-0.{{ .Release.Name }}-cp-zookeeper-headless:{{ default 2181 .Values.clientPort }},{{ .Release.Name }}-cp-zookeeper-1.{{ .Release.Name }}-cp-zookeeper-headless:{{ default 2181 .Values.clientPort }},...
To connect from a client pod:
1. Deploy a zookeeper client pod with configuration:
apiVersion: v1
kind: Pod
metadata:
name: zookeeper-client
namespace: {{ .Release.Namespace }}
spec:
containers:
- name: zookeeper-client
image: {{index .Values "cp-zookeeper" "image" }}:{{index .Values "cp-zookeeper" "imageTag" }}
command:
- sh
- -c
- "exec tail -f /dev/null"
2. Log into the Pod
kubectl exec -it zookeeper-client -- /bin/bash
3. Use zookeeper-shell to connect in the zookeeper-client Pod:
zookeeper-shell {{ .Release.Name }}-cp-zookeeper:{{ default 2181 .Values.clientPort }}
4. Explore with zookeeper commands, for example:
# Gives the list of active brokers
ls /brokers/ids
# Gives the list of topics
ls /brokers/topics
# Gives more detailed information of the broker id '0'
get /brokers/ids/0
{{- end -}}
{{- if (index .Values "cp-kafka" "enabled") -}}
## ------------------------------------------------------
## Kafka
## ------------------------------------------------------
To connect from a client pod:
1. Deploy a kafka client pod with configuration:
apiVersion: v1
kind: Pod
metadata:
name: kafka-client
namespace: {{ .Release.Namespace }}
spec:
containers:
- name: kafka-client
image: {{ index .Values "cp-kafka" "image" }}:{{ index .Values "cp-kafka" "imageTag" }}
command:
- sh
- -c
- "exec tail -f /dev/null"
2. Log into the Pod
kubectl exec -it kafka-client -- /bin/bash
3. Explore with kafka commands:
# Create the topic
kafka-topics --zookeeper {{ .Release.Name }}-cp-zookeeper-headless:{{ default 2181 .Values.clientPort }} --topic {{ .Release.Name }}-topic --create --partitions 1 --replication-factor 1 --if-not-exists
# Create a message
MESSAGE="`date -u`"
# Produce a test message to the topic
echo "$MESSAGE" | kafka-console-producer --broker-list {{ .Release.Name }}-cp-kafka-headless:9092 --topic {{ .Release.Name }}-topic
# Consume a test message from the topic
kafka-console-consumer --bootstrap-server {{ .Release.Name }}-cp-kafka-headless:9092 --topic {{ .Release.Name }}-topic --from-beginning --timeout-ms 2000 --max-messages 1 | grep "$MESSAGE"
{{- end -}}