-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/pulsar manager initialize (#457)
* add better pulsar manager integration and init along with tests & docs * fix pulsar manager startup args * update pulsar manager service to ClusterIP + remove duplicate
- Loading branch information
Showing
11 changed files
with
295 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
components: | ||
pulsar_manager: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
charts/pulsar/templates/pulsar-manager-cluster-initialize.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# | ||
# 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: | ||
{{- if or .Values.job.ttl.enabled (semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version) }} | ||
ttlSecondsAfterFinished: {{ .Values.job.ttl.secondsAfterFinished | default 600 }} | ||
{{- 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 12 }} | ||
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 -v \ | ||
-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 -v \ | ||
-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 }}" | ||
{{- else }} | ||
BROKER_URL="https://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}:{{ .Values.broker.ports.https }}" | ||
{{- end }} | ||
BOOKIE_URL="http://{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}:{{ .Values.bookkeeper.ports.http }}" | ||
curl -v \ | ||
-X PUT http://${UI_URL}/pulsar-manager/environments/environment \ | ||
-H 'Content-Type: application/json' \ | ||
-H "token: $LOGIN_TOKEN" \ | ||
-H "X-XSRF-TOKEN: $CSRF_TOKEN" \ | ||
-H "username: $USERNAME" \ | ||
-H "Cookie: XSRF-TOKEN=$CSRF_TOKEN; JSESSIONID=$LOGIN_JSESSSIONID;" \ | ||
-d '{ "name": "{{ template "pulsar.fullname" . }}", "broker": "'$BROKER_URL'", "bookie": "'$BOOKIE_URL'"}' | ||
env: | ||
- name: USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-secret" | ||
key: UI_USERNAME | ||
- name: PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}-secret" | ||
key: UI_PASSWORD | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.