Skip to content

Commit

Permalink
Merge pull request #25 from BenPope/update-helm-chart
Browse files Browse the repository at this point in the history
Update helm chart
  • Loading branch information
BenPope authored Feb 20, 2021
2 parents 36b4b9a + 8dc33d9 commit 8e62474
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 31 deletions.
4 changes: 2 additions & 2 deletions redpanda/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Try some sample commands, like creating a topic called topic1:

kubectl -n {{ .Release.Namespace }} run -ti --rm --restart=Never \
--image {{ .Values.image.repository }}:{{ .Values.image.tag }} \
rpk -- --brokers={{ include "redpanda.fullname" . }}-bootstrap:{{ .Values.config.redpanda.kafka_api.port }} api topic create topic1
rpk -- --brokers={{ include "redpanda.fullname" . }}-bootstrap:{{ template "redpanda.kafka.internal.advertise.port" $ }} api topic create topic1

To get the api status:

kubectl -n {{ .Release.Namespace }} run -ti --rm --restart=Never \
--image {{ .Values.image.repository }}:{{ .Values.image.tag }} \
rpk -- --brokers={{ include "redpanda.fullname" . }}-bootstrap:{{ .Values.config.redpanda.kafka_api.port }} api status
rpk -- --brokers={{ include "redpanda.fullname" . }}-bootstrap:{{ template "redpanda.kafka.internal.advertise.port" $ }} api status
49 changes: 48 additions & 1 deletion redpanda/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,51 @@ Strip out the suffixes on memory to pass to Redpanda
{{- $string := .Values.statefulset.resources.limits.memory | toString }}
{{- regexReplaceAll "(\\d+)(\\w?)i?" $string "${1}${2}" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Generate configuration needed for rpk
*/}}
{{- define "redpanda.internal.domain" -}}
{{- $service := include "redpanda.fullname" . -}}
{{- $ns := .Release.Namespace -}}
{{- $domain := .Values.clusterDomain | trimSuffix "." -}}
{{- printf "%s.%s.svc.%s." $service $ns $domain -}}
{{- end }}

{{- define "redpanda.kafka.internal.advertise.address" -}}
{{- $host := "$(SERVICE_NAME)" -}}
{{- $domain := include "redpanda.internal.domain" . -}}
{{- printf "%s.%s" $host $domain -}}
{{- end -}}

{{- define "redpanda.kafka.internal.advertise.port" -}}
{{- (first .Values.config.redpanda.kafka_api).port -}}
{{- end -}}

{{- define "redpanda.kafka.internal.listen.address" -}}
{{- "$(POD_IP)" -}}
{{- end -}}

{{- define "redpanda.kafka.internal.listen.port" -}}
{{- (first .Values.config.redpanda.kafka_api).port -}}
{{- end -}}

{{- define "redpanda.rpc.advertise.address" -}}
{{- $host := "$(SERVICE_NAME)" -}}
{{- $domain := include "redpanda.internal.domain" . -}}
{{- printf "%s.%s" $host $domain -}}
{{- end -}}

{{- define "redpanda.rpc.advertise.port" -}}
{{- .Values.config.redpanda.rpc_server.port -}}
{{- end -}}

{{- define "redpanda.rpc.listen.address" -}}
{{- "$(POD_IP)" -}}
{{- end -}}

{{- define "redpanda.rpc.listen.port" -}}
{{- .Values.config.redpanda.rpc_server.port -}}
{{- end -}}

