From e80e53510075a7aeddecd1c9b3391ecbf5edb97d Mon Sep 17 00:00:00 2001 From: chejinge Date: Thu, 17 Oct 2024 10:37:21 +0800 Subject: [PATCH 1/8] fix:fix CI --- .github/workflows/pika.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pika.yml b/.github/workflows/pika.yml index 067a9c4a9..db5eff61d 100644 --- a/.github/workflows/pika.yml +++ b/.github/workflows/pika.yml @@ -16,7 +16,7 @@ jobs: # The CMake configure and build commands are platform-agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest + runs-on: ubuntu22 steps: - uses: actions/checkout@v4 From 9e1480ddb0f5b07ab525f47ab1eb878d741329bc Mon Sep 17 00:00:00 2001 From: chejinge Date: Thu, 17 Oct 2024 10:53:10 +0800 Subject: [PATCH 2/8] fix:fix CI --- .github/workflows/pika.yml | 121 ++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 68 deletions(-) diff --git a/.github/workflows/pika.yml b/.github/workflows/pika.yml index db5eff61d..da9448d8a 100644 --- a/.github/workflows/pika.yml +++ b/.github/workflows/pika.yml @@ -1,22 +1,18 @@ -name: Pika +name: Pika CI Pipeline on: push: - branches: [ "unstable", "3.5" , "4.0"] + branches: ["unstable", "3.5", "4.0"] pull_request: - branches: [ "unstable", "3.5" , "4.0"] + branches: ["unstable", "3.5", "4.0"] env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: RelWithDebInfo ARTIFACT_PIKA_NAME: artifact-pika jobs: build_on_ubuntu: - # The CMake configure and build commands are platform-agnostic and should work equally well on Windows or Mac. - # You can convert this to a matrix build if you need cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu22 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,50 +22,51 @@ jobs: with: go-version: 1.19 - - name: ccache + - name: Set up ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: key: ubuntu-latest - - name: Install Deps + - name: Install Dependencies run: | - sudo apt-get install -y autoconf libprotobuf-dev protobuf-compiler - sudo apt-get install -y clang-tidy-12 + sudo apt-get update + sudo apt-get install -y autoconf libprotobuf-dev protobuf-compiler clang-tidy - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + run: | + cmake -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DUSE_PIKA_TOOLS=ON \ + -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build - # Build your program with the given configuration - run: cmake --build build --config ${{ env.BUILD_TYPE }} + run: | + cmake --build build --config $BUILD_TYPE - name: Cleanup run: | - rm -rf ./deps + rm -rf ./deps rm -rf ./buildtrees - - uses: actions/upload-artifact@v3 + - name: Upload Artifact + uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_PIKA_NAME }} path: ${{ github.workspace }}/build/pika - - name: Test + - name: Run Tests working-directory: ${{ github.workspace }}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{ env.BUILD_TYPE }} --verbose + run: ctest -C $BUILD_TYPE --verbose - - name: Unit Test + - name: Run Unit Tests working-directory: ${{ github.workspace }} run: ./pikatests.sh all clean - # master on port 9221, slave on port 9231, all with 2 db - - name: Start codis, pika master and pika slave + - name: Start Services for Integration Tests working-directory: ${{ github.workspace }}/build run: | - echo "hello" + set -e chmod +x ../tests/integration/start_master_and_slave.sh ../tests/integration/start_master_and_slave.sh chmod +x ../tests/integration/start_codis.sh @@ -90,55 +87,44 @@ jobs: image: rockylinux:9 steps: - - name: Install deps + - name: Install Dependencies run: | dnf update -y - dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar g++ tar epel-release gcc-c++ libstdc++-devel gcc-toolset-13 + dnf install -y epel-release + dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar gcc-c++ libstdc++-devel clang make automake - name: Set up Go uses: actions/setup-go@v5 with: go-version: 1.19 - - name: Checkout + - name: Checkout Code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Configure CMake run: | - source /opt/rh/gcc-toolset-13/enable - cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address . - - - uses: actions/cache@v3 - with: - path: ${{ github.workspace }}/deps - key: ${{ runner.os }}-rocky-deps-${{ hashFiles('**/CMakeLists.txt') }} - - - uses: actions/cache@v3 - with: - path: ${{ github.workspace }}/buildtrees - key: ${{ runner.os }}-rocky-buildtrees-${{ hashFiles('**/CMakeLists.txt') }} + cmake -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address - name: Build run: | - source /opt/rh/gcc-toolset-13/enable - cmake --build build --config ${{ env.BUILD_TYPE }} + cmake --build build --config $BUILD_TYPE - name: Cleanup run: | - rm -rf ./deps + rm -rf ./deps rm -rf ./buildtrees - - name: Test + - name: Run Tests working-directory: ${{ github.workspace }}/build - run: ctest -C ${{ env.BUILD_TYPE }} + run: ctest -C $BUILD_TYPE - - name: Unit Test + - name: Run Unit Tests working-directory: ${{ github.workspace }} run: ./pikatests.sh all clean - - name: Start codis, pika master and pika slave + - name: Start Services for Integration Tests working-directory: ${{ github.workspace }}/build run: | chmod +x ../tests/integration/start_master_and_slave.sh @@ -166,41 +152,39 @@ jobs: with: go-version: 1.19 - - name: ccache + - name: Set up ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: key: macos-12 - - name: Install Deps + - name: Install Dependencies run: | brew update - brew install --overwrite python@3.12 autoconf protobuf llvm wget git - brew install gcc@10 automake cmake make binutils + brew install python@3.12 autoconf protobuf llvm wget git gcc@10 automake cmake make binutils - name: Configure CMake run: | - export CC=/usr/local/opt/gcc@10/bin/gcc-10 - cmake -B build -DCMAKE_C_COMPILER=/usr/local/opt/gcc@10/bin/gcc-10 -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + export CC=/usr/local/opt/gcc@10/bin/gcc-10 + cmake -B build -DCMAKE_C_COMPILER=$CC -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: | - cmake --build build --config ${{ env.BUILD_TYPE }} + cmake --build build --config $BUILD_TYPE - name: Cleanup run: | - rm -rf ./deps + rm -rf ./deps rm -rf ./buildtrees - - name: Test + - name: Run Tests working-directory: ${{ github.workspace }}/build - run: ctest -C ${{ env.BUILD_TYPE }} --verbose + run: ctest -C $BUILD_TYPE --verbose - - name: Unit Test + - name: Run Unit Tests working-directory: ${{ github.workspace }} - run: | - ./pikatests.sh all clean + run: ./pikatests.sh all clean - - name: Start codis, pika master and pika slave + - name: Start Services for Integration Tests working-directory: ${{ github.workspace }}/build run: | chmod +x ../tests/integration/start_master_and_slave.sh @@ -218,11 +202,12 @@ jobs: sh integrate_test.sh build_pika_image: - name: Build Pika Docker image + name: Build Pika Docker Image runs-on: ubuntu-latest needs: build_on_ubuntu + steps: - - name: Check out the repo + - name: Check out the Repo uses: actions/checkout@v4 - name: Set up QEMU @@ -231,9 +216,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Extract metadata (tags, labels) for Docker + - name: Extract Metadata for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v4 with: images: pikadb/pika @@ -242,7 +227,7 @@ jobs: name: ${{ env.ARTIFACT_PIKA_NAME }} path: artifact/ - - name: Build Docker image + - name: Build Docker Image uses: docker/build-push-action@v5 with: context: . From c2f580b810702a1590e523ca99dc1f145fadc79e Mon Sep 17 00:00:00 2001 From: chejinge Date: Thu, 17 Oct 2024 11:03:34 +0800 Subject: [PATCH 3/8] fix:fix CI --- .github/workflows/pika.yml | 115 +++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pika.yml b/.github/workflows/pika.yml index da9448d8a..b8fddf591 100644 --- a/.github/workflows/pika.yml +++ b/.github/workflows/pika.yml @@ -1,17 +1,21 @@ -name: Pika CI Pipeline +name: Pika on: push: - branches: ["unstable", "3.5", "4.0"] + branches: [ "unstable", "3.5" , "4.0"] pull_request: - branches: ["unstable", "3.5", "4.0"] + branches: [ "unstable", "3.5" , "4.0"] env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: RelWithDebInfo ARTIFACT_PIKA_NAME: artifact-pika jobs: build_on_ubuntu: + # The CMake configure and build commands are platform-agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix runs-on: ubuntu-latest steps: @@ -22,51 +26,50 @@ jobs: with: go-version: 1.19 - - name: Set up ccache + - name: ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: key: ubuntu-latest - - name: Install Dependencies + - name: Install Deps run: | sudo apt-get update sudo apt-get install -y autoconf libprotobuf-dev protobuf-compiler clang-tidy - name: Configure CMake - run: | - cmake -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DUSE_PIKA_TOOLS=ON \ - -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build - run: | - cmake --build build --config $BUILD_TYPE + # Build your program with the given configuration + run: cmake --build build --config ${{ env.BUILD_TYPE }} - name: Cleanup run: | - rm -rf ./deps + rm -rf ./deps rm -rf ./buildtrees - - name: Upload Artifact - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_PIKA_NAME }} path: ${{ github.workspace }}/build/pika - - name: Run Tests + - name: Test working-directory: ${{ github.workspace }}/build - run: ctest -C $BUILD_TYPE --verbose + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{ env.BUILD_TYPE }} --verbose - - name: Run Unit Tests + - name: Unit Test working-directory: ${{ github.workspace }} run: ./pikatests.sh all clean - - name: Start Services for Integration Tests + # master on port 9221, slave on port 9231, all with 2 db + - name: Start codis, pika master and pika slave working-directory: ${{ github.workspace }}/build run: | - set -e + echo "hello" chmod +x ../tests/integration/start_master_and_slave.sh ../tests/integration/start_master_and_slave.sh chmod +x ../tests/integration/start_codis.sh @@ -87,44 +90,55 @@ jobs: image: rockylinux:9 steps: - - name: Install Dependencies + - name: Install deps run: | dnf update -y - dnf install -y epel-release - dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar gcc-c++ libstdc++-devel clang make automake + dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar g++ tar epel-release gcc-c++ libstdc++-devel gcc-toolset-13 - name: Set up Go uses: actions/setup-go@v5 with: go-version: 1.19 - - name: Checkout Code + - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Configure CMake run: | - cmake -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address + source /opt/rh/gcc-toolset-13/enable + cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address . + + - uses: actions/cache@v3 + with: + path: ${{ github.workspace }}/deps + key: ${{ runner.os }}-rocky-deps-${{ hashFiles('**/CMakeLists.txt') }} + + - uses: actions/cache@v3 + with: + path: ${{ github.workspace }}/buildtrees + key: ${{ runner.os }}-rocky-buildtrees-${{ hashFiles('**/CMakeLists.txt') }} - name: Build run: | - cmake --build build --config $BUILD_TYPE + source /opt/rh/gcc-toolset-13/enable + cmake --build build --config ${{ env.BUILD_TYPE }} - name: Cleanup run: | - rm -rf ./deps + rm -rf ./deps rm -rf ./buildtrees - - name: Run Tests + - name: Test working-directory: ${{ github.workspace }}/build - run: ctest -C $BUILD_TYPE + run: ctest -C ${{ env.BUILD_TYPE }} - - name: Run Unit Tests + - name: Unit Test working-directory: ${{ github.workspace }} run: ./pikatests.sh all clean - - name: Start Services for Integration Tests + - name: Start codis, pika master and pika slave working-directory: ${{ github.workspace }}/build run: | chmod +x ../tests/integration/start_master_and_slave.sh @@ -152,39 +166,41 @@ jobs: with: go-version: 1.19 - - name: Set up ccache + - name: ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: key: macos-12 - - name: Install Dependencies + - name: Install Deps run: | brew update - brew install python@3.12 autoconf protobuf llvm wget git gcc@10 automake cmake make binutils + brew install --overwrite python@3.12 autoconf protobuf llvm wget git + brew install gcc@10 automake cmake make binutils - name: Configure CMake run: | - export CC=/usr/local/opt/gcc@10/bin/gcc-10 - cmake -B build -DCMAKE_C_COMPILER=$CC -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + export CC=/usr/local/opt/gcc@10/bin/gcc-10 + cmake -B build -DCMAKE_C_COMPILER=/usr/local/opt/gcc@10/bin/gcc-10 -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: | - cmake --build build --config $BUILD_TYPE + cmake --build build --config ${{ env.BUILD_TYPE }} - name: Cleanup run: | - rm -rf ./deps + rm -rf ./deps rm -rf ./buildtrees - - name: Run Tests + - name: Test working-directory: ${{ github.workspace }}/build - run: ctest -C $BUILD_TYPE --verbose + run: ctest -C ${{ env.BUILD_TYPE }} --verbose - - name: Run Unit Tests + - name: Unit Test working-directory: ${{ github.workspace }} - run: ./pikatests.sh all clean + run: | + ./pikatests.sh all clean - - name: Start Services for Integration Tests + - name: Start codis, pika master and pika slave working-directory: ${{ github.workspace }}/build run: | chmod +x ../tests/integration/start_master_and_slave.sh @@ -202,12 +218,11 @@ jobs: sh integrate_test.sh build_pika_image: - name: Build Pika Docker Image + name: Build Pika Docker image runs-on: ubuntu-latest needs: build_on_ubuntu - steps: - - name: Check out the Repo + - name: Check out the repo uses: actions/checkout@v4 - name: Set up QEMU @@ -216,9 +231,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Extract Metadata for Docker + - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: images: pikadb/pika @@ -227,7 +242,7 @@ jobs: name: ${{ env.ARTIFACT_PIKA_NAME }} path: artifact/ - - name: Build Docker Image + - name: Build Docker image uses: docker/build-push-action@v5 with: context: . From d10baeec0e816693b2d45a07bce26b43a65fb36a Mon Sep 17 00:00:00 2001 From: chejinge Date: Thu, 17 Oct 2024 14:32:26 +0800 Subject: [PATCH 4/8] feat:master-slave add expoter && sentinel --- .../grafana/configmap-dashboards.yaml | 19 ++++++ .../componentversion-pika-expter.yaml | 65 +++++++++++++++++++ .../componentversion-redis-sentinel.yaml | 65 +++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 tools/kubeblocks_helm/pika-master-slave-cluster/templates/grafana/configmap-dashboards.yaml create mode 100644 tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expter.yaml create mode 100644 tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml diff --git a/tools/kubeblocks_helm/pika-master-slave-cluster/templates/grafana/configmap-dashboards.yaml b/tools/kubeblocks_helm/pika-master-slave-cluster/templates/grafana/configmap-dashboards.yaml new file mode 100644 index 000000000..104062188 --- /dev/null +++ b/tools/kubeblocks_helm/pika-master-slave-cluster/templates/grafana/configmap-dashboards.yaml @@ -0,0 +1,19 @@ +{{- $files := .Files.Glob "dashboards/*.json" }} +{{- if $files }} +apiVersion: v1 +kind: ConfigMapList +items: +{{- range $path, $fileContents := $files }} +{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }} +- apiVersion: v1 + kind: ConfigMap + metadata: + name: {{ printf "%s-grafana-%s" (include "pika.name" $) $dashboardName | trunc 63 | trimSuffix "-" }} + labels: + grafana_dashboard: "1" + app: {{ template "pika.name" $ }}-grafana +{{ include "pika.labels" $ | indent 6 }} + data: + {{ $dashboardName }}.json: {{ $.Files.Get $path | toJson }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expter.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expter.yaml new file mode 100644 index 000000000..3b2b42930 --- /dev/null +++ b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expter.yaml @@ -0,0 +1,65 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ComponentDefinition +metadata: + name: pika-exporter + namespace: {{ .Release.Namespace }} + labels: + {{- include "pika.labels" . | nindent 4 }} +spec: + provider: pika + description: A pika exporter component definition + serviceKind: pika-exporter + serviceVersion: {{ .Chart.AppVersion }} + services: + - name: expoter + spec: + ports: + - name: expoter + port: 9121 + targetPort: expoter + updateStrategy: Serial + configs: + - name: pika-config + templateRef: pika-conf-template + namespace: {{ .Release.Namespace }} + volumeName: config + vars: + ## reference to the pika-codis-dashboard service + - name: DASHBOARD_ADDR + valueFrom: + serviceVarRef: + compDef: pika-codis-dashboard + name: dashboard + optional: true + host: Optional + runtime: + initContainers: + - name: wait-codis-dashboard + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + image: busybox:1.28 + command: + - 'sh' + - '-c' + - "until nc -z ${DASHBOARD_ADDR} 18080; do echo waiting for codis dashboard; sleep 2; done;" + containers: + - name: pika-exporter + image: {{ include "pikaExporter.image" . }} + imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} + ports: + - name: expoter + containerPort: 9121 + volumeMounts: + - name: config + mountPath: /etc/pika + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + command: + - "/pika/bin/pika_exporter" + args: + - "-config" + - "/etc/pika/info.toml" + - "-codis.addr" + - "http://$(DASHBOARD_ADDR):18080/topom" \ No newline at end of file diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml new file mode 100644 index 000000000..22c3d6a87 --- /dev/null +++ b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml @@ -0,0 +1,65 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ComponentDefinition +metadata: + name: pika-exporter + namespace: {{ .Release.Namespace }} + labels: + {{- include "pika.labels" . | nindent 4 }} +spec: + provider: pika + description: A pika exporter component definition + serviceKind: redis-sentinel + serviceVersion: {{ .Chart.AppVersion }} + services: + - name: expoter + spec: + ports: + - name: expoter + port: 9121 + targetPort: expoter + updateStrategy: Serial + configs: + - name: pika-config + templateRef: pika-conf-template + namespace: {{ .Release.Namespace }} + volumeName: config + vars: + ## reference to the pika-codis-dashboard service + - name: DASHBOARD_ADDR + valueFrom: + serviceVarRef: + compDef: pika-codis-dashboard + name: dashboard + optional: true + host: Optional + runtime: + initContainers: + - name: wait-codis-dashboard + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + image: busybox:1.28 + command: + - 'sh' + - '-c' + - "until nc -z ${DASHBOARD_ADDR} 18080; do echo waiting for codis dashboard; sleep 2; done;" + containers: + - name: pika-exporter + image: {{ include "pikaExporter.image" . }} + imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} + ports: + - name: expoter + containerPort: 9121 + volumeMounts: + - name: config + mountPath: /etc/pika + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + command: + - "/pika/bin/pika_exporter" + args: + - "-config" + - "/etc/pika/info.toml" + - "-codis.addr" + - "http://$(DASHBOARD_ADDR):18080/topom" \ No newline at end of file From b33d62b35cf372517fac491a1b7083c741db5194 Mon Sep 17 00:00:00 2001 From: chejinge Date: Fri, 18 Oct 2024 10:18:11 +0800 Subject: [PATCH 5/8] noedit --- .../componentversion-redis-sentinel.yaml | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml index 22c3d6a87..579fb40e6 100644 --- a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml +++ b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml @@ -1,50 +1,35 @@ apiVersion: apps.kubeblocks.io/v1alpha1 kind: ComponentDefinition metadata: - name: pika-exporter + name: redis-sentinel namespace: {{ .Release.Namespace }} labels: {{- include "pika.labels" . | nindent 4 }} spec: - provider: pika - description: A pika exporter component definition - serviceKind: redis-sentinel - serviceVersion: {{ .Chart.AppVersion }} - services: - - name: expoter - spec: - ports: - - name: expoter - port: 9121 - targetPort: expoter + clusterSize: 3 + podSecurityContext: + runAsUser: 1000 + fsGroup: 1000 + redisSentinelConfig: + redisReplicationName: redis-replication + kubernetesConfig: + image: 'quay.io/opstree/redis-sentinel:v7.0.7' + imagePullPolicy: IfNotPresent + resources: + requests: + cpu: 101m + memory: 128Mi + limits: + cpu: 101m + memory: 128Mi updateStrategy: Serial configs: - name: pika-config templateRef: pika-conf-template namespace: {{ .Release.Namespace }} volumeName: config - vars: - ## reference to the pika-codis-dashboard service - - name: DASHBOARD_ADDR - valueFrom: - serviceVarRef: - compDef: pika-codis-dashboard - name: dashboard - optional: true - host: Optional - runtime: - initContainers: - - name: wait-codis-dashboard - env: - - name: DASHBOARD_ADDR - value: "$(KB_CLUSTER_NAME)-codis-dashboard" - image: busybox:1.28 - command: - - 'sh' - - '-c' - - "until nc -z ${DASHBOARD_ADDR} 18080; do echo waiting for codis dashboard; sleep 2; done;" - containers: - - name: pika-exporter + containers: + - name: redis-sentinel image: {{ include "pikaExporter.image" . }} imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} ports: From 66b0374e6457b334fa220f99bdc8a05b164b1f39 Mon Sep 17 00:00:00 2001 From: chejinge Date: Fri, 18 Oct 2024 10:58:29 +0800 Subject: [PATCH 6/8] noedit --- ...=> componentdefinition-pika-exporter.yaml} | 0 .../componentdefinition-redis-sentinel.yaml | 50 +++++++++++++++++++ .../componentversion-pika-expoter.yaml | 18 +++++++ .../componentversion-redis-sentinel.yaml | 35 ++----------- 4 files changed, 71 insertions(+), 32 deletions(-) rename tools/kubeblocks_helm/pika-master-slave/templates/{componentversion-pika-expter.yaml => componentdefinition-pika-exporter.yaml} (100%) create mode 100644 tools/kubeblocks_helm/pika-master-slave/templates/componentdefinition-redis-sentinel.yaml create mode 100644 tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expoter.yaml diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expter.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentdefinition-pika-exporter.yaml similarity index 100% rename from tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expter.yaml rename to tools/kubeblocks_helm/pika-master-slave/templates/componentdefinition-pika-exporter.yaml diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentdefinition-redis-sentinel.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentdefinition-redis-sentinel.yaml new file mode 100644 index 000000000..60c633047 --- /dev/null +++ b/tools/kubeblocks_helm/pika-master-slave/templates/componentdefinition-redis-sentinel.yaml @@ -0,0 +1,50 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ComponentDefinition +metadata: + name: redis-sentinel + namespace: {{ .Release.Namespace }} + labels: + {{- include "pika.labels" . | nindent 4 }} +spec: + clusterSize: 3 + podSecurityContext: + runAsUser: 1000 + fsGroup: 1000 + redisSentinelConfig: + redisReplicationName: redis-replication + kubernetesConfig: + image: 'quay.io/opstree/redis-sentinel:v7.0.7' + imagePullPolicy: IfNotPresent + resources: + requests: + cpu: 101m + memory: 128Mi + limits: + cpu: 101m + memory: 128Mi + updateStrategy: Serial + configs: + - name: pika-config + templateRef: pika-conf-template + namespace: {{ .Release.Namespace }} + volumeName: config + containers: + - name: redis-sentinel + image: {{ include "pikaExporter.image" . }} + imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} + ports: + - name: expoter + containerPort: 9121 + volumeMounts: + - name: config + mountPath: /etc/pika + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + command: + - "/pika/bin/pika_exporter" + args: + - "-config" + - "/etc/pika/info.toml" + - "-codis.addr" + - "http://$(DASHBOARD_ADDR):18080/topom" \ No newline at end of file diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expoter.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expoter.yaml new file mode 100644 index 000000000..b06d098d7 --- /dev/null +++ b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-pika-expoter.yaml @@ -0,0 +1,18 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ComponentVersion +metadata: + name: pika-exporter + labels: + {{- include "pika.labels" . | nindent 4 }} +spec: + compatibilityRules: + - compDefs: + - pika-exporter + releases: + - {{ .Chart.AppVersion }} + releases: + - name: {{ .Chart.AppVersion }} + changes: + serviceVersion: {{ .Chart.AppVersion }} + images: + codis-dashboard: {{ include "pikaExporter.image" . }} \ No newline at end of file diff --git a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml index 579fb40e6..d5d003d62 100644 --- a/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml +++ b/tools/kubeblocks_helm/pika-master-slave/templates/componentversion-redis-sentinel.yaml @@ -1,10 +1,7 @@ -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ComponentDefinition +apiVersion: redis.redis.opstreelabs.in/v1beta1 +kind: RedisSentinel metadata: name: redis-sentinel - namespace: {{ .Release.Namespace }} - labels: - {{- include "pika.labels" . | nindent 4 }} spec: clusterSize: 3 podSecurityContext: @@ -21,30 +18,4 @@ spec: memory: 128Mi limits: cpu: 101m - memory: 128Mi - updateStrategy: Serial - configs: - - name: pika-config - templateRef: pika-conf-template - namespace: {{ .Release.Namespace }} - volumeName: config - containers: - - name: redis-sentinel - image: {{ include "pikaExporter.image" . }} - imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} - ports: - - name: expoter - containerPort: 9121 - volumeMounts: - - name: config - mountPath: /etc/pika - env: - - name: DASHBOARD_ADDR - value: "$(KB_CLUSTER_NAME)-codis-dashboard" - command: - - "/pika/bin/pika_exporter" - args: - - "-config" - - "/etc/pika/info.toml" - - "-codis.addr" - - "http://$(DASHBOARD_ADDR):18080/topom" \ No newline at end of file + memory: 128Mi \ No newline at end of file From 7118cea206f81010ebd7def015d22bbb090582d8 Mon Sep 17 00:00:00 2001 From: chejinge Date: Fri, 18 Oct 2024 11:09:00 +0800 Subject: [PATCH 7/8] noedit --- .../pika-master-slave/config/exporter-info.tpl | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tools/kubeblocks_helm/pika-master-slave/config/exporter-info.tpl diff --git a/tools/kubeblocks_helm/pika-master-slave/config/exporter-info.tpl b/tools/kubeblocks_helm/pika-master-slave/config/exporter-info.tpl new file mode 100644 index 000000000..5597752f9 --- /dev/null +++ b/tools/kubeblocks_helm/pika-master-slave/config/exporter-info.tpl @@ -0,0 +1,12 @@ +server = true +data = true +clients = true +stats = true +cpu = true +replication = true +keyspace = true +cache = true + +execcount = false +commandstats = false +rocksdb = false From 0550199d8307ccc7c50ea73e4dcf51c3f7f56279 Mon Sep 17 00:00:00 2001 From: chejinge Date: Fri, 18 Oct 2024 15:08:08 +0800 Subject: [PATCH 8/8] noedit --- .../grafana/configmap-dashboards.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tools/kubeblocks_helm/pika-cluster/templates/grafana/configmap-dashboards.yaml diff --git a/tools/kubeblocks_helm/pika-cluster/templates/grafana/configmap-dashboards.yaml b/tools/kubeblocks_helm/pika-cluster/templates/grafana/configmap-dashboards.yaml new file mode 100644 index 000000000..104062188 --- /dev/null +++ b/tools/kubeblocks_helm/pika-cluster/templates/grafana/configmap-dashboards.yaml @@ -0,0 +1,19 @@ +{{- $files := .Files.Glob "dashboards/*.json" }} +{{- if $files }} +apiVersion: v1 +kind: ConfigMapList +items: +{{- range $path, $fileContents := $files }} +{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }} +- apiVersion: v1 + kind: ConfigMap + metadata: + name: {{ printf "%s-grafana-%s" (include "pika.name" $) $dashboardName | trunc 63 | trimSuffix "-" }} + labels: + grafana_dashboard: "1" + app: {{ template "pika.name" $ }}-grafana +{{ include "pika.labels" $ | indent 6 }} + data: + {{ $dashboardName }}.json: {{ $.Files.Get $path | toJson }} +{{- end }} +{{- end }} \ No newline at end of file