Skip to content

Commit

Permalink
Issue Fix: wrong connection strings in NOTE.txt for cp-helm-charts
Browse files Browse the repository at this point in the history
  • Loading branch information
qshao-pivotal committed May 22, 2018
1 parent dc98ae2 commit 4517410
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Zookeeper
## ------------------------------------------------------
Connection string for Confluent Kafka:
{{ template "cp-zookeeper.fullname" . }}-0.{{ template "cp-zookeeper.fullname" . }}-headless:{{ .Values.clientPort }},{{ template "cp-zookeeper.fullname" . }}-1.{{ template "cp-zookeeper.fullname" . }}-headless:{{ .Values.clientPort }},...
{{ .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:

Expand All @@ -28,7 +28,7 @@ To connect from a client pod:

3. Use zookeeper-shell to connect in the zookeeper-client Pod:

zookeeper-shell {{ template "cp-zookeeper.fullname" . }}:{{ .Values.clientPort }}
zookeeper-shell {{ .Release.Name }}-cp-zookeeper:{{ default 2181 .Values.clientPort }}

4. Explore with zookeeper commands, for example:

Expand Down Expand Up @@ -70,13 +70,13 @@ To connect from a client pod:
3. Explore with kafka commands:

# Create the topic
kafka-topics --zookeeper {{ template "cp-kafka.cp-zookeeper.service-name" . }} --topic {{ template "cp-kafka.fullname" . }}-topic --create --partitions 1 --replication-factor 1 --if-not-exists
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 {{ template "cp-kafka.fullname" . }}:9092 --topic {{ template "cp-kafka.fullname" . }}-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 {{ template "cp-kafka.fullname" . }}-headless:9092 --topic {{ template "cp-kafka.fullname" . }}-topic --from-beginning --timeout-ms 2000 --max-messages 1 | grep "$MESSAGE"
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"
32 changes: 32 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cp-helm-charts.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "cp-helm-charts.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cp-helm-charts.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

0 comments on commit 4517410

Please sign in to comment.