8 changes: 3 additions & 5 deletions redpanda/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ data:
redpanda:
{{ toYaml .Values.config.redpanda | indent 6 }}
seed_servers:
{{- $envAll := . }}
{{- range untilStep 0 (.Values.statefulset.replicas|int) 1 }}
- node_id: {{ . }}
host:
address: {{ template "redpanda.fullname" $envAll }}-{{ . }}.{{ template "redpanda.fullname" $envAll }}.{{ $envAll.Release.Namespace }}.svc.{{ $envAll.Values.clusterDomain }}
port: {{ $envAll.Values.config.redpanda.rpc_server.port }}
- host:
address: "{{ template "redpanda.fullname" $ }}-{{ . }}.{{ template "redpanda.internal.domain" $ }}"
port: {{ template "redpanda.rpc.advertise.port" $ }}
{{- end }}
rpk:
{{ toYaml .Values.config.rpk | indent 6 }}
4 changes: 2 additions & 2 deletions redpanda/templates/service.bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ spec:
ports:
- name: kafka-tcp
protocol: TCP
port: {{ .Values.config.redpanda.kafka_api.port }}
targetPort: {{ .Values.config.redpanda.kafka_api.port }}
port: {{ template "redpanda.kafka.internal.advertise.port" $ }}
targetPort: {{ template "redpanda.kafka.internal.advertise.port" $ }}
selector:
app.kubernetes.io/name: {{ template "redpanda.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
4 changes: 2 additions & 2 deletions redpanda/templates/service.discovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ spec:
ports:
- name: kafka-tcp
protocol: TCP
port: {{ .Values.config.redpanda.kafka_api.port }}
targetPort: {{ .Values.config.redpanda.kafka_api.port }}
port: {{ template "redpanda.kafka.internal.advertise.port" $ }}
targetPort: {{ template "redpanda.kafka.internal.advertise.port" $ }}
selector:
app.kubernetes.io/name: {{ template "redpanda.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
46 changes: 31 additions & 15 deletions redpanda/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,27 @@ spec:
spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
# TODO:
# * Figure out what to do about node_id / seeds here - the operator will fix this separately
# * Once that's done, this initContainer can be removed
initContainers:
- name: {{ template "redpanda.name" . }}-configurator
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
command: ["/bin/sh", "-c"]
env:
- name: SERVICE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
args:
- >
CONFIG=/etc/redpanda/redpanda.yaml;
NODE_ID=${HOSTNAME##*-};
SERVICE_NAME={{ template "redpanda.fullname" . }}-$NODE_ID.{{ template "redpanda.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }};
cp /tmp/base-config/redpanda.yaml $CONFIG;
rpk --config $CONFIG config set redpanda.node_id $NODE_ID;
NODE_ID=${SERVICE_NAME##*-};
cp /tmp/base-config/redpanda.yaml "$CONFIG";
rpk --config "$CONFIG" config set redpanda.node_id $NODE_ID;
if [ "$NODE_ID" = "0" ]; then
rpk --config $CONFIG config set redpanda.seed_servers '[]' --format yaml;
rpk --config "$CONFIG" config set redpanda.seed_servers '[]' --format yaml;
fi;
rpk --config $CONFIG config set redpanda.advertised_rpc_api.address $SERVICE_NAME;
rpk --config $CONFIG config set redpanda.advertised_rpc_api.port {{ .Values.config.redpanda.rpc_server.port }};
rpk --config $CONFIG config set redpanda.advertised_kafka_api.address $SERVICE_NAME;
rpk --config $CONFIG config set redpanda.advertised_kafka_api.port {{ .Values.config.redpanda.kafka_api.port }};
volumeMounts:
- name: {{ template "redpanda.fullname" . }}
mountPath: /tmp/base-config
Expand All @@ -81,21 +84,34 @@ spec:
containers:
- name: {{ template "redpanda.name" . }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
env:
- name: SERVICE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
args:
- >
--check=false
--smp {{ .Values.statefulset.resources.limits.cpu }}
--memory {{ template "redpanda.parseMemory" . }}
redpanda
start
--smp={{ .Values.statefulset.resources.limits.cpu }}
--memory={{ template "redpanda.parseMemory" . }}
--reserve-memory=0M
--advertise-kafka-addr=internal://{{ template "redpanda.kafka.internal.advertise.address" . }}:{{ template "redpanda.kafka.internal.advertise.port" . }}
--kafka-addr=internal://{{ template "redpanda.kafka.internal.listen.address" . }}:{{ template "redpanda.kafka.internal.listen.port" . }}
--advertise-rpc-addr={{ template "redpanda.rpc.advertise.address" . }}:{{ template "redpanda.rpc.advertise.port" . }}
--rpc-addr={{ template "redpanda.rpc.listen.address" . }}:{{ template "redpanda.rpc.listen.port" . }}
--
--default-log-level={{ .Values.config.seastar.default_log_level }}
--reserve-memory 0M
ports:
- containerPort: {{ .Values.config.redpanda.admin.port }}
name: admin
- containerPort: {{ .Values.config.redpanda.kafka_api.port }}
- containerPort: {{ template "redpanda.kafka.internal.listen.port" . }}
name: kafka
- containerPort: {{ .Values.config.redpanda.rpc_server.port }}
- containerPort: {{ template "redpanda.rpc.listen.port" $ }}
name: rpc
volumeMounts:
- name: datadir
Expand Down
2 changes: 1 addition & 1 deletion redpanda/templates/tests/test-api-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
containers:
- name: {{ template "redpanda.name" . }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
args: ["api", "status", "--brokers", "{{ include "redpanda.fullname" . }}:{{ .Values.config.redpanda.kafka_api.port }}"]
args: ["api", "status", "--brokers", "{{ include "redpanda.fullname" . }}:{{ template "redpanda.kafka.internal.advertise.port" $ }}"]
volumeMounts:
- name: {{ template "redpanda.fullname" . }}
mountPath: /tmp/base-config
Expand Down
12 changes: 9 additions & 3 deletions redpanda/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ config:
#
# Metrics are served off of this port at /metrics.
port: 9644

# Kafka API listeners
# The first entry is used to set up the headless service.
# Other entries are ignored.
kafka_api:
# The port for the Kafka API.
port: 9092
- name: internal
address: $(POD_IP)
port: 9092

# rpc server listener
rpc_server:
# The port for the internal RPC server.
port: 33145

rpk:
Expand Down

0 comments on commit 8e62474

Please sign in to comment.