diff --git a/.github/actions/build-and-push-ci-image/action.yml b/.github/actions/build-and-push-ci-image/action.yml new file mode 100644 index 000000000000..4eb85fc68420 --- /dev/null +++ b/.github/actions/build-and-push-ci-image/action.yml @@ -0,0 +1,18 @@ +name: Build and push CI Docker image +description: Build and push CI Docker image to local registry +inputs: + binary_path: + default: "./bin" + description: "Binary path" +runs: + using: composite + steps: + - name: Build and push to local registry + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/ci/ubuntu/Dockerfile.fuzztests + push: true + tags: localhost:5001/greptime/greptimedb:latest + build-args: | + BINARY_PATH=${{ inputs.binary_path }} diff --git a/.github/actions/setup-etcd-cluster/action.yml b/.github/actions/setup-etcd-cluster/action.yml new file mode 100644 index 000000000000..dfc9a29a2f32 --- /dev/null +++ b/.github/actions/setup-etcd-cluster/action.yml @@ -0,0 +1,23 @@ +name: Setup Etcd cluster +description: Deploy Etcd cluster on Kubernetes +inputs: + etcd-replica-count: + default: 1 + description: "Etcd replica count" + namespace: + default: "etcd-cluster" + +runs: + using: composite + steps: + - name: Install Etcd cluster + shell: bash + run: | + helm upgrade \ + --install etcd oci://registry-1.docker.io/bitnamicharts/etcd \ + --set replicaCount=${{ inputs.etcd-replica-count }} \ + --set auth.rbac.create=false \ + --set auth.rbac.token.enabled=false \ + --set persistence.size=1Gi \ + --create-namespace \ + -n ${{ inputs.namespace }} diff --git a/.github/actions/setup-greptimedb-cluster/action.yml b/.github/actions/setup-greptimedb-cluster/action.yml new file mode 100644 index 000000000000..709738b7c85c --- /dev/null +++ b/.github/actions/setup-greptimedb-cluster/action.yml @@ -0,0 +1,81 @@ +name: Setup GreptimeDB cluster +description: Deploy GreptimeDB cluster on Kubernetes +inputs: + frontend-replica-count: + default: 1 + description: "Frontend replica count" + datanode-replica-count: + default: 2 + description: "Datanode replica count" + metasrv-replica-count: + default: 1 + description: "Metasrv replica count" + etcd-replica-count: + default: 1 + description: "Etcd replica count" + image-registry: + default: "docker.io" + description: "Image registry" + image-repository: + default: "greptime/greptimedb" + description: "Image repository" + image-tag: + default: "latest" + description: 'Image tag' + etcd-endpoints: + default: "etcd.etcd-cluster.svc.cluster.local:2379" + description: "Etcd endpoints" + +runs: + using: composite + steps: + - name: Install GreptimeDB operator + shell: bash + run: | + helm repo add greptime https://greptimeteam.github.io/helm-charts/ + helm repo update + helm upgrade \ + --install \ + --create-namespace \ + greptimedb-operator greptime/greptimedb-operator \ + -n greptimedb-admin \ + --wait \ + --wait-for-jobs + - name: Install GreptimeDB cluster + shell: bash + run: | + helm upgrade \ + --install my-greptimedb \ + --set meta.etcdEndpoints=${{ inputs.etcd-endpoints }} \ + --set image.registry=${{ inputs.image-registry }} \ + --set image.repository=${{ inputs.image-repository }} \ + --set image.tag=${{ inputs.image-tag }} \ + greptime/greptimedb-cluster \ + --create-namespace \ + -n my-greptimedb \ + --wait \ + --wait-for-jobs + - name: Wait for GreptimeDB + shell: bash + run: | + kubectl get pods -n my-greptimedb + kubectl wait \ + --for=condition=Ready \ + pod -l app.greptime.io/component=my-greptimedb-meta \ + --timeout=120s \ + -n my-greptimedb + kubectl wait \ + --for=condition=Ready \ + pod -l app.greptime.io/component=my-greptimedb-datanode \ + --timeout=120s \ + -n my-greptimedb + kubectl wait \ + --for=condition=Ready \ + pod -l app.greptime.io/component=my-greptimedb-frontend \ + --timeout=120s \ + -n my-greptimedb + - name: Print GreptimeDB info + if: always() + shell: bash + run: | + kubectl get all --show-labels -n my-greptimedb diff --git a/.github/actions/setup-kind/action.yml b/.github/actions/setup-kind/action.yml new file mode 100644 index 000000000000..f42731ca6db4 --- /dev/null +++ b/.github/actions/setup-kind/action.yml @@ -0,0 +1,10 @@ +name: Setup Kind +description: Deploy Kind +runs: + using: composite + steps: + - uses: actions/checkout@v4 + - name: Create kind cluster + shell: bash + run: | + ./.github/scripts/kind-with-registry.sh diff --git a/.github/scripts/kind-with-registry.sh b/.github/scripts/kind-with-registry.sh new file mode 100755 index 000000000000..398e096e4139 --- /dev/null +++ b/.github/scripts/kind-with-registry.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +# 1. Create registry container unless it already exists +reg_name='kind-registry' +reg_port='5001' +if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then + docker run \ + -d --restart=always -p "127.0.0.1:${reg_port}:5000" --network bridge --name "${reg_name}" \ + registry:2 +fi + +# 2. Create kind cluster with containerd registry config dir enabled +# TODO: kind will eventually enable this by default and this patch will +# be unnecessary. +# +# See: +# https://github.com/kubernetes-sigs/kind/issues/2875 +# https://github.com/containerd/containerd/blob/main/docs/cri/config.md#registry-configuration +# See: https://github.com/containerd/containerd/blob/main/docs/hosts.md +cat <