Mortom123 commented on code in PR #448: URL: https://github.com/apache/pulsar-helm-chart/pull/448#discussion_r1469331877
########## charts/pulsar/templates/pulsar_manager_cluster_initialize.yaml: ########## @@ -0,0 +1,137 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +{{- if or .Release.IsInstall .Values.initialize }} +{{- if or .Values.components.pulsar_manager .Values.extra.pulsar_manager }} +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-init" + namespace: {{ template "pulsar.namespace" . }} + labels: + {{- include "pulsar.standardLabels" . | nindent 4 }} + component: {{ .Values.pulsar_manager.component }}-init +spec: + # This feature was previously behind a feature gate for several Kubernetes versions and will default to true in 1.23 and beyond + # https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/ + {{- if .Values.job.ttl.enabled }} + ttlSecondsAfterFinished: {{ .Values.job.ttl.secondsAfterFinished }} + {{- end }} + template: + spec: + nodeSelector: + {{- if .Values.pulsar_metadata.nodeSelector }} + {{ toYaml .Values.pulsar_metadata.nodeSelector | indent 8 }} + {{- end }} + tolerations: + {{- if .Values.pulsar_metadata.tolerations }} + {{ toYaml .Values.pulsar_metadata.tolerations | indent 8 }} + {{- end }} + restartPolicy: OnFailure + initContainers: + - name: wait-pulsar-manager-ready + image: "{{ template "pulsar.imageFullName" (dict "image" .Values.pulsar_metadata.image "root" .) }}" + imagePullPolicy: {{ .Values.pulsar_metadata.image.pullPolicy }} + resources: {{ toYaml .Values.initContainer.resources | nindent 12 }} + command: [ "sh", "-c" ] + args: + - | + ADMIN_URL={{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-admin:{{ .Values.pulsar_manager.adminService.port }} + until $(curl -sS --fail -X GET http://${ADMIN_URL} > /dev/null 2>&1); do + sleep 3; + done; + # This init container will wait for at least one broker to be ready before + # initializing the pulsar-manager + - name: wait-broker-ready + image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.proxy "root" .) }}" + imagePullPolicy: {{ .Values.images.proxy.pullPolicy }} + resources: {{ toYaml .Values.initContainer.resources | nindent 10 }} + command: [ "sh", "-c" ] + args: + - >- + set -e; + brokerServiceNumber="$(nslookup -timeout=10 {{ template "pulsar.fullname" . }}-{{ .Values.broker.component }} | grep Name | wc -l)"; + until [ ${brokerServiceNumber} -ge 1 ]; do + echo "pulsar cluster {{ template "pulsar.cluster.name" . }} isn't initialized yet ... check in 10 seconds ..."; + sleep 10; + brokerServiceNumber="$(nslookup -timeout=10 {{ template "pulsar.fullname" . }}-{{ .Values.broker.component }} | grep Name | wc -l)"; + done; + containers: + - name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-init" + image: "{{ template "pulsar.imageFullName" (dict "image" .Values.pulsar_metadata.image "root" .) }}" + imagePullPolicy: {{ .Values.pulsar_metadata.image.pullPolicy }} + {{- if .Values.pulsar_metadata.resources }} + resources: {{ toYaml .Values.pulsar_metadata.resources | nindent 12 }} + {{- end }} + command: [ "sh", "-c" ] + args: + - | + ADMIN_URL={{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-admin:{{ .Values.pulsar_manager.adminService.port }} + CSRF_TOKEN=$(curl http://${ADMIN_URL}/pulsar-manager/csrf-token) + {{/* set admin credentials */}} + curl \ + -X PUT http://${ADMIN_URL}/pulsar-manager/users/superuser \ + -H "X-XSRF-TOKEN: $CSRF_TOKEN" \ + -H "Cookie: XSRF-TOKEN=$CSRF_TOKEN;" \ + -H 'Content-Type: application/json' \ + -d '{"name": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'", "description": "Helm-managed Admin Account", "email": "'"${USERNAME}"'@pulsar.org"}' + + UI_URL={{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}:{{ .Values.pulsar_manager.service.port }} + {{/* login as admin */}} + curl \ + -X POST http://${UI_URL}/pulsar-manager/login \ + -H 'Accept: application/json, text/plain, */*' \ + -H 'Content-Type: application/json' \ + -H "X-XSRF-TOKEN: $CSRF_TOKEN" \ + -H "Cookie: XSRF-TOKEN=$CSRF_TOKEN" \ + -sS -D headers.txt \ + -d '{"username": "'${USERNAME}'", "password": "'${PASSWORD}'"}' + + LOGIN_TOKEN=$(grep "token:" headers.txt | sed 's/^.*: //') + LOGIN_JSESSSIONID=$(grep -o "JSESSIONID=[a-zA-Z0-9_]*" headers.txt | sed 's/^.*=//') + + {{/* create environment */}} + {{- if or (not .Values.tls.enabled) (not .Values.tls.broker.enabled) }} + BROKER_URL="http://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}:{{ .Values.broker.ports.http }}" + BOOKIE_URL="http://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}:{{ .Values.broker.ports.pulsar }}" Review Comment: I also tried to use .Values.bookie.component with any of the ports under .Values.bookie.ports, but none worked. However, .Values.bookie.component worked with .Values.broker.ports.pulsar ??? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
