From 50bd13efbbc7ede8436abf2c6291c8a93ce16d7c Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 11:21:15 +0600 Subject: [PATCH 01/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 163 ++++++++++++++++++++++++++++++++ hack/scripts/check-dashboard.sh | 9 ++ 2 files changed, 172 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 hack/scripts/check-dashboard.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..57e874a6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,163 @@ +name: dashboard-check +on: + issue_comment: + types: [ created ] + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + inputs: + databases: + description: 'Databases' + required: true + default: 'all' + type: string + kubedb-version: + description: 'KubeDB Version' + required: true + default: 'v2024.4.27' #needs to be dynamic + type: string +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-dashboard-check + cancel-in-progress: true +jobs: + config: + name: Configure Inputs + runs-on: ubuntu-latest + outputs: + dbs: ${{ steps.defaulter.outputs.databases }} + kubedb-version : ${{ steps.defaulter.outputs.kubedb-version }} + steps: + - name: Defaulter + id: defaulter + env: + V_DATABASES: ${{ inputs.databases }} + V_KUBEDB_VERSION: ${{ inputs.kubedb-version }} + run: | + echo "databases=${V_DATABASES:-all}" >> $GITHUB_OUTPUT + echo "kubedb-version=${V_KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT + test: + name: Test + runs-on: ubuntu-latest + if: contains(github.event.issue.html_url, '/pull/') && startsWith(github.event.comment.body, '/ok-to-test') + needs: config + strategy: + fail-fast: false + matrix: + k8s: [1.27.3] + kubedb-version: ${{ fromJSON(needs.config.outputs.kubedb-version) }} + steps: + - name: Set up Go 1.22 + uses: actions/setup-go@v1 + with: + go-version: '1.22' + id: go + + - name: Install Homebrew + run: | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + - uses: Homebrew/actions/setup-homebrew@master + + - name: Prepare host + run: | + brew instal gh kubectl helm kind + + - name: Prepare git + env: + GITHUB_USER: 1gtm + GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }} + run: | + set -x + git config --global user.name "1gtm" + git config --global user.email "1gtm@appscode.com" + git config --global \ + url."https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com".insteadOf \ + "https://github.com" + + - name: Create Kubernetes ${{ matrix.k8s }} cluster + id: kind + uses: engineerd/setup-kind@v0.5.0 + with: + version: v0.20.0 + config: hack/kubernetes/kind.yaml + image: kindest/node:${{ matrix.k8s }} + + - name: Prepare cluster for testing + id: local-path + run: | + echo "waiting for nodes to be ready ..." + kubectl wait --for=condition=Ready nodes --all --timeout=5m + kubectl get nodes + kubectl wait --for=condition=Ready pods -n kube-system --all --timeout=10m + kubectl get pods -n kube-system + + - name: Install cert-manager + run: | + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml + + - name: Issue License + env: + BYTEBUILDERS_LICENSE_TOKEN: ${{ secrets.BYTEBUILDERS_LICENSE_TOKEN }} + run: | + export KUBECONFIG="${HOME}/.kube/config" + CLUSTER_UID=$(kubectl get ns kube-system -o=jsonpath='{.metadata.uid}') + curl -X POST -o /tmp/license.txt -d "name=1gtm&email=1gtm@appscode.com&product=kubedb-enterprise&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license + + - name: Install KubeDB + env: + LICENSE_FILE: /tmp/license.txt + run: | + helm install kubedb oci://ghcr.io/appscode-charts/kubedb \ + --version ${{ matrix.kubedb-version }} \ + --namespace kubedb --create-namespace \ + --set-file global.license=${LICENSE_FILE} \ + --set global.featureGates.Druid=true + --set global.featureGates.FerretDB=true + --set global.featureGates.Memcached=true + --set global.featureGates.MSSQLServer=true + --set global.featureGates.PerconaXtraDB=true + --set global.featureGates.PgBouncer=true + --set global.featureGates.Pgpool=true + --set global.featureGates.ProxySQL=true + --set global.featureGates.RabbitMQ=true + --set global.featureGates.Singlestore=true + --set global.featureGates.Solr=true + --set global.featureGates.ZooKeeper=true + --wait --burst-limit=10000 --debug + + - name: Install KubeDB CLI + run: | + cd .. + git clone git@github.com:kubedb/cli.git + cd cli + git checkout master + go get ./... + + - name: Install Prometheus + run: | + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + helm repo update + helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring + + - name: Install Panopticon + run: | + helm repo add appscode https://charts.appscode.com/stable/ + helm repo update + helm upgrade -i panopticon appscode/panopticon -n kubeops --create-namespace --version=v2024.2.5 + + - name: Apply MetricsConfigurations + run: | + helm repo add appscode https://charts.appscode.com/stable/ + helm repo update + helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ matrix.kubedb-version }} + + - name: Install Falco UI Server + run: | + helm repo add appscode https://charts.appscode.com/stable/ + helm repo update + helm upgrade -i falco-ui-server appscode/falco-ui-server -n kubeops --create-namespace --version=v2024.2.5 + + - name: Check Dashboard Metrics + run: | + DB=${{ fromJSON(needs.config.outputs.databases) }} + bash hack/scripts/check-dashboard.sh "$DB" \ No newline at end of file diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh new file mode 100644 index 00000000..c9cdc742 --- /dev/null +++ b/hack/scripts/check-dashboard.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -eou pipefail +DB=$1 +allDbs=("MongoDB" "ConnectCluster" "Druid" "Elasticsearch" "Kafka" ) +if [ $(DB)=="all" ]; then + kubectl apply -f https://raw.githubusercontent.com/kubedb/samples/old-dbs/mongodb/shard/mongodb.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready MongoDB mongodb -n demo --timeout=10m + kubectl-dba monitor dashboard mongodb mongodb-summary-dashboard --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 +fi \ No newline at end of file From 212003cb5ec4e0df84370ac2c9ff2a11befece1b Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 11:49:29 +0600 Subject: [PATCH 02/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57e874a6..5b35c737 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: dashboard-check on: + push: + branches: + - "*.*" issue_comment: types: [ created ] schedule: From 6ebb7b69c428865666b6eaca55cfc14a168e06f3 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 11:57:13 +0600 Subject: [PATCH 03/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b35c737..e6596cfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,11 @@ on: push: branches: - "*.*" + pull_request: + branches: + - "master" + paths: + - ".github/workflows/ci.yml" issue_comment: types: [ created ] schedule: From 50f74d7e65769abe07dfb5a815e7e56c5528fb22 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 11:58:52 +0600 Subject: [PATCH 04/16] wip --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6596cfa..8356938e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,6 @@ jobs: test: name: Test runs-on: ubuntu-latest - if: contains(github.event.issue.html_url, '/pull/') && startsWith(github.event.comment.body, '/ok-to-test') needs: config strategy: fail-fast: false From c49cbda3551bed4bacd9e67d929eec348b313ade Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 12:00:04 +0600 Subject: [PATCH 05/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8356938e..b7a73d04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,6 @@ on: - "master" paths: - ".github/workflows/ci.yml" - issue_comment: - types: [ created ] schedule: - cron: '0 0 * * *' workflow_dispatch: From c51d1a86de6def594e96c2573c4a8015d6a1b4ef Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 12:12:24 +0600 Subject: [PATCH 06/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++---------- hack/kubernetes/kind.yaml | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 hack/kubernetes/kind.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7a73d04..68140099 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,8 @@ on: pull_request: branches: - "master" - paths: - - ".github/workflows/ci.yml" +# paths: +# - ".github/workflows/ci.yml" schedule: - cron: '0 0 * * *' workflow_dispatch: @@ -31,25 +31,38 @@ jobs: runs-on: ubuntu-latest outputs: dbs: ${{ steps.defaulter.outputs.databases }} - kubedb-version : ${{ steps.defaulter.outputs.kubedb-version }} + kubedb : ${{ steps.defaulter.outputs.kubedb }} steps: - name: Defaulter id: defaulter env: - V_DATABASES: ${{ inputs.databases }} - V_KUBEDB_VERSION: ${{ inputs.kubedb-version }} +# V_DATABASES: ${{ inputs.databases }} +# V_KUBEDB_VERSION: ${{ inputs.kubedb-version }} + V_DATABASES: "all" + V_KUBEDB_VERSION: "v2024.4.27" run: | echo "databases=${V_DATABASES:-all}" >> $GITHUB_OUTPUT - echo "kubedb-version=${V_KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT + echo "kubedb=${V_KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT test: name: Test runs-on: ubuntu-latest +# needs: config +# strategy: +# fail-fast: false +# matrix: +# k8s: [ 1.27.3 ] +# kubedb: ${{ needs.config.outputs.kubedb }} +# steps: +# - name: test +# run: | +# echo "hh" +# echo "${{ needs.config.outputs.kubedb }}" needs: config strategy: fail-fast: false matrix: k8s: [1.27.3] - kubedb-version: ${{ fromJSON(needs.config.outputs.kubedb-version) }} +# kubedb-version: ${{ fromJSON(needs.config.outputs.kubedb-version) }} steps: - name: Set up Go 1.22 uses: actions/setup-go@v1 @@ -106,14 +119,14 @@ jobs: run: | export KUBECONFIG="${HOME}/.kube/config" CLUSTER_UID=$(kubectl get ns kube-system -o=jsonpath='{.metadata.uid}') - curl -X POST -o /tmp/license.txt -d "name=1gtm&email=1gtm@appscode.com&product=kubedb-enterprise&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license + curl -X POST -o /tmp/license.txt -d "name=1gtm&email=1gtm@appscode.com&product=kubedb-enterprise&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license - name: Install KubeDB env: LICENSE_FILE: /tmp/license.txt run: | helm install kubedb oci://ghcr.io/appscode-charts/kubedb \ - --version ${{ matrix.kubedb-version }} \ + --version ${{ needs.config.outputs.kubedb }} \ --namespace kubedb --create-namespace \ --set-file global.license=${LICENSE_FILE} \ --set global.featureGates.Druid=true @@ -154,7 +167,7 @@ jobs: run: | helm repo add appscode https://charts.appscode.com/stable/ helm repo update - helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ matrix.kubedb-version }} + helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} - name: Install Falco UI Server run: | diff --git a/hack/kubernetes/kind.yaml b/hack/kubernetes/kind.yaml new file mode 100644 index 00000000..8490d6a1 --- /dev/null +++ b/hack/kubernetes/kind.yaml @@ -0,0 +1,15 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + kubeadmConfigPatches: + - | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: ClusterConfiguration + metadata: + name: config + apiServer: + extraArgs: + enable-admission-plugins: "NodeRestriction,OwnerReferencesPermissionEnforcement" + - role: worker + - role: worker \ No newline at end of file From 8c3bfacea461c4bd020fd11a14e0a9b60e616211 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 13:00:46 +0600 Subject: [PATCH 07/16] Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68140099..4a1a9911 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,11 +61,20 @@ jobs: strategy: fail-fast: false matrix: - k8s: [1.27.3] + k8s: [v1.27.3] # kubedb-version: ${{ fromJSON(needs.config.outputs.kubedb-version) }} steps: + - uses: actions/checkout@v4 + with: + ref: ci + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + with: + detached: true + - name: Set up Go 1.22 - uses: actions/setup-go@v1 + uses: actions/setup-go@v4 with: go-version: '1.22' id: go @@ -129,24 +138,24 @@ jobs: --version ${{ needs.config.outputs.kubedb }} \ --namespace kubedb --create-namespace \ --set-file global.license=${LICENSE_FILE} \ - --set global.featureGates.Druid=true - --set global.featureGates.FerretDB=true - --set global.featureGates.Memcached=true - --set global.featureGates.MSSQLServer=true - --set global.featureGates.PerconaXtraDB=true - --set global.featureGates.PgBouncer=true - --set global.featureGates.Pgpool=true - --set global.featureGates.ProxySQL=true - --set global.featureGates.RabbitMQ=true - --set global.featureGates.Singlestore=true - --set global.featureGates.Solr=true - --set global.featureGates.ZooKeeper=true + --set global.featureGates.Druid=true \ + --set global.featureGates.FerretDB=true \ + --set global.featureGates.Memcached=true \ + --set global.featureGates.MSSQLServer=true \ + --set global.featureGates.PerconaXtraDB=true \ + --set global.featureGates.PgBouncer=true \ + --set global.featureGates.Pgpool=true \ + --set global.featureGates.ProxySQL=true \ + --set global.featureGates.RabbitMQ=true \ + --set global.featureGates.Singlestore=true \ + --set global.featureGates.Solr=true \ + --set global.featureGates.ZooKeeper=true \ --wait --burst-limit=10000 --debug - name: Install KubeDB CLI run: | cd .. - git clone git@github.com:kubedb/cli.git + git clone https://github.com/kubedb/cli.git cd cli git checkout master go get ./... From 343c3ea0f3b8e196fb9bac1c5fda923b66d58949 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Tue, 14 May 2024 16:42:22 +0600 Subject: [PATCH 08/16] Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 28 ++++++++++++++++------------ hack/scripts/check-dashboard.sh | 7 ++++--- hack/scripts/test.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 hack/scripts/test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a1a9911..6b852f23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,37 +154,41 @@ jobs: - name: Install KubeDB CLI run: | - cd .. - git clone https://github.com/kubedb/cli.git - cd cli - git checkout master - go get ./... + curl -o kubectl-dba.tar.gz -fsSL https://github.com/kubedb/cli/releases/download/v0.45.0/kubectl-dba-linux-amd64.tar.gz \ + && tar zxvf kubectl-dba.tar.gz \ + && chmod +x kubectl-dba-linux-amd64 \ + && sudo mv kubectl-dba-linux-amd64 /usr/local/bin/kubectl-dba \ + && rm kubectl-dba.tar.gz LICENSE.md - name: Install Prometheus run: | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update - helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring + helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring --create-namespace - name: Install Panopticon run: | helm repo add appscode https://charts.appscode.com/stable/ helm repo update - helm upgrade -i panopticon appscode/panopticon -n kubeops --create-namespace --version=v2024.2.5 + helm install panopticon appscode/panopticon \ + -n kubeops --create-namespace \ + --set monitoring.agent=prometheus.io/operator \ + --set monitoring.serviceMonitor.labels.release=prometheus \ + --set-file license=/tmp/license.txt - - name: Apply MetricsConfigurations + - name: Install Falco UI Server run: | helm repo add appscode https://charts.appscode.com/stable/ helm repo update - helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} + helm upgrade -i falco-ui-server appscode/falco-ui-server -n kubeops --create-namespace --version=v2024.2.5 - - name: Install Falco UI Server + - name: Apply MetricsConfigurations run: | helm repo add appscode https://charts.appscode.com/stable/ helm repo update - helm upgrade -i falco-ui-server appscode/falco-ui-server -n kubeops --create-namespace --version=v2024.2.5 + helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} - name: Check Dashboard Metrics run: | - DB=${{ fromJSON(needs.config.outputs.databases) }} + DB=${{ needs.config.outputs.databases }} bash hack/scripts/check-dashboard.sh "$DB" \ No newline at end of file diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index c9cdc742..a915765d 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -1,9 +1,10 @@ #!/bin/bash -set -eou pipefail +#set -eou pipefail DB=$1 -allDbs=("MongoDB" "ConnectCluster" "Druid" "Elasticsearch" "Kafka" ) +allDbs=("ConnectCluster" "Druid" "Elasticsearch" "Kafka" "MariaDB" "MongoDB" "MySQL" "PerconaXtraDB" "Pgpool" "Postgres" "ProxySQL" "RabbitMQ" "Redis" "Singlestore" "Solr" "ZooKeeper") +kubectl create ns demo if [ $(DB)=="all" ]; then kubectl apply -f https://raw.githubusercontent.com/kubedb/samples/old-dbs/mongodb/shard/mongodb.yaml kubectl wait --for=jsonpath='{.status.phase}'=Ready MongoDB mongodb -n demo --timeout=10m - kubectl-dba monitor dashboard mongodb mongodb-summary-dashboard --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + kubectl-dba monitor dashboard mongodb mongodb -n demo mongodb-summary-dashboard --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 fi \ No newline at end of file diff --git a/hack/scripts/test.sh b/hack/scripts/test.sh new file mode 100644 index 00000000..92dff39b --- /dev/null +++ b/hack/scripts/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elasticsearch"]="Elasticsearch" ["kafka"]="Kafka" ["mariadb"]="MariaDB" + ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" + ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper") + +cd ../../ + +folders=$(ls) + +# Convert the string variable into an array +IFS=$'\n' read -r -d '' -a folder_array <<< "$folders" + +for folder in "${folder_array[@]}"; do + if [[ -v kind["$folder"] ]]; then + kubectl apply -f + echo "db name: $folder" + inside_files=$(ls "$folder") + IFS=$'\n' read -r -d '' -a inside_files_array <<< "$inside_files" + for file in "${inside_files_array[@]}"; do + if [[ $file == *.json ]]; then + echo "$file" + fi + done + fi +done \ No newline at end of file From f680ed60cdef67d93b249d171fe5f5ee712da367 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Wed, 15 May 2024 14:12:46 +0600 Subject: [PATCH 09/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 70 +++++------ hack/scripts/check-dashboard.sh | 130 +++++++++++++++++++-- hack/scripts/policy-flow.sh | 11 ++ hack/scripts/stash-flow.sh | 66 +++++++++++ hack/scripts/test.sh | 55 ++++++--- hack/yamls/policy/constraint-template.yaml | 58 +++++++++ hack/yamls/policy/constraint.yaml | 13 +++ hack/yamls/stash/backupconfiguration.yaml | 18 +++ hack/yamls/stash/repository.yaml | 16 +++ hack/yamls/stash/restoresession.yaml | 15 +++ 10 files changed, 390 insertions(+), 62 deletions(-) create mode 100644 hack/scripts/policy-flow.sh create mode 100644 hack/scripts/stash-flow.sh create mode 100644 hack/yamls/policy/constraint-template.yaml create mode 100644 hack/yamls/policy/constraint.yaml create mode 100644 hack/yamls/stash/backupconfiguration.yaml create mode 100644 hack/yamls/stash/repository.yaml create mode 100644 hack/yamls/stash/restoresession.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b852f23..d264f53c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,6 @@ on: pull_request: branches: - "master" -# paths: -# - ".github/workflows/ci.yml" schedule: - cron: '0 0 * * *' workflow_dispatch: @@ -36,33 +34,19 @@ jobs: - name: Defaulter id: defaulter env: -# V_DATABASES: ${{ inputs.databases }} -# V_KUBEDB_VERSION: ${{ inputs.kubedb-version }} - V_DATABASES: "all" - V_KUBEDB_VERSION: "v2024.4.27" + DATABASES: "policy" + KUBEDB_VERSION: "v2024.4.27" run: | - echo "databases=${V_DATABASES:-all}" >> $GITHUB_OUTPUT - echo "kubedb=${V_KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT + echo "databases=${DATABASES:-all}" >> $GITHUB_OUTPUT + echo "kubedb=${KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT test: name: Test runs-on: ubuntu-latest -# needs: config -# strategy: -# fail-fast: false -# matrix: -# k8s: [ 1.27.3 ] -# kubedb: ${{ needs.config.outputs.kubedb }} -# steps: -# - name: test -# run: | -# echo "hh" -# echo "${{ needs.config.outputs.kubedb }}" needs: config strategy: fail-fast: false matrix: k8s: [v1.27.3] -# kubedb-version: ${{ fromJSON(needs.config.outputs.kubedb-version) }} steps: - uses: actions/checkout@v4 with: @@ -154,17 +138,17 @@ jobs: - name: Install KubeDB CLI run: | - curl -o kubectl-dba.tar.gz -fsSL https://github.com/kubedb/cli/releases/download/v0.45.0/kubectl-dba-linux-amd64.tar.gz \ - && tar zxvf kubectl-dba.tar.gz \ - && chmod +x kubectl-dba-linux-amd64 \ - && sudo mv kubectl-dba-linux-amd64 /usr/local/bin/kubectl-dba \ - && rm kubectl-dba.tar.gz LICENSE.md + cd .. + git clone https://github.com/kubedb/cli.git + cd cli + git checkout check + go install ./... - name: Install Prometheus run: | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update - helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring --create-namespace + helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring --create-namespace --wait --burst-limit=10000 - name: Install Panopticon run: | @@ -174,21 +158,37 @@ jobs: -n kubeops --create-namespace \ --set monitoring.agent=prometheus.io/operator \ --set monitoring.serviceMonitor.labels.release=prometheus \ - --set-file license=/tmp/license.txt + --set-file license=/tmp/license.txt \ + --wait --burst-limit=10000 + sleep 5s + kubectl wait --for=condition=ready pod -l "app.kubernetes.io/name=panopticon,app.kubernetes.io/instance=panopticon" -n kubeops --timeout=10m - - name: Install Falco UI Server - run: | - helm repo add appscode https://charts.appscode.com/stable/ - helm repo update - helm upgrade -i falco-ui-server appscode/falco-ui-server -n kubeops --create-namespace --version=v2024.2.5 +# - name: Install Falco UI Server +# run: | +# helm repo add appscode https://charts.appscode.com/stable/ +# helm repo update +# helm upgrade -i falco-ui-server appscode/falco-ui-server -n kubeops --create-namespace --version=v2024.2.5 - name: Apply MetricsConfigurations run: | helm repo add appscode https://charts.appscode.com/stable/ helm repo update - helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} + helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} --wait --burst-limit=10000 --debug + + - name: Prepare smaples + run: | + cd .. + git clone https://github.com/kubedb/samples.git + cd samples + git checkout old-dbs - name: Check Dashboard Metrics + env: + SINGLESTORE_LICENSE_USERNAME: ${{ secrets.SINGLESTORE_LICENSE_USERNAME }} + SINGLESTORE_LICENSE_PASSWORD: ${{ secrets.SINGLESTORE_LICENSE_PASSWORD }} + DATABASES: ${{ needs.config.outputs.dbs }} run: | - DB=${{ needs.config.outputs.databases }} - bash hack/scripts/check-dashboard.sh "$DB" \ No newline at end of file + echo "SINGLESTORE_LICENSE_USERNAME=$(echo $SINGLESTORE_LICENSE_USERNAME)" >> ./hack/scripts/.env + echo "SINGLESTORE_LICENSE_PASSWORD=$(echo $SINGLESTORE_LICENSE_PASSWORD)" >> ./hack/scripts/.env + echo "DATABASES=$(echo $DATABASES)" >> ./hack/scripts/.env + bash hack/scripts/check-dashboard.sh \ No newline at end of file diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index a915765d..7f4396a7 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -1,10 +1,124 @@ #!/bin/bash -#set -eou pipefail -DB=$1 -allDbs=("ConnectCluster" "Druid" "Elasticsearch" "Kafka" "MariaDB" "MongoDB" "MySQL" "PerconaXtraDB" "Pgpool" "Postgres" "ProxySQL" "RabbitMQ" "Redis" "Singlestore" "Solr" "ZooKeeper") +set -e + +declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elasticsearch"]="Elasticsearch" ["kafka"]="Kafka" ["mariadb"]="MariaDB" + ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" + ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper") + +if [ -f .env ]; then + export $(grep -v '^#' .env | xargs) +fi + kubectl create ns demo -if [ $(DB)=="all" ]; then - kubectl apply -f https://raw.githubusercontent.com/kubedb/samples/old-dbs/mongodb/shard/mongodb.yaml - kubectl wait --for=jsonpath='{.status.phase}'=Ready MongoDB mongodb -n demo --timeout=10m - kubectl-dba monitor dashboard mongodb mongodb -n demo mongodb-summary-dashboard --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 -fi \ No newline at end of file + +readarray -t folder_array < <(ls) +IFS=',' read -r -a user_array <<< "$DATABASES" +if [ $DATABASES != "all" ]; then + folder_array=("${user_array[@]}") +fi + +for folder in "${folder_array[@]}"; do + if [[ -v kind["$folder"] ]]; then + echo "db name: $folder" + + readarray -t inside_files_array < <(ls "$folder") + + path=../samples/"$folder"/monitoring/ + + if [ "$folder" == "connectcluster" ]; then + path=../samples/kafka/connectcluster/monitoring/ + fi + + if [ "$folder" == "pgpool" ]; then + kubectl apply -f ../samples/pgpool/monitoring/conf.yaml + kubectl apply -f ../samples/pgpool/monitoring/postgres.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready Postgres postgres -n demo --timeout=10m + fi + + if [ "$folder" == "druid" ]; then + kubectl create configmap -n demo my-init-script \ + --from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/samples/old-dbs/druid/monitoring/mysql-init-script.sql)" + + helm repo add minio https://operator.min.io/ + helm upgrade --install --namespace "minio-operator" --create-namespace "minio-operator" minio/operator --set operator.replicaCount=1 --wait + helm upgrade --install --namespace "demo" --create-namespace druid-minio minio/tenant \ + --set tenant.pools[0].servers=1 \ + --set tenant.pools[0].volumesPerServer=1 \ + --set tenant.pools[0].size=1Gi \ + --set tenant.certificate.requestAutoCert=false \ + --set tenant.pools[0].name="default" \ + --set tenant.buckets[0].name="druid" \ + --wait + + kubectl apply -f ../samples/druid/monitoring/mysql.yaml + kubectl apply -f ../samples/druid/monitoring/zookeeper.yaml + + kubectl wait --for=jsonpath='{.status.phase}'=Ready MySQL mysql -n demo --timeout=10m + kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m + fi + + if [ "$folder" == "solr" ]; then + kubectl apply -f ../samples/solr/monitoring/zookeeper.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m + fi + + if [ "$folder" == "singlestore" ]; then + kubectl create secret generic -n demo license-secret \ + --from-literal=username=$SINGLESTORE_LICENSE_USERNAME \ + --from-literal=password=$SINGLESTORE_LICENSE_PASSWORD + fi + + kubectl apply -f $path + kubectl wait --for=jsonpath='{.status.phase}'=Ready ${kind[$folder]} $folder -n demo --timeout=10m + + sleep 120s + for file in "${inside_files_array[@]}"; do + if [[ $file == *.json ]]; then + dashboard_name="${file::-5}" + echo "checking for dashboard $dashboard_name" + $HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + fi + done + + kubectl delete -f $path + elif [ "$folder" == "stash" ]; then + echo "non db object name: $folder" + readarray -t inside_files_array < <(ls "$folder") + + bash ./hack/scripts/stash-flow.sh + + sleep 120s + for file in "${inside_files_array[@]}"; do + if [[ $file == *.json ]]; then + dashboard_name="${file::-5}" + echo "checking for dashboard $dashboard_name" + url="https://raw.githubusercontent.com/appscode/grafana-dashboards/ci/stash/$file" + $HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + fi + done + + kubectl delete -f ./hack/yamls/backupconfiguration.yaml + kubectl delete -f ./hack/yamls/restoresession.yaml + kubectl delete -f ./hack/yamls/repository.yaml + kubectl delete -f ../samples/mongodb/monitoring/mongodb_standalone.yaml + + elif [ "$folder" == "policy" ]; then + echo "non db object name: $folder" + readarray -t inside_files_array < <(ls "$folder") + + bash ./hack/scripts/policy-flow.sh + + sleep 120s + for file in "${inside_files_array[@]}"; do + if [[ $file == *.json ]]; then + dashboard_name="${file::-5}" + echo "checking for dashboard $dashboard_name" + url="https://raw.githubusercontent.com/appscode/grafana-dashboards/ci/policy/$file" + $HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + fi + done + + kubectl delete -f ./hack/yamls/policy/constraint-template.yaml + kubectl delete -f ./hack/yamls/policy/constraint.yaml + fi +done \ No newline at end of file diff --git a/hack/scripts/policy-flow.sh b/hack/scripts/policy-flow.sh new file mode 100644 index 00000000..c35cf605 --- /dev/null +++ b/hack/scripts/policy-flow.sh @@ -0,0 +1,11 @@ +set -e + +helm repo add gatekeeper https://open-policy-agent.github.io/gatekeeper/charts +helm install gatekeeper/gatekeeper --name-template=gatekeeper --namespace gatekeeper-system --create-namespace --set replicas=1 --set constraintViolationsLimit=100 --wait + +helm upgrade -i kube-ui-server appscode/kube-ui-server -n kubeops --create-namespace --version=v2024.5.17 --wait + +kubectl apply -f ./hack/yamls/policy/constraint-template.yaml +sleep 5 +kubectl apply -f ./hack/yamls/policy/constraint.yaml + diff --git a/hack/scripts/stash-flow.sh b/hack/scripts/stash-flow.sh new file mode 100644 index 00000000..0c92c1d4 --- /dev/null +++ b/hack/scripts/stash-flow.sh @@ -0,0 +1,66 @@ +set -e + +helm repo add minio https://operator.min.io/ +helm upgrade --install --namespace "minio-operator" --create-namespace "stash-minio-operator" minio/operator --set operator.replicaCount=1 --wait +helm upgrade --install --namespace "demo" --create-namespace stash-minio minio/tenant \ + --set tenant.pools[0].servers=1 \ + --set tenant.pools[0].volumesPerServer=1 \ + --set tenant.pools[0].size=1Gi \ + --set tenant.certificate.requestAutoCert=false \ + --set tenant.pools[0].name="default" \ + --set tenant.buckets[0].name="stash" \ + --wait + +echo -n 'changeit' > RESTIC_PASSWORD +echo -n 'minio' > AWS_ACCESS_KEY_ID +echo -n 'minio123' > AWS_SECRET_ACCESS_KEY +kubectl create secret generic -n demo minio-secret \ + --from-file=./RESTIC_PASSWORD \ + --from-file=./AWS_ACCESS_KEY_ID \ + --from-file=./AWS_SECRET_ACCESS_KEY + +helm install stash oci://ghcr.io/appscode-charts/stash \ + --version v2024.4.8 \ + --namespace stash --create-namespace \ + --set features.enterprise=true \ + --set stash-enterprise.monitoring.agent=prometheus.io/operator \ + --set stash-enterprise.monitoring.backup=true \ + --set stash-enterprise.monitoring.operator=true \ + --set stash-enterprise.monitoring.serviceMonitor.labels.release=prometheus \ + --set-file global.license=/tmp/license.txt \ + --wait --burst-limit=10000 + +curl -o kubectl-stash.tar.gz -fsSL https://github.com/stashed/cli/releases/download/v0.34.0/kubectl-stash-linux-amd64.tar.gz \ + && tar zxvf kubectl-stash.tar.gz \ + && chmod +x kubectl-stash-linux-amd64 \ + && sudo mv kubectl-stash-linux-amd64 /usr/local/bin/kubectl-stash \ + && rm kubectl-stash.tar.gz LICENSE.md + +kubectl apply -f ./hack/yamls/stash/repository.yaml +sleep 10 + +kubectl apply -f ../samples/mongodb/monitoring/mongodb_standalone.yaml +kubectl wait --for=jsonpath='{.status.phase}'=Ready MongoDB mongodb-standalone -n demo --timeout=10m + +kubectl apply -f ./hack/yamls/stash/backupconfiguration.yaml +kubectl wait --for=jsonpath='{.status.phase}'=Ready BackupConfiguration mg-st-backup -n demo --timeout=10m + +kubectl-stash trigger mg-st-backup -n demo + +retries=0 +while true; do + backupsession_count=$(kubectl get backupsession -n demo -l "stash.appscode.com/invoker-name=mg-st-backup" | wc -l) + if [ $backupsession_count -ge 0 ]; then + break + elif [ $retries -ge 5 ]; then + echo "backupsession not creating for backupconfiguration 'mg-st-backup'" + exit 1 + fi + retries=$((retries + 1)) + sleep 5 +done + + +sleep 10s +kubectl apply -f ./hack/yamls/stash/restoresession.yaml +kubectl wait --for=jsonpath='{.status.phase}'=Succeeded RestoreSession mg-st-restore -n demo --timeout=10m diff --git a/hack/scripts/test.sh b/hack/scripts/test.sh index 92dff39b..20638bf6 100644 --- a/hack/scripts/test.sh +++ b/hack/scripts/test.sh @@ -1,26 +1,43 @@ #!/bin/bash +set -e + declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elasticsearch"]="Elasticsearch" ["kafka"]="Kafka" ["mariadb"]="MariaDB" ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper") -cd ../../ - -folders=$(ls) - -# Convert the string variable into an array -IFS=$'\n' read -r -d '' -a folder_array <<< "$folders" +#kubectl apply -f safklkasg.yaml +# Capture the output of ls into an array +readarray -t files < <(ls) -for folder in "${folder_array[@]}"; do - if [[ -v kind["$folder"] ]]; then - kubectl apply -f - echo "db name: $folder" - inside_files=$(ls "$folder") - IFS=$'\n' read -r -d '' -a inside_files_array <<< "$inside_files" - for file in "${inside_files_array[@]}"; do - if [[ $file == *.json ]]; then - echo "$file" - fi - done - fi -done \ No newline at end of file +# Displaying elements of the array +for file in "${files[@]}"; do + echo "$file" +done +#cd ../../ +#kubectl create ns demo +# +#folders=$(ls) +##path=/home/sayed/go/src/kubedb.dev/samples/kafka/ +##kubectl apply -f $path +# +## Convert the string variable into an array +#IFS=$'\n' read -r -d '' -a folder_array <<< "$folders" +# +#for folder in "${folder_array[@]}"; do +# if [[ -v kind["$folder"] ]] && [[ "$folder" == "mongodb" ]]; then +# kubectl apply -f +# echo "db name: $folder" +# inside_files=$(ls "$folder") +# path=../samples/"$folder"/monitoring/ +# kubectl apply -f $path +# kubectl wait --for=jsonpath='{.status.phase}'=Ready ${kind[$folder]} $folder -n demo --timeout=10m +# IFS=$'\n' read -r -d '' -a inside_files_array <<< "$inside_files" +# for file in "${inside_files_array[@]}"; do +# if [[ $file == *.json ]]; then +# dashboard_name="${file::-5}" +# kubectl-dba monitor dashboard $folder $folder -n demo dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 +# fi +# done +# fi +#done \ No newline at end of file diff --git a/hack/yamls/policy/constraint-template.yaml b/hack/yamls/policy/constraint-template.yaml new file mode 100644 index 00000000..ad7c1cae --- /dev/null +++ b/hack/yamls/policy/constraint-template.yaml @@ -0,0 +1,58 @@ +apiVersion: templates.gatekeeper.sh/v1 +kind: ConstraintTemplate +metadata: + name: k8sreplicalimits + annotations: + metadata.gatekeeper.sh/title: "Replica Limits" + metadata.gatekeeper.sh/version: 1.0.2 + description: >- + Requires that objects with the field `spec.replicas` (Deployments, + ReplicaSets, etc.) specify a number of replicas within defined ranges. +spec: + crd: + spec: + names: + kind: K8sReplicaLimits + validation: + # Schema for the `parameters` field + openAPIV3Schema: + type: object + properties: + ranges: + type: array + description: Allowed ranges for numbers of replicas. Values are inclusive. + items: + type: object + description: A range of allowed replicas. Values are inclusive. + properties: + min_replicas: + description: The minimum number of replicas allowed, inclusive. + type: integer + max_replicas: + description: The maximum number of replicas allowed, inclusive. + type: integer + targets: + - target: admission.k8s.gatekeeper.sh + rego: | + package k8sreplicalimits + + object_name = input.review.object.metadata.name + object_kind = input.review.kind.kind + + violation[{"msg": msg}] { + spec := input.review.object.spec + not input_replica_limit(spec) + msg := sprintf("The provided number of replicas is not allowed for %v: %v. Allowed ranges: %v", [object_kind, object_name, input.parameters]) + } + + input_replica_limit(spec) { + provided := spec.replicas + count(input.parameters.ranges) > 0 + range := input.parameters.ranges[_] + value_within_range(range, provided) + } + + value_within_range(range, value) { + range.min_replicas <= value + range.max_replicas >= value + } \ No newline at end of file diff --git a/hack/yamls/policy/constraint.yaml b/hack/yamls/policy/constraint.yaml new file mode 100644 index 00000000..82bfec79 --- /dev/null +++ b/hack/yamls/policy/constraint.yaml @@ -0,0 +1,13 @@ +apiVersion: constraints.gatekeeper.sh/v1beta1 +kind: K8sReplicaLimits +metadata: + name: replica-limits +spec: + match: + kinds: + - apiGroups: ["apps"] + kinds: ["Deployment"] + parameters: + ranges: + - min_replicas: 3 + max_replicas: 50 \ No newline at end of file diff --git a/hack/yamls/stash/backupconfiguration.yaml b/hack/yamls/stash/backupconfiguration.yaml new file mode 100644 index 00000000..4453421f --- /dev/null +++ b/hack/yamls/stash/backupconfiguration.yaml @@ -0,0 +1,18 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: BackupConfiguration +metadata: + name: mg-st-backup + namespace: demo +spec: + schedule: "*/50 * * * *" + repository: + name: minio-repo + target: + ref: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + name: mongodb-standalone + retentionPolicy: + name: keep-last-5 + keepLast: 5 + prune: true diff --git a/hack/yamls/stash/repository.yaml b/hack/yamls/stash/repository.yaml new file mode 100644 index 00000000..2e18b938 --- /dev/null +++ b/hack/yamls/stash/repository.yaml @@ -0,0 +1,16 @@ +apiVersion: stash.appscode.com/v1alpha1 +kind: Repository +metadata: + name: minio-repo + namespace: demo +spec: + usagePolicy: + allowedNamespaces: + from: Same + backend: + s3: + endpoint: http://minio.demo.svc.cluster.local:80 + bucket: myminio + region: us-east-1 + prefix: /hhh/sayed/ + storageSecretName: minio-secret \ No newline at end of file diff --git a/hack/yamls/stash/restoresession.yaml b/hack/yamls/stash/restoresession.yaml new file mode 100644 index 00000000..67ced428 --- /dev/null +++ b/hack/yamls/stash/restoresession.yaml @@ -0,0 +1,15 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: RestoreSession +metadata: + name: mg-st-restore + namespace: demo +spec: + repository: + name: minio-repo + target: + ref: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + name: mongodb-standalone + rules: + - snapshots: [latest] \ No newline at end of file From 63585daa945172d901de899856901d8525dacde7 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Wed, 22 May 2024 14:35:23 +0600 Subject: [PATCH 10/16] Add CI Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 46 ++++++++------------------------- hack/scripts/check-dashboard.sh | 4 +-- hack/scripts/test.sh | 43 ------------------------------ 3 files changed, 13 insertions(+), 80 deletions(-) delete mode 100644 hack/scripts/test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d264f53c..da55c03a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,21 +1,15 @@ name: dashboard-check on: - push: - branches: - - "*.*" - pull_request: - branches: - - "master" schedule: - cron: '0 0 * * *' workflow_dispatch: inputs: - databases: - description: 'Databases' + folders: + description: 'Folders' required: true default: 'all' type: string - kubedb-version: + kubedb_version: description: 'KubeDB Version' required: true default: 'v2024.4.27' #needs to be dynamic @@ -28,17 +22,17 @@ jobs: name: Configure Inputs runs-on: ubuntu-latest outputs: - dbs: ${{ steps.defaulter.outputs.databases }} - kubedb : ${{ steps.defaulter.outputs.kubedb }} + folders: ${{ steps.defaulter.outputs.folders }} + kubedb_version : ${{ steps.defaulter.outputs.kubedb_version }} steps: - name: Defaulter id: defaulter env: - DATABASES: "policy" - KUBEDB_VERSION: "v2024.4.27" + FOLDERS: ${{ inputs.folders }} + KUBEDB_VERSION: ${{ inputs.kubedb_version }} run: | - echo "databases=${DATABASES:-all}" >> $GITHUB_OUTPUT - echo "kubedb=${KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT + echo "folders=${FOLDERS:-all}" >> $GITHUB_OUTPUT + echo "kubedb_version=${KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT test: name: Test runs-on: ubuntu-latest @@ -48,15 +42,6 @@ jobs: matrix: k8s: [v1.27.3] steps: - - uses: actions/checkout@v4 - with: - ref: ci - - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - with: - detached: true - - name: Set up Go 1.22 uses: actions/setup-go@v4 with: @@ -141,7 +126,6 @@ jobs: cd .. git clone https://github.com/kubedb/cli.git cd cli - git checkout check go install ./... - name: Install Prometheus @@ -163,12 +147,6 @@ jobs: sleep 5s kubectl wait --for=condition=ready pod -l "app.kubernetes.io/name=panopticon,app.kubernetes.io/instance=panopticon" -n kubeops --timeout=10m -# - name: Install Falco UI Server -# run: | -# helm repo add appscode https://charts.appscode.com/stable/ -# helm repo update -# helm upgrade -i falco-ui-server appscode/falco-ui-server -n kubeops --create-namespace --version=v2024.2.5 - - name: Apply MetricsConfigurations run: | helm repo add appscode https://charts.appscode.com/stable/ @@ -179,16 +157,14 @@ jobs: run: | cd .. git clone https://github.com/kubedb/samples.git - cd samples - git checkout old-dbs - name: Check Dashboard Metrics env: SINGLESTORE_LICENSE_USERNAME: ${{ secrets.SINGLESTORE_LICENSE_USERNAME }} SINGLESTORE_LICENSE_PASSWORD: ${{ secrets.SINGLESTORE_LICENSE_PASSWORD }} - DATABASES: ${{ needs.config.outputs.dbs }} + FOLDERS: ${{ needs.config.outputs.folders }} run: | echo "SINGLESTORE_LICENSE_USERNAME=$(echo $SINGLESTORE_LICENSE_USERNAME)" >> ./hack/scripts/.env echo "SINGLESTORE_LICENSE_PASSWORD=$(echo $SINGLESTORE_LICENSE_PASSWORD)" >> ./hack/scripts/.env - echo "DATABASES=$(echo $DATABASES)" >> ./hack/scripts/.env + echo "FOLDERS=$(echo $FOLDERS)" >> ./hack/scripts/.env bash hack/scripts/check-dashboard.sh \ No newline at end of file diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index 7f4396a7..18e785c6 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -12,8 +12,8 @@ fi kubectl create ns demo readarray -t folder_array < <(ls) -IFS=',' read -r -a user_array <<< "$DATABASES" -if [ $DATABASES != "all" ]; then +IFS=',' read -r -a user_array <<< "$FOLDERS" +if [ $FOLDERS != "all" ]; then folder_array=("${user_array[@]}") fi diff --git a/hack/scripts/test.sh b/hack/scripts/test.sh deleted file mode 100644 index 20638bf6..00000000 --- a/hack/scripts/test.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -e - -declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elasticsearch"]="Elasticsearch" ["kafka"]="Kafka" ["mariadb"]="MariaDB" - ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" - ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper") - -#kubectl apply -f safklkasg.yaml -# Capture the output of ls into an array -readarray -t files < <(ls) - -# Displaying elements of the array -for file in "${files[@]}"; do - echo "$file" -done -#cd ../../ -#kubectl create ns demo -# -#folders=$(ls) -##path=/home/sayed/go/src/kubedb.dev/samples/kafka/ -##kubectl apply -f $path -# -## Convert the string variable into an array -#IFS=$'\n' read -r -d '' -a folder_array <<< "$folders" -# -#for folder in "${folder_array[@]}"; do -# if [[ -v kind["$folder"] ]] && [[ "$folder" == "mongodb" ]]; then -# kubectl apply -f -# echo "db name: $folder" -# inside_files=$(ls "$folder") -# path=../samples/"$folder"/monitoring/ -# kubectl apply -f $path -# kubectl wait --for=jsonpath='{.status.phase}'=Ready ${kind[$folder]} $folder -n demo --timeout=10m -# IFS=$'\n' read -r -d '' -a inside_files_array <<< "$inside_files" -# for file in "${inside_files_array[@]}"; do -# if [[ $file == *.json ]]; then -# dashboard_name="${file::-5}" -# kubectl-dba monitor dashboard $folder $folder -n demo dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 -# fi -# done -# fi -#done \ No newline at end of file From f42646225a76bbe7a10e8cedb297c911e5d22ac0 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Thu, 23 May 2024 14:06:19 +0600 Subject: [PATCH 11/16] Add create_db_dependencies(), check_dashboard_for_non_dbs() Signed-off-by: Arnob kumar saha --- hack/scripts/check-dashboard.sh | 99 ++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index 18e785c6..932fd98e 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -5,36 +5,22 @@ declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elastic ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper") +# export the ENVs from .env file if [ -f .env ]; then export $(grep -v '^#' .env | xargs) fi -kubectl create ns demo - +# folder_array will hold all the folder names that we are going to check readarray -t folder_array < <(ls) IFS=',' read -r -a user_array <<< "$FOLDERS" if [ $FOLDERS != "all" ]; then folder_array=("${user_array[@]}") fi +echo "folder_array = ${folder_array}" -for folder in "${folder_array[@]}"; do - if [[ -v kind["$folder"] ]]; then - echo "db name: $folder" - - readarray -t inside_files_array < <(ls "$folder") - - path=../samples/"$folder"/monitoring/ - - if [ "$folder" == "connectcluster" ]; then - path=../samples/kafka/connectcluster/monitoring/ - fi - - if [ "$folder" == "pgpool" ]; then - kubectl apply -f ../samples/pgpool/monitoring/conf.yaml - kubectl apply -f ../samples/pgpool/monitoring/postgres.yaml - kubectl wait --for=jsonpath='{.status.phase}'=Ready Postgres postgres -n demo --timeout=10m - fi - +create_db_dependencies() { + folder="$1" + echo "folder=$folder" if [ "$folder" == "druid" ]; then kubectl create configmap -n demo my-init-script \ --from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/samples/old-dbs/druid/monitoring/mysql-init-script.sql)" @@ -57,9 +43,10 @@ for folder in "${folder_array[@]}"; do kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m fi - if [ "$folder" == "solr" ]; then - kubectl apply -f ../samples/solr/monitoring/zookeeper.yaml - kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m + if [ "$folder" == "pgpool" ]; then + kubectl apply -f ../samples/pgpool/monitoring/conf.yaml + kubectl apply -f ../samples/pgpool/monitoring/postgres.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready Postgres postgres -n demo --timeout=10m fi if [ "$folder" == "singlestore" ]; then @@ -68,35 +55,68 @@ for folder in "${folder_array[@]}"; do --from-literal=password=$SINGLESTORE_LICENSE_PASSWORD fi - kubectl apply -f $path - kubectl wait --for=jsonpath='{.status.phase}'=Ready ${kind[$folder]} $folder -n demo --timeout=10m + if [ "$folder" == "solr" ]; then + kubectl apply -f ../samples/solr/monitoring/zookeeper.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m + fi +} - sleep 120s +delete_db_dependencies() { + +} + +check_dashboard_for_non_dbs() { + sleep 30s # waiting for the metrics to be generated + folder="$1" + inside_files_array="$2" for file in "${inside_files_array[@]}"; do if [[ $file == *.json ]]; then dashboard_name="${file::-5}" echo "checking for dashboard $dashboard_name" - $HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + url="https://raw.githubusercontent.com/appscode/grafana-dashboards/master/$folder/$file" + $HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 fi done +} + + +kubectl create ns demo + +for folder in "${folder_array[@]}"; do + if [[ -v kind["$folder"] ]]; then + echo "db name: $folder" - kubectl delete -f $path - elif [ "$folder" == "stash" ]; then - echo "non db object name: $folder" readarray -t inside_files_array < <(ls "$folder") - bash ./hack/scripts/stash-flow.sh + path=../samples/"$folder"/monitoring/ - sleep 120s + if [ "$folder" == "connectcluster" ]; then + path=../samples/kafka/connectcluster/monitoring/ + fi + + create_db_dependencies "$folder" + + kubectl apply -f $path + kubectl wait --for=jsonpath='{.status.phase}'=Ready ${kind[$folder]} $folder -n demo --timeout=10m + + sleep 30s for file in "${inside_files_array[@]}"; do if [[ $file == *.json ]]; then dashboard_name="${file::-5}" echo "checking for dashboard $dashboard_name" - url="https://raw.githubusercontent.com/appscode/grafana-dashboards/ci/stash/$file" - $HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + $HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 fi done + kubectl delete -f $path + delete_db_dependencies "$folder" + elif [ "$folder" == "stash" ]; then + echo "non db object name: $folder" + readarray -t inside_files_array < <(ls "$folder") + + bash ./hack/scripts/stash-flow.sh + check_dashboard_for_non_dbs "$folder" "$inside_files_array" + kubectl delete -f ./hack/yamls/backupconfiguration.yaml kubectl delete -f ./hack/yamls/restoresession.yaml kubectl delete -f ./hack/yamls/repository.yaml @@ -107,16 +127,7 @@ for folder in "${folder_array[@]}"; do readarray -t inside_files_array < <(ls "$folder") bash ./hack/scripts/policy-flow.sh - - sleep 120s - for file in "${inside_files_array[@]}"; do - if [[ $file == *.json ]]; then - dashboard_name="${file::-5}" - echo "checking for dashboard $dashboard_name" - url="https://raw.githubusercontent.com/appscode/grafana-dashboards/ci/policy/$file" - $HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 - fi - done + check_dashboard_for_non_dbs "$folder" "$inside_files_array" kubectl delete -f ./hack/yamls/policy/constraint-template.yaml kubectl delete -f ./hack/yamls/policy/constraint.yaml From cffac763070b71e6a3effae165f8bdbc01a2b508 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Thu, 23 May 2024 14:17:21 +0600 Subject: [PATCH 12/16] Acquire platform license Signed-off-by: Arnob kumar saha --- .github/workflows/ci.yml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da55c03a..e0643b87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,11 @@ name: dashboard-check on: + push: + branches: + - "*.*" + pull_request: + branches: + - "master" schedule: - cron: '0 0 * * *' workflow_dispatch: @@ -42,6 +48,10 @@ jobs: matrix: k8s: [v1.27.3] steps: + - uses: actions/checkout@v4 + with: + ref: workflow + - name: Set up Go 1.22 uses: actions/setup-go@v4 with: @@ -91,22 +101,26 @@ jobs: run: | kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + with: + detached: true + - name: Issue License env: BYTEBUILDERS_LICENSE_TOKEN: ${{ secrets.BYTEBUILDERS_LICENSE_TOKEN }} run: | export KUBECONFIG="${HOME}/.kube/config" CLUSTER_UID=$(kubectl get ns kube-system -o=jsonpath='{.metadata.uid}') - curl -X POST -o /tmp/license.txt -d "name=1gtm&email=1gtm@appscode.com&product=kubedb-enterprise&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license + curl -X POST -o /tmp/kubedb-license.txt -d "name=1gtm&email=1gtm@appscode.com&product=kubedb-enterprise&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license + curl -X POST -o /tmp/platform-license.txt -d "name=1gtm&email=1gtm@appscode.com&product=platform&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license - name: Install KubeDB - env: - LICENSE_FILE: /tmp/license.txt run: | helm install kubedb oci://ghcr.io/appscode-charts/kubedb \ - --version ${{ needs.config.outputs.kubedb }} \ + --version ${{ needs.config.outputs.kubedb_version }} \ --namespace kubedb --create-namespace \ - --set-file global.license=${LICENSE_FILE} \ + --set-file global.license=/tmp/kubedb-license.txt \ --set global.featureGates.Druid=true \ --set global.featureGates.FerretDB=true \ --set global.featureGates.Memcached=true \ @@ -126,6 +140,7 @@ jobs: cd .. git clone https://github.com/kubedb/cli.git cd cli + git checkout check go install ./... - name: Install Prometheus @@ -142,7 +157,7 @@ jobs: -n kubeops --create-namespace \ --set monitoring.agent=prometheus.io/operator \ --set monitoring.serviceMonitor.labels.release=prometheus \ - --set-file license=/tmp/license.txt \ + --set-file license=/tmp/kubedb-license.txt \ --wait --burst-limit=10000 sleep 5s kubectl wait --for=condition=ready pod -l "app.kubernetes.io/name=panopticon,app.kubernetes.io/instance=panopticon" -n kubeops --timeout=10m From e56205bcfb3ca3fc84655a6290a41c7e18d44980 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Thu, 23 May 2024 16:45:48 +0600 Subject: [PATCH 13/16] cleanup func added Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 24 ++++--- connectcluster/connectcluster-connect.json | 4 +- hack/scripts/check-dashboard.sh | 78 +++++++++++++++++----- hack/scripts/stash-flow.sh | 4 +- hack/yamls/stash/mongodb_standalone.yaml | 22 ++++++ 5 files changed, 100 insertions(+), 32 deletions(-) create mode 100644 hack/yamls/stash/mongodb_standalone.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0643b87..746459d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,12 +13,12 @@ on: folders: description: 'Folders' required: true - default: 'all' + default: 'mongodb' type: string kubedb_version: description: 'KubeDB Version' required: true - default: 'v2024.4.27' #needs to be dynamic + default: 'v2024.6.4' #needs to be dynamic type: string concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-dashboard-check @@ -34,11 +34,11 @@ jobs: - name: Defaulter id: defaulter env: - FOLDERS: ${{ inputs.folders }} + FOLDERS: "mongodb" KUBEDB_VERSION: ${{ inputs.kubedb_version }} run: | - echo "folders=${FOLDERS:-all}" >> $GITHUB_OUTPUT - echo "kubedb_version=${KUBEDB_VERSION:-v2024.4.27}" >> $GITHUB_OUTPUT + echo "folders=${FOLDERS:-mongodb}" >> $GITHUB_OUTPUT + echo "kubedb_version=${KUBEDB_VERSION:-v2024.6.4}" >> $GITHUB_OUTPUT test: name: Test runs-on: ubuntu-latest @@ -52,6 +52,11 @@ jobs: with: ref: workflow + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + with: + detached: true + - name: Set up Go 1.22 uses: actions/setup-go@v4 with: @@ -101,11 +106,6 @@ jobs: run: | kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - with: - detached: true - - name: Issue License env: BYTEBUILDERS_LICENSE_TOKEN: ${{ secrets.BYTEBUILDERS_LICENSE_TOKEN }} @@ -166,12 +166,14 @@ jobs: run: | helm repo add appscode https://charts.appscode.com/stable/ helm repo update - helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} --wait --burst-limit=10000 --debug + helm upgrade -i kubedb-metrics appscode/kubedb-metrics -n kubedb --create-namespace --version=${{ needs.config.outputs.kubedb }} --wait - name: Prepare smaples run: | cd .. git clone https://github.com/kubedb/samples.git + cd samples + git checkout fr-web - name: Check Dashboard Metrics env: diff --git a/connectcluster/connectcluster-connect.json b/connectcluster/connectcluster-connect.json index 45d66e58..ac7fdb9e 100644 --- a/connectcluster/connectcluster-connect.json +++ b/connectcluster/connectcluster-connect.json @@ -749,7 +749,7 @@ "targets": [ { "exemplar": true, - "expr": "kafka_connect_app_info{instance=~\"$instance\",start_time_ms!=\"\"}", + "expr": "kafka_connect_app_info{instance=~\"$instance\"}", "hide": false, "interval": "", "legendFormat": "", @@ -781,7 +781,7 @@ "refId": "D" }, { - "expr": "sum by (pod) (kafka_connect_worker__connector_startup_failure_total{namespace=~\"$namespace\",pod=~\"$app-.+$\"})", + "expr": "sum by (pod) (kafka_connect_worker_connector_startup_failure_total{namespace=~\"$namespace\",pod=~\"$app-.+$\"})", "format": "table", "instant": true, "interval": "", diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index 932fd98e..14c4452e 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +#set -e declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elasticsearch"]="Elasticsearch" ["kafka"]="Kafka" ["mariadb"]="MariaDB" ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" @@ -18,12 +18,21 @@ if [ $FOLDERS != "all" ]; then fi echo "folder_array = ${folder_array}" +PROMETHEUS_SERVICE_NAMESPACE="monitoring" +PROMETHEUS_SERVICE_NAME="prometheus-kube-prometheus-prometheus" +kubectl port-forward svc/${PROMETHEUS_SERVICE_NAME} 9090:9090 -n ${PROMETHEUS_SERVICE_NAMESPACE} & +# `$!` is a special variable in bash that holds the PID of the most recently executed background command. +PORT_FORWARD_PID=$! + +# Give port-forwarding some time to establish +sleep 5 + create_db_dependencies() { folder="$1" echo "folder=$folder" if [ "$folder" == "druid" ]; then kubectl create configmap -n demo my-init-script \ - --from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/samples/old-dbs/druid/monitoring/mysql-init-script.sql)" + --from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/samples/master/druid/monitoring/mysql-init-script.sql)" helm repo add minio https://operator.min.io/ helm upgrade --install --namespace "minio-operator" --create-namespace "minio-operator" minio/operator --set operator.replicaCount=1 --wait @@ -59,14 +68,31 @@ create_db_dependencies() { kubectl apply -f ../samples/solr/monitoring/zookeeper.yaml kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m fi -} -delete_db_dependencies() { + if [ "$folder" == "connectcluster" ]; then + kubectl apply -f ../samples/kafka/connectcluster/monitoring/kafka.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready Kafka kafka -n demo --timeout=10m + + kubectl apply -f ../samples/kafka/connectcluster/monitoring/connect-cluster.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready ConnectCluster connectcluster -n demo --timeout=10m + kubectl apply -f ../samples/kafka/connectcluster/monitoring/file-source.yaml + sleep 2s + fi +} + +cleanup() { + path="$1" + folder="$2" + if [ $folder == "connectcluster" ]; then + kubectl delete -f ../samples/kafka/connectcluster/monitoring/connect-cluster.yaml + fi + kubectl delete -f $path +# kubectl delete secret -n demo --all } check_dashboard_for_non_dbs() { - sleep 30s # waiting for the metrics to be generated + sleep 60s # waiting for the metrics to be generated folder="$1" inside_files_array="$2" for file in "${inside_files_array[@]}"; do @@ -74,11 +100,27 @@ check_dashboard_for_non_dbs() { dashboard_name="${file::-5}" echo "checking for dashboard $dashboard_name" url="https://raw.githubusercontent.com/appscode/grafana-dashboards/master/$folder/$file" - $HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + echo "$HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090" + $HOME/go/bin/kubectl-dba monitor dashboard -u $url -d=false --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 fi done } +wait_for_prometheus_target() { + target="$1" + echo "checking if $target-stats target exist in prometheus..." + for (( i=1; i<=600; i++ )); do + # Curl the Prometheus API to get the targets and extract the pool information + Targets=$(curl -s http://localhost:9090/api/v1/targets | jq -r '.data.activeTargets[] | .labels.service') + if echo "$Targets" | grep -q "$target"; then + echo "$target target found in prometheus" + sleep 30s + break + fi + sleep 5s + done +} + kubectl create ns demo @@ -99,37 +141,39 @@ for folder in "${folder_array[@]}"; do kubectl apply -f $path kubectl wait --for=jsonpath='{.status.phase}'=Ready ${kind[$folder]} $folder -n demo --timeout=10m - sleep 30s + wait_for_prometheus_target "$folder-stats" + for file in "${inside_files_array[@]}"; do if [[ $file == *.json ]]; then dashboard_name="${file::-5}" echo "checking for dashboard $dashboard_name" - $HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 + echo "$HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 -b=workflow" + $HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 -b=workflow fi done +# cleanup "$path" "$folder" - kubectl delete -f $path - delete_db_dependencies "$folder" elif [ "$folder" == "stash" ]; then echo "non db object name: $folder" readarray -t inside_files_array < <(ls "$folder") bash ./hack/scripts/stash-flow.sh + wait_for_prometheus_target "stash-stash-enterprise" check_dashboard_for_non_dbs "$folder" "$inside_files_array" - kubectl delete -f ./hack/yamls/backupconfiguration.yaml - kubectl delete -f ./hack/yamls/restoresession.yaml - kubectl delete -f ./hack/yamls/repository.yaml - kubectl delete -f ../samples/mongodb/monitoring/mongodb_standalone.yaml + cleanup "./hack/yamls/stash" elif [ "$folder" == "policy" ]; then echo "non db object name: $folder" readarray -t inside_files_array < <(ls "$folder") bash ./hack/scripts/policy-flow.sh + wait_for_prometheus_target "falco-ui-server" check_dashboard_for_non_dbs "$folder" "$inside_files_array" - kubectl delete -f ./hack/yamls/policy/constraint-template.yaml - kubectl delete -f ./hack/yamls/policy/constraint.yaml + cleanup "./hack/yamls/policy" fi -done \ No newline at end of file + +done + +kill $PORT_FORWARD_PID \ No newline at end of file diff --git a/hack/scripts/stash-flow.sh b/hack/scripts/stash-flow.sh index 0c92c1d4..e37688d0 100644 --- a/hack/scripts/stash-flow.sh +++ b/hack/scripts/stash-flow.sh @@ -27,7 +27,7 @@ helm install stash oci://ghcr.io/appscode-charts/stash \ --set stash-enterprise.monitoring.backup=true \ --set stash-enterprise.monitoring.operator=true \ --set stash-enterprise.monitoring.serviceMonitor.labels.release=prometheus \ - --set-file global.license=/tmp/license.txt \ + --set-file global.license=/tmp/kubedb-license.txt \ --wait --burst-limit=10000 curl -o kubectl-stash.tar.gz -fsSL https://github.com/stashed/cli/releases/download/v0.34.0/kubectl-stash-linux-amd64.tar.gz \ @@ -39,7 +39,7 @@ curl -o kubectl-stash.tar.gz -fsSL https://github.com/stashed/cli/releases/downl kubectl apply -f ./hack/yamls/stash/repository.yaml sleep 10 -kubectl apply -f ../samples/mongodb/monitoring/mongodb_standalone.yaml +kubectl apply -f ./hack/yamls/stash/mongodb_standalone.yaml kubectl wait --for=jsonpath='{.status.phase}'=Ready MongoDB mongodb-standalone -n demo --timeout=10m kubectl apply -f ./hack/yamls/stash/backupconfiguration.yaml diff --git a/hack/yamls/stash/mongodb_standalone.yaml b/hack/yamls/stash/mongodb_standalone.yaml new file mode 100644 index 00000000..9ea8b3c8 --- /dev/null +++ b/hack/yamls/stash/mongodb_standalone.yaml @@ -0,0 +1,22 @@ +apiVersion: kubedb.com/v1alpha2 +kind: MongoDB +metadata: + name: mongodb-standalone + namespace: demo +spec: + version: "4.4.26" + terminationPolicy: WipeOut + storage: + storageClassName: "standard" + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + monitor: + agent: prometheus.io/operator + prometheus: + serviceMonitor: + labels: + release: prometheus + interval: 10s \ No newline at end of file From 234b0f5a5ae2f8b0c70f6e887fb45de944ea1079 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Wed, 17 Jul 2024 14:34:30 +0600 Subject: [PATCH 14/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 6 +++--- hack/scripts/check-dashboard.sh | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 746459d7..3889b9c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ on: kubedb_version: description: 'KubeDB Version' required: true - default: 'v2024.6.4' #needs to be dynamic + default: 'v2024.7.11-rc.1' #needs to be dynamic type: string concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-dashboard-check @@ -38,7 +38,7 @@ jobs: KUBEDB_VERSION: ${{ inputs.kubedb_version }} run: | echo "folders=${FOLDERS:-mongodb}" >> $GITHUB_OUTPUT - echo "kubedb_version=${KUBEDB_VERSION:-v2024.6.4}" >> $GITHUB_OUTPUT + echo "kubedb_version=${KUBEDB_VERSION:-v2024.7.11-rc.1}" >> $GITHUB_OUTPUT test: name: Test runs-on: ubuntu-latest @@ -173,7 +173,7 @@ jobs: cd .. git clone https://github.com/kubedb/samples.git cd samples - git checkout fr-web + git checkout mg-args - name: Check Dashboard Metrics env: diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index 14c4452e..d309046c 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -88,7 +88,6 @@ cleanup() { kubectl delete -f ../samples/kafka/connectcluster/monitoring/connect-cluster.yaml fi kubectl delete -f $path -# kubectl delete secret -n demo --all } check_dashboard_for_non_dbs() { From 20081a413052fbe9ec15b242de4ad8b9f093f37f Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Wed, 17 Jul 2024 16:58:08 +0600 Subject: [PATCH 15/16] fix changes to run cli properly Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 8 +++++++- druid/druid_summary_dashboard.json | 6 +++--- elasticsearch/elasticsearch_summary_dashboard.json | 6 +++--- hack/scripts/check-dashboard.sh | 2 +- kafka/kafka_summary.json | 6 +++--- mariadb/mariadb-summary.json | 6 +++--- mongodb/mongodb-pod-dashboard.json | 8 ++++---- mongodb/mongodb-summary-dashboard.json | 6 +++--- mysql/mysql_summary_dashboard.json | 6 +++--- perconaxtradb/perconaxtradb-summary.json | 6 +++--- postgres/postgres_summary_dashboard.json | 6 +++--- rabbitmq/rabbitmq-summary.json | 6 +++--- redis/redis_summary_dashboard.json | 6 +++--- redis/sentinel_summary_dashbaord.json | 6 +++--- singlestore/singlestore_summary_dashboard.json | 6 +++--- solr/solr-summary.json | 6 +++--- zookeeper/zookeeper_summary_dashboard.json | 6 +++--- 17 files changed, 54 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3889b9c3..4427cafb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,6 +115,12 @@ jobs: curl -X POST -o /tmp/kubedb-license.txt -d "name=1gtm&email=1gtm@appscode.com&product=kubedb-enterprise&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license curl -X POST -o /tmp/platform-license.txt -d "name=1gtm&email=1gtm@appscode.com&product=platform&cluster=${CLUSTER_UID}&tos=true&token=${BYTEBUILDERS_LICENSE_TOKEN}" https://license-issuer.appscode.com/issue-license + - name: Install Longhorn + run: | + helm repo add longhorn https://charts.longhorn.io + helm repo update + helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace --version 1.6.2 --wait --burst-limit=10000 + - name: Install KubeDB run: | helm install kubedb oci://ghcr.io/appscode-charts/kubedb \ @@ -140,7 +146,7 @@ jobs: cd .. git clone https://github.com/kubedb/cli.git cd cli - git checkout check +# git checkout check go install ./... - name: Install Prometheus diff --git a/druid/druid_summary_dashboard.json b/druid/druid_summary_dashboard.json index 1022ffc4..911ec149 100644 --- a/druid/druid_summary_dashboard.json +++ b/druid/druid_summary_dashboard.json @@ -2434,7 +2434,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-brokers-\\\\d+$|$app-coordinators-\\\\d+$|$app-historicals-\\\\d+$|$app-middlemanagers-\\\\d+$|$app-routers-\\\\d+$|$app-overlords-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2518,7 +2518,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-brokers-\\\\d+$|$app-coordinators-\\\\d+$|$app-historicals-\\\\d+$|$app-middlemanagers-\\\\d+$|$app-routers-\\\\d+$|$app-overlords-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2602,7 +2602,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-brokers-\\\\d+$|$app-coordinators-\\\\d+$|$app-historicals-\\\\d+$|$app-middlemanagers-\\\\d+$|$app-routers-\\\\d+$|$app-overlords-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/elasticsearch/elasticsearch_summary_dashboard.json b/elasticsearch/elasticsearch_summary_dashboard.json index ea117e30..a26c3845 100644 --- a/elasticsearch/elasticsearch_summary_dashboard.json +++ b/elasticsearch/elasticsearch_summary_dashboard.json @@ -2567,7 +2567,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2651,7 +2651,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2735,7 +2735,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index d309046c..c1b640bb 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -97,7 +97,7 @@ check_dashboard_for_non_dbs() { for file in "${inside_files_array[@]}"; do if [[ $file == *.json ]]; then dashboard_name="${file::-5}" - echo "checking for dashboard $dashboard_name" + echo "checking for dashboard $dashboard_name" url="https://raw.githubusercontent.com/appscode/grafana-dashboards/master/$folder/$file" echo "$HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090" $HOME/go/bin/kubectl-dba monitor dashboard -u $url -d=false --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 diff --git a/kafka/kafka_summary.json b/kafka/kafka_summary.json index 63654ac3..ac54134b 100644 --- a/kafka/kafka_summary.json +++ b/kafka/kafka_summary.json @@ -2434,7 +2434,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2518,7 +2518,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2602,7 +2602,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-.+$\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/mariadb/mariadb-summary.json b/mariadb/mariadb-summary.json index 18b0e80d..48c9a7bc 100644 --- a/mariadb/mariadb-summary.json +++ b/mariadb/mariadb-summary.json @@ -2434,7 +2434,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2518,7 +2518,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2602,7 +2602,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/mongodb/mongodb-pod-dashboard.json b/mongodb/mongodb-pod-dashboard.json index 75e7ebe9..3e2aa90a 100644 --- a/mongodb/mongodb-pod-dashboard.json +++ b/mongodb/mongodb-pod-dashboard.json @@ -195,7 +195,7 @@ "targets": [ { "exemplar": false, - "expr": "sum(rate(mongodb_ss_opcounters{pod=~\"$pod\",type!=\"command\"}[$interval]) or irate(mongodb_ss_opcounters{pod=~\"$pod\",type!=\"command\"}[5m]))", + "expr": "sum(rate(mongodb_ss_opcounters{pod=~\"$pod\",legacy_op_type!=\"command\"}[$interval]) or irate(mongodb_ss_opcounters{pod=~\"$pod\",legacy_op_type!=\"command\"}[5m]))", "interval": "$interval", "legendFormat": "", "refId": "A" @@ -261,7 +261,7 @@ "targets": [ { "exemplar": false, - "expr": "avg by (service) (rate(mongodb_ss_opLatencies_latency{service=~\"${app}-stats\"}[$interval]) / (rate(mongodb_ss_opLatencies_ops{service=~\"${app}-stats\"}[$interval]) > 0) or irate(mongodb_ss_opLatencies_latency{service=~\"${app}-stats\"}[5m]) / (irate(mongodb_ss_opLatencies_ops{service=~\"${app}-stats\"}[5m]) > 0))\n", + "expr": "avg by (service) (rate(mongodb_ss_opLatencies_latency{service=~\"$app-stats\"}[$interval]) / (rate(mongodb_ss_opLatencies_ops{service=~\"$app-stats\"}[$interval]) > 0) or irate(mongodb_ss_opLatencies_latency{service=~\"$app-stats\"}[5m]) / (irate(mongodb_ss_opLatencies_ops{service=~\"$app-stats\"}[5m]) > 0))\n", "interval": "$interval", "legendFormat": "", "refId": "A" @@ -478,7 +478,7 @@ "targets": [ { "exemplar": false, - "expr": "avg by (service,op_type) (rate(mongodb_ss_opLatencies_latency{service=~\"${app}-stats\"}[$interval]) / (rate(mongodb_ss_opLatencies_ops{service=~\"${app}-stats\"}[$interval]) > 0) or irate(mongodb_ss_opLatencies_latency{service=~\"${app}-stats\"}[5m]) / (irate(mongodb_ss_opLatencies_ops{service=~\"${app}-stats\"}[5m]) > 0))", + "expr": "avg by (service,op_type) (rate(mongodb_ss_opLatencies_latency{service=~\"$app-stats\"}[$interval]) / (rate(mongodb_ss_opLatencies_ops{service=~\"$app-stats\"}[$interval]) > 0) or irate(mongodb_ss_opLatencies_latency{service=~\"$app-stats\"}[5m]) / (irate(mongodb_ss_opLatencies_ops{service=~\"$app-stats\"}[5m]) > 0))", "interval": "$interval", "legendFormat": "{{op_type}}", "range": true, @@ -1890,7 +1890,7 @@ "name": "pod", "options": [], "query": { - "query": "label_values(mongodb_up{namespace=~\"$namespace\",service=\"${app}-stats\"}, pod)", + "query": "label_values(mongodb_up{namespace=~\"$namespace\",service=\"$app-stats\"}, pod)", "refId": "Prometheus-pod-Variable-Query" }, "refresh": 2, diff --git a/mongodb/mongodb-summary-dashboard.json b/mongodb/mongodb-summary-dashboard.json index 29ab4d8f..c135d708 100644 --- a/mongodb/mongodb-summary-dashboard.json +++ b/mongodb/mongodb-summary-dashboard.json @@ -2473,7 +2473,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$|$app-shard\\\\d+-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2557,7 +2557,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$|$app-shard\\\\d+-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2641,7 +2641,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$|$app-shard\\\\d+-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/mysql/mysql_summary_dashboard.json b/mysql/mysql_summary_dashboard.json index f808cefd..3770505f 100644 --- a/mysql/mysql_summary_dashboard.json +++ b/mysql/mysql_summary_dashboard.json @@ -2517,7 +2517,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2601,7 +2601,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2685,7 +2685,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/perconaxtradb/perconaxtradb-summary.json b/perconaxtradb/perconaxtradb-summary.json index bbf5e0d0..638321f1 100644 --- a/perconaxtradb/perconaxtradb-summary.json +++ b/perconaxtradb/perconaxtradb-summary.json @@ -2434,7 +2434,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2518,7 +2518,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2602,7 +2602,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/postgres/postgres_summary_dashboard.json b/postgres/postgres_summary_dashboard.json index 38fc0d2e..d61fc88f 100644 --- a/postgres/postgres_summary_dashboard.json +++ b/postgres/postgres_summary_dashboard.json @@ -2977,7 +2977,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -3061,7 +3061,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -3145,7 +3145,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/rabbitmq/rabbitmq-summary.json b/rabbitmq/rabbitmq-summary.json index 90c28bc3..d17cbe8d 100644 --- a/rabbitmq/rabbitmq-summary.json +++ b/rabbitmq/rabbitmq-summary.json @@ -2434,7 +2434,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2518,7 +2518,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2602,7 +2602,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/redis/redis_summary_dashboard.json b/redis/redis_summary_dashboard.json index 8d8007cf..443f29db 100644 --- a/redis/redis_summary_dashboard.json +++ b/redis/redis_summary_dashboard.json @@ -2563,7 +2563,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$|$app-shard\\\\d+-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2647,7 +2647,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$|$app-shard\\\\d+-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2731,7 +2731,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$|$app-shard\\\\d+-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/redis/sentinel_summary_dashbaord.json b/redis/sentinel_summary_dashbaord.json index fe26d21d..b5bc60e4 100644 --- a/redis/sentinel_summary_dashbaord.json +++ b/redis/sentinel_summary_dashbaord.json @@ -2563,7 +2563,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2647,7 +2647,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2731,7 +2731,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/singlestore/singlestore_summary_dashboard.json b/singlestore/singlestore_summary_dashboard.json index 396d8155..3c49d4f5 100644 --- a/singlestore/singlestore_summary_dashboard.json +++ b/singlestore/singlestore_summary_dashboard.json @@ -2434,7 +2434,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-aggregator-\\\\d+$|$app-leaf-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2518,7 +2518,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-aggregator-\\\\d+$|$app-leaf-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2602,7 +2602,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-aggregator-\\\\d+$|$app-leaf-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/solr/solr-summary.json b/solr/solr-summary.json index 0d9924cd..6c8c6d5f 100644 --- a/solr/solr-summary.json +++ b/solr/solr-summary.json @@ -2491,7 +2491,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-overseer-\\\\d+$|$app-coordinator-\\\\d+$|$app-data-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-overseer-\\\\d+$|$app-coordinator-\\\\d+$|$app-data-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2575,7 +2575,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-overseer-\\\\d+$|$app-coordinator-\\\\d+$|$app-data-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-overseer-\\\\d+$|$app-coordinator-\\\\d+$|$app-data-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2659,7 +2659,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-overseer-\\\\d+$|$app-coordinator-\\\\d+$|$app-data-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-overseer-\\\\d+$|$app-coordinator-\\\\d+$|$app-data-\\\\d+$|$app-\\\\d+$\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", diff --git a/zookeeper/zookeeper_summary_dashboard.json b/zookeeper/zookeeper_summary_dashboard.json index b52bbdab..6942c23b 100644 --- a/zookeeper/zookeeper_summary_dashboard.json +++ b/zookeeper/zookeeper_summary_dashboard.json @@ -2551,7 +2551,7 @@ "targets": [ { "exemplar": true, - "expr": "kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}", + "expr": "kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}", "format": "table", "instant": true, "interval": "", @@ -2637,7 +2637,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) )* 100", + "expr": "(kubelet_volume_stats_used_bytes{} / on(persistentvolumeclaim) group_left(pod) (kubelet_volume_stats_capacity_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) )* 100", "instant": true, "interval": "", "legendFormat": "{{pod}}", @@ -2725,7 +2725,7 @@ "targets": [ { "exemplar": true, - "expr": "(kubelet_volume_stats_used_bytes + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"$app-\\\\d+$\",namespace=~\"$namespace\"}) ", + "expr": "(kubelet_volume_stats_used_bytes{} + on(persistentvolumeclaim) group_left(pod) kube_pod_spec_volumes_persistentvolumeclaims_info{pod=~\"^$app.*\",namespace=~\"$namespace\"}) ", "interval": "", "intervalFactor": 1, "legendFormat": "{{pod}}", From fa3ce3903d549b7d47c7106a6d8c9c9a4c78540e Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Thu, 18 Jul 2024 10:51:54 +0600 Subject: [PATCH 16/16] wip Signed-off-by: sayedppqq --- .github/workflows/ci.yml | 37 ++++++++++++++++----------------- hack/scripts/check-dashboard.sh | 15 ++++++++----- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4427cafb..92779768 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,11 @@ name: dashboard-check on: - push: - branches: - - "*.*" - pull_request: - branches: - - "master" +# push: +# branches: +# - "*.*" +# pull_request: +# branches: +# - "master" schedule: - cron: '0 0 * * *' workflow_dispatch: @@ -13,12 +13,12 @@ on: folders: description: 'Folders' required: true - default: 'mongodb' + default: 'all' type: string kubedb_version: description: 'KubeDB Version' required: true - default: 'v2024.7.11-rc.1' #needs to be dynamic + default: 'v2024.8.21' #needs to be dynamic type: string concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-dashboard-check @@ -26,7 +26,7 @@ concurrency: jobs: config: name: Configure Inputs - runs-on: ubuntu-latest + runs-on: label-detector outputs: folders: ${{ steps.defaulter.outputs.folders }} kubedb_version : ${{ steps.defaulter.outputs.kubedb_version }} @@ -34,14 +34,14 @@ jobs: - name: Defaulter id: defaulter env: - FOLDERS: "mongodb" + FOLDERS: "all" KUBEDB_VERSION: ${{ inputs.kubedb_version }} run: | - echo "folders=${FOLDERS:-mongodb}" >> $GITHUB_OUTPUT - echo "kubedb_version=${KUBEDB_VERSION:-v2024.7.11-rc.1}" >> $GITHUB_OUTPUT + echo "folders=${FOLDERS:-all}" >> $GITHUB_OUTPUT + echo "kubedb_version=${KUBEDB_VERSION:-v2024.8.21}" >> $GITHUB_OUTPUT test: name: Test - runs-on: ubuntu-latest + runs-on: firecracker needs: config strategy: fail-fast: false @@ -52,10 +52,10 @@ jobs: with: ref: workflow - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - with: - detached: true +# - name: Setup tmate session +# uses: mxschmitt/action-tmate@v3 +# with: +# detached: true - name: Set up Go 1.22 uses: actions/setup-go@v4 @@ -146,7 +146,6 @@ jobs: cd .. git clone https://github.com/kubedb/cli.git cd cli -# git checkout check go install ./... - name: Install Prometheus @@ -179,7 +178,7 @@ jobs: cd .. git clone https://github.com/kubedb/samples.git cd samples - git checkout mg-args + git checkout mssql-monitoring - name: Check Dashboard Metrics env: diff --git a/hack/scripts/check-dashboard.sh b/hack/scripts/check-dashboard.sh index c1b640bb..5d186241 100644 --- a/hack/scripts/check-dashboard.sh +++ b/hack/scripts/check-dashboard.sh @@ -3,7 +3,7 @@ declare -A kind=(["connectcluster"]="ConnectCluster" ["druid"]="Druid" ["elasticsearch"]="Elasticsearch" ["kafka"]="Kafka" ["mariadb"]="MariaDB" ["mongodb"]="MongoDB" ["mysql"]="MySQL" ["perconaxtradb"]="PerconaXtraDB" ["pgpool"]="Pgpool" ["postgres"]="Postgres" ["proxysql"]="ProxySQL" - ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper") + ["rabbitmq"]="RabbitMQ" ["redis"]="Redis" ["singlestore"]="Singlestore" ["solr"]="Solr" ["zookeeper"]="ZooKeeper" ["mssqlserver"]="MSSQLServer") # export the ENVs from .env file if [ -f .env ]; then @@ -77,8 +77,13 @@ create_db_dependencies() { kubectl wait --for=jsonpath='{.status.phase}'=Ready ConnectCluster connectcluster -n demo --timeout=10m kubectl apply -f ../samples/kafka/connectcluster/monitoring/file-source.yaml - sleep 2s fi + + if [ "$folder" == "redis" ]; then + kubectl apply -f ../samples/redis/monitoring/sentinel.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Ready RedisSentinel sentinel -n demo --timeout=10m + fi + sleep 2s } cleanup() { @@ -97,7 +102,7 @@ check_dashboard_for_non_dbs() { for file in "${inside_files_array[@]}"; do if [[ $file == *.json ]]; then dashboard_name="${file::-5}" - echo "checking for dashboard $dashboard_name" + echo "checking for dashboard $dashboard_name" url="https://raw.githubusercontent.com/appscode/grafana-dashboards/master/$folder/$file" echo "$HOME/go/bin/kubectl-dba monitor dashboard -u $url -o=true --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090" $HOME/go/bin/kubectl-dba monitor dashboard -u $url -d=false --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 @@ -107,7 +112,7 @@ check_dashboard_for_non_dbs() { wait_for_prometheus_target() { target="$1" - echo "checking if $target-stats target exist in prometheus..." + echo "checking if $target-stats target exist in prometheus...." for (( i=1; i<=600; i++ )); do # Curl the Prometheus API to get the targets and extract the pool information Targets=$(curl -s http://localhost:9090/api/v1/targets | jq -r '.data.activeTargets[] | .labels.service') @@ -150,7 +155,7 @@ for folder in "${folder_array[@]}"; do $HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090 -b=workflow fi done -# cleanup "$path" "$folder" + cleanup "$path" "$folder" elif [ "$folder" == "stash" ]; then echo "non db object name: $folder"