From d877fc3312192cce1bf29d0c35f665ce513b8841 Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Wed, 30 Oct 2024 00:29:27 +0200 Subject: [PATCH] Use Pulsar 4.0.0 image, bump chart version to 3.7.0, kube-prometheus-stack to 65.x (#542) * Use Pulsar 4.0.0 image, bump chart version to 3.7.0 * Bump kube-prometheus-stack to 65.x.x * Remove testing with latest and test with previous LTS version - run kube-prometheus-stack test with previous LTS version since the older chart version doesn't support Pulsar 4.0.0 image * Fix passing "--values" to helm command * Move ci runner config to a script * Attempt to fix pulsar-manager-cluster-initialize --- .ci/chart_test.sh | 18 +++++-- .ci/clusters/values-pulsar-latest.yaml | 20 -------- ...e.yaml => values-pulsar-previous-lts.yaml} | 2 +- .ci/configure_ci_runner_for_debugging.sh | 41 +++++++++++++++ .ci/helm.sh | 24 +++++++-- .github/workflows/pulsar-helm-chart-ci.yaml | 50 +++---------------- README.md | 17 ++++++- charts/pulsar/Chart.yaml | 6 +-- .../pulsar-manager-cluster-initialize.yaml | 1 + .../upgrade_prometheus_operator_crds.sh | 2 +- 10 files changed, 101 insertions(+), 80 deletions(-) delete mode 100644 .ci/clusters/values-pulsar-latest.yaml rename .ci/clusters/{values-pulsar-image.yaml => values-pulsar-previous-lts.yaml} (96%) create mode 100755 .ci/configure_ci_runner_for_debugging.sh diff --git a/.ci/chart_test.sh b/.ci/chart_test.sh index e91f3d1b..3196c021 100755 --- a/.ci/chart_test.sh +++ b/.ci/chart_test.sh @@ -36,13 +36,21 @@ ci::create_cluster ci::helm_repo_add -extra_opts="" +extra_opts=() + +# Add any arguments after $1 to extra_opts +shift # Remove $1 from the argument list +while [[ $# -gt 0 ]]; do + extra_opts+=("$1") + shift +done + if [[ "x${SYMMETRIC}" == "xtrue" ]]; then - extra_opts="-s" + extra_opts+=("-s") fi if [[ "x${EXTRA_SUPERUSERS}" != "x" ]]; then - extra_opts="${extra_opts} --pulsar-superusers proxy-admin,broker-admin,admin,${EXTRA_SUPERUSERS}" + extra_opts+=("--pulsar-superusers" "proxy-admin,broker-admin,admin,${EXTRA_SUPERUSERS}") fi install_type="install" @@ -50,7 +58,7 @@ test_action="produce-consume" if [[ "$UPGRADE_FROM_VERSION" != "" ]]; then # install older version of pulsar chart PULSAR_CHART_VERSION="$UPGRADE_FROM_VERSION" - ci::install_pulsar_chart install ${PULSAR_HOME}/.ci/values-common.yaml ${PULSAR_HOME}/${VALUES_FILE} ${extra_opts} + ci::install_pulsar_chart install ${PULSAR_HOME}/.ci/values-common.yaml ${PULSAR_HOME}/${VALUES_FILE} "${extra_opts[@]}" install_type="upgrade" echo "Wait 10 seconds" sleep 10 @@ -68,7 +76,7 @@ fi PULSAR_CHART_VERSION="local" # install (or upgrade) pulsar chart -ci::install_pulsar_chart ${install_type} ${PULSAR_HOME}/.ci/values-common.yaml ${PULSAR_HOME}/${VALUES_FILE} ${extra_opts} +ci::install_pulsar_chart ${install_type} ${PULSAR_HOME}/.ci/values-common.yaml ${PULSAR_HOME}/${VALUES_FILE} "${extra_opts[@]}" echo "Wait 10 seconds" sleep 10 diff --git a/.ci/clusters/values-pulsar-latest.yaml b/.ci/clusters/values-pulsar-latest.yaml deleted file mode 100644 index 2a3526c0..00000000 --- a/.ci/clusters/values-pulsar-latest.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# -# 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. -# - -defaultPulsarImageTag: 3.3.1 \ No newline at end of file diff --git a/.ci/clusters/values-pulsar-image.yaml b/.ci/clusters/values-pulsar-previous-lts.yaml similarity index 96% rename from .ci/clusters/values-pulsar-image.yaml rename to .ci/clusters/values-pulsar-previous-lts.yaml index e332a4fd..b87d9b92 100644 --- a/.ci/clusters/values-pulsar-image.yaml +++ b/.ci/clusters/values-pulsar-previous-lts.yaml @@ -17,4 +17,4 @@ # under the License. # -defaultPulsarImageTag: 3.3.2 \ No newline at end of file +defaultPulsarImageTag: 3.0.7 \ No newline at end of file diff --git a/.ci/configure_ci_runner_for_debugging.sh b/.ci/configure_ci_runner_for_debugging.sh new file mode 100755 index 00000000..c0ea76e8 --- /dev/null +++ b/.ci/configure_ci_runner_for_debugging.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# this script is used to install tools for the GitHub Actions CI runner while debugging with ssh + +if [[ -z "${GITHUB_ACTIONS}" ]]; then + echo "Error: This script is intended to run only in GitHub Actions environment" + exit 1 +fi + +cat >> $HOME/.bashrc <<'EOF' +function use_kind_kubeconfig() { + export KUBECONFIG=$(ls $HOME/kind/pulsar-ci-*/kubeconfig.yaml) +} + +function kubectl() { + # use kind environment's kubeconfig + if [ -z "$KUBECONFIG" ]; then + use_kind_kubeconfig + fi + command kubectl "$@" +} + +function k9s() { + # use kind environment's kubeconfig + if [ -z "$KUBECONFIG" ]; then + use_kind_kubeconfig + fi + # install k9s on the fly + if [ ! -x /usr/local/bin/k9s ]; then + echo "Installing k9s..." + curl -L -s https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_Linux_amd64.tar.gz | sudo tar xz -C /usr/local/bin k9s + fi + command k9s "$@" +} + +alias k=kubectl +EOF +cat >> $HOME/.bash_profile <<'EOF' +if [ -f ~/.bashrc ]; then + source ~/.bashrc +fi +EOF \ No newline at end of file diff --git a/.ci/helm.sh b/.ci/helm.sh index 69fabfbf..516e82c7 100644 --- a/.ci/helm.sh +++ b/.ci/helm.sh @@ -112,15 +112,29 @@ function ci::install_pulsar_chart() { local install_type=$1 local common_value_file=$2 local value_file=$3 - local extra_opts="$4 $5 $6 $7 $8" + shift 3 + local extra_values=() + local extra_opts=() + local values_next=false + for arg in "$@"; do + if [[ "$arg" == "--values" ]]; then + extra_values+=("$arg") + values_next=true + elif [[ "$values_next" == true ]]; then + extra_values+=("$arg") + values_next=false + else + extra_opts+=("$arg") + fi + done local install_args if [[ "${install_type}" == "install" ]]; then echo "Installing the pulsar chart" ${KUBECTL} create namespace ${NAMESPACE} ci::install_cert_manager - echo ${CHARTS_HOME}/scripts/pulsar/prepare_helm_release.sh -k ${CLUSTER} -n ${NAMESPACE} ${extra_opts} - ${CHARTS_HOME}/scripts/pulsar/prepare_helm_release.sh -k ${CLUSTER} -n ${NAMESPACE} ${extra_opts} + echo ${CHARTS_HOME}/scripts/pulsar/prepare_helm_release.sh -k ${CLUSTER} -n ${NAMESPACE} "${extra_opts[@]}" + ${CHARTS_HOME}/scripts/pulsar/prepare_helm_release.sh -k ${CLUSTER} -n ${NAMESPACE} "${extra_opts[@]}" sleep 10 # install metallb for loadbalancer support @@ -154,8 +168,8 @@ function ci::install_pulsar_chart() { fi fi set -x - ${HELM} template --values ${common_value_file} --values ${value_file} ${CLUSTER} ${CHART_ARGS} - ${HELM} ${install_type} --values ${common_value_file} --values ${value_file} --namespace=${NAMESPACE} ${CLUSTER} ${CHART_ARGS} ${install_args} + ${HELM} template --values ${common_value_file} --values ${value_file} "${extra_values[@]}" ${CLUSTER} ${CHART_ARGS} + ${HELM} ${install_type} --values ${common_value_file} --values ${value_file} "${extra_values[@]}" --namespace=${NAMESPACE} ${CLUSTER} ${CHART_ARGS} ${install_args} set +x if [[ "${install_type}" == "install" ]]; then diff --git a/.github/workflows/pulsar-helm-chart-ci.yaml b/.github/workflows/pulsar-helm-chart-ci.yaml index 1dd79b75..f9fdf1b7 100644 --- a/.github/workflows/pulsar-helm-chart-ci.yaml +++ b/.github/workflows/pulsar-helm-chart-ci.yaml @@ -178,9 +178,9 @@ jobs: values_file: .ci/clusters/values-upgrade.yaml shortname: upgrade type: upgrade - - name: Use Pulsar Image - values_file: .ci/clusters/values-pulsar-image.yaml - shortname: pulsar-image + - name: Use previous LTS Pulsar Image + values_file: .ci/clusters/values-pulsar-previous-lts.yaml + shortname: pulsar-previous-lts - name: JWT Asymmetric Keys values_file: .ci/clusters/values-jwt-asymmetric.yaml shortname: jwt-asymmetric @@ -209,13 +209,6 @@ jobs: values_file: .ci/clusters/values-pulsar-manager.yaml shortname: pulsar-manager include: - - k8sVersion: - version: "1.23.17" - kind_image_tag: v1.23.17@sha256:14d0a9a892b943866d7e6be119a06871291c517d279aedb816a4b4bc0ec0a5b3 - testScenario: - name: "Pulsar Latest" - values_file: .ci/clusters/values-pulsar-latest.yaml - shortname: pulsar-latest - k8sVersion: version: "1.23.17" kind_image_tag: v1.23.17@sha256:14d0a9a892b943866d7e6be119a06871291c517d279aedb816a4b4bc0ec0a5b3 @@ -236,8 +229,8 @@ jobs: version: "1.23.17" kind_image_tag: v1.23.17@sha256:14d0a9a892b943866d7e6be119a06871291c517d279aedb816a4b4bc0ec0a5b3 testScenario: - name: "Upgrade kube-prometheus-stack" - values_file: .ci/clusters/values-prometheus-grafana.yaml + name: "Upgrade kube-prometheus-stack for previous LTS" + values_file: .ci/clusters/values-prometheus-grafana.yaml --values .ci/clusters/values-pulsar-previous-lts.yaml shortname: prometheus-grafana type: upgrade upgradeFromVersion: 3.2.0 @@ -263,38 +256,7 @@ jobs: - name: Setup debugging tools for ssh access if: ${{ github.repository != 'apache/pulsar-helm-chart' && github.event_name == 'pull_request' }} - run: | - cat >> $HOME/.bashrc <<'EOF' - function use_kind_kubeconfig() { - export KUBECONFIG=$(ls $HOME/kind/pulsar-ci-*/kubeconfig.yaml) - } - - function kubectl() { - # use kind environment's kubeconfig - if [ -z "$KUBECONFIG" ]; then - use_kind_kubeconfig - fi - command kubectl "$@" - } - - function k9s() { - # use kind environment's kubeconfig - if [ -z "$KUBECONFIG" ]; then - use_kind_kubeconfig - fi - # install k9s on the fly - if [ ! -x /usr/local/bin/k9s ]; then - echo "Installing k9s..." - curl -L -s https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_Linux_amd64.tar.gz | sudo tar xz -C /usr/local/bin k9s - fi - command k9s "$@" - } - EOF - cat >> $HOME/.bash_profile <<'EOF' - if [ -f ~/.bashrc ]; then - source ~/.bashrc - fi - EOF + run: .ci/configure_ci_runner_for_debugging.sh - name: Setup ssh access to build runner VM # ssh access is enabled for builds in own forks diff --git a/README.md b/README.md index f0910b19..0f655b27 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,20 @@ helm upgrade -f pulsar.yaml \ For more detailed information, see our [Upgrading](http://pulsar.apache.org/docs/helm-upgrade/) guide. +## Upgrading from Helm Chart version 3.0.0-3.6.0 to 3.7.0 version and above + +The kube-prometheus-stack version has been upgraded to 65.x.x in Pulsar Helm Chart version 3.7.0 . +Before running "helm upgrade", you should first upgrade the Prometheus Operator CRDs as [instructed +in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-64x-to-65x). + +There's a script to run the required commands: + +```shell +./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.77.1 +``` + +After, this you can proceed with `helm upgrade`. + ## Upgrading from Helm Chart version 3.0.0-3.4.x to 3.5.0 version and above The kube-prometheus-stack version has been upgraded to 59.x.x in Pulsar Helm Chart version 3.5.0 . @@ -252,13 +266,13 @@ Before running "helm upgrade", you should first upgrade the Prometheus Operator in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-58x-to-59x). There's a script to run the required commands: + ```shell ./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.74.0 ``` After, this you can proceed with `helm upgrade`. - ## Upgrading from Helm Chart version 3.0.0-3.2.x to 3.3.0 version and above The kube-prometheus-stack version has been upgraded to 56.x.x in Pulsar Helm Chart version 3.3.0 . @@ -266,6 +280,7 @@ Before running "helm upgrade", you should first upgrade the Prometheus Operator in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-55x-to-56x). There's a script to run the required commands: + ```shell ./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.71.0 ``` diff --git a/charts/pulsar/Chart.yaml b/charts/pulsar/Chart.yaml index 1380f1ca..82c90786 100644 --- a/charts/pulsar/Chart.yaml +++ b/charts/pulsar/Chart.yaml @@ -18,10 +18,10 @@ # apiVersion: v2 -appVersion: "3.0.7" +appVersion: "4.0.0" description: Apache Pulsar Helm chart for Kubernetes name: pulsar -version: 3.6.0 +version: 3.7.0 kubeVersion: ">=1.23.0-0" home: https://pulsar.apache.org sources: @@ -33,6 +33,6 @@ maintainers: email: dev@pulsar.apache.org dependencies: - name: kube-prometheus-stack - version: 59.x.x + version: 65.x.x repository: https://prometheus-community.github.io/helm-charts condition: kube-prometheus-stack.enabled diff --git a/charts/pulsar/templates/pulsar-manager-cluster-initialize.yaml b/charts/pulsar/templates/pulsar-manager-cluster-initialize.yaml index 39a6c186..6fe34231 100755 --- a/charts/pulsar/templates/pulsar-manager-cluster-initialize.yaml +++ b/charts/pulsar/templates/pulsar-manager-cluster-initialize.yaml @@ -83,6 +83,7 @@ spec: command: [ "sh", "-c" ] args: - | + cd /tmp 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) UI_URL={{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}:{{ .Values.pulsar_manager.service.port }} diff --git a/scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh b/scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh index d762a834..ebf4ae37 100755 --- a/scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh +++ b/scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh @@ -21,7 +21,7 @@ # This script is used to upgrade the Prometheus Operator CRDs before running "helm upgrade" # source: https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#upgrading-an-existing-release-to-a-new-major-version # "Run these commands to update the CRDs before applying the upgrade." -PROMETHEUS_OPERATOR_VERSION="${1:-"0.74.0"}" +PROMETHEUS_OPERATOR_VERSION="${1:-"0.77.1"}" PREFIX_URL="https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v${PROMETHEUS_OPERATOR_VERSION}/example/prometheus-operator-crd" for crd in alertmanagerconfigs alertmanagers podmonitors probes prometheusagents prometheuses prometheusrules scrapeconfigs servicemonitors thanosrulers; do # "--force-conflicts" is required to upgrade the CRDs. Following instructions from https://github.com/prometheus-community/helm-charts/issues/2489