From 5f3910f611af2617d2f42f7f15f10d1ba68f5b1d Mon Sep 17 00:00:00 2001 From: fengshunli <1171313930@qq.com> Date: Mon, 15 Apr 2024 10:43:14 +0800 Subject: [PATCH] add ci Signed-off-by: fengshunli <1171313930@qq.com> --- .github/CODEOWNERS | 7 +++ .github/linters/.markdown-lint.yml | 2 + .github/linters/ct.yaml | 10 ++++ .github/workflows/lint-test.yaml | 48 +++++++++++++++++++ .github/workflows/release.yaml | 31 ++++++++++++ .github/workflows/superlinter.yml | 32 +++++++++++++ .github/workflows/sync-codeowners.yaml | 29 +++++++++++ .github/workflows/sync-readme.yaml | 23 +++++++++ README.md | 66 +++++++++++++------------- scripts/check-codeowners.sh | 18 +++++++ 10 files changed, 233 insertions(+), 33 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/linters/ct.yaml create mode 100644 .github/workflows/lint-test.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/superlinter.yml create mode 100644 .github/workflows/sync-codeowners.yaml create mode 100644 .github/workflows/sync-readme.yaml create mode 100755 scripts/check-codeowners.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..6812004 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners +# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax + +# The repo admins team will be the default owners for everything in the repo. +# Unless a later match takes precedence, they will be requested for review when someone opens a pull request. + +/cubefs \ No newline at end of file diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..56f4e6b --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,2 @@ +MD013: + line_length: 600 diff --git a/.github/linters/ct.yaml b/.github/linters/ct.yaml new file mode 100644 index 0000000..b1d1fb9 --- /dev/null +++ b/.github/linters/ct.yaml @@ -0,0 +1,10 @@ +# See https://github.com/helm/chart-testing#configuration +remote: origin +target-branch: master +chart-dirs: + - cubefs +chart-repos: + - cubefs-community=https://cubefs.github.io/cubefs-helm +helm-extra-args: --timeout 600s +additional-commands: + - helm unittest --helm3 --strict --file unittests/*.yaml --file 'unittests/**/*.yaml' {{ .Path }} diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml new file mode 100644 index 0000000..310ea4c --- /dev/null +++ b/.github/workflows/lint-test.yaml @@ -0,0 +1,48 @@ +name: Lint and Test Charts + +on: pull_request + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v2.0 + with: + version: v3.8.1 + + - uses: actions/setup-python@v3 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.2.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --config .github/linters/ct.yaml) + if [[ -n "$changed" ]]; then + echo "name=changed::true" >> "$GITHUB_OUTPUT" + fi + + - name: install helm unittest plugin + if: steps.list-changed.outputs.changed == 'true' + run: | + helm env + helm plugin install https://github.com/quintush/helm-unittest.git --version 0.2.8 + + - name: Run chart-testing (lint) + run: ct lint --config .github/linters/ct.yaml + + - name: Create kind cluster + uses: helm/kind-action@v1.2.0 + if: steps.list-changed.outputs.changed == 'true' + + - name: Run chart-testing (install) + run: ct install --config .github/linters/ct.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..98baba8 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,31 @@ +name: Release Charts + +on: + push: + branches: + - master + +jobs: + release: + if: github.repository == 'cubefs/cubefs-helm' + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Fetch history + run: git fetch --prune --unshallow + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Set up Helm + uses: azure/setup-helm@v2.0 + with: + version: v3.8.1 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.4.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml new file mode 100644 index 0000000..73c7fe4 --- /dev/null +++ b/.github/workflows/superlinter.yml @@ -0,0 +1,32 @@ +name: Lint Code Base + +# Documentation: +# https://help.github.com/en/articles/workflow-syntax-for-github-actions + +on: pull_request + +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Lint Code Base + uses: docker://github/super-linter:slim-v4 + env: + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: .github/linters + VALIDATE_ALL_CODEBASE: false + VALIDATE_BASH: false + VALIDATE_JSCPD: false + VALIDATE_KUBERNETES_KUBEVAL: false + VALIDATE_PYTHON: false + VALIDATE_PYTHON_FLAKE8: false + VALIDATE_PYTHON_BLACK: false + VALIDATE_YAML: false + VALIDATE_NATURAL_LANGUAGE: false diff --git a/.github/workflows/sync-codeowners.yaml b/.github/workflows/sync-codeowners.yaml new file mode 100644 index 0000000..4d162a0 --- /dev/null +++ b/.github/workflows/sync-codeowners.yaml @@ -0,0 +1,29 @@ +name: Sync CODEOWNERS + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - run: | + ./scripts/check-codeowners.sh > ${{ runner.temp }}/CODEOWNERS + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: master + - name: install yq + run: | + sudo snap install yq + - name: commit codeowners + run: | + cp -f ${{ runner.temp }}/CODEOWNERS .github/CODEOWNERS + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add .github/CODEOWNERS + git commit --signoff -m "change code owners" + git push \ No newline at end of file diff --git a/.github/workflows/sync-readme.yaml b/.github/workflows/sync-readme.yaml new file mode 100644 index 0000000..6fa9548 --- /dev/null +++ b/.github/workflows/sync-readme.yaml @@ -0,0 +1,23 @@ +on: + push: + branches: + - master + paths: + - README.md +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: | + cp -f README.md ${{ runner.temp }}/README.md + - uses: actions/checkout@v3 + with: + ref: gh-pages + - run: | + cp -f ${{ runner.temp }}/README.md . + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add README.md + git commit --signoff -m "Sync README from master" + git push diff --git a/README.md b/README.md index cb90112..b116c80 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,36 @@ - # cubefs-helm ## Deploy Cubefs using Kubernetes and Helm The cubefs-helm project helps deploy a Cubefs cluster orchestrated by Kubernetes. -**Cubefs Components** +## Cubefs Components -
Cubefs Components
+![Cubefs Components](assets/cubefs-component.jpg) +## Cubefs Deployment -**Cubefs Deployment** +![Cubefs Deployment](assets/cubefs-deployment.jpg) -
Cubefs Deployment
+### Prerequisite -### Prerequisite -- Kubernetes 1.14+ -- CSI spec version 1.1.0 -- Helm 3 +* Kubernetes 1.14+ +* CSI spec version 1.1.0 +* Helm 3 ### Download cubefs-helm -``` -$ git clone https://github.com/cubefs/cubefs-helm -$ cd cubefs-helm +```shell +git clone https://github.com/cubefs/cubefs-helm +cd cubefs-helm ``` ### Create configuration yaml file Create a `cubefs.yaml` file, and put it in a user-defined path. Suppose this is where we put it. -``` -$ vi ~/cubefs.yaml +```shell +vim ~/cubefs.yaml ``` ``` yaml @@ -78,7 +77,7 @@ provisioner: You should tag each Kubernetes node with the appropriate labels accorindly for server node and CSI node of Cubefs. -``` +```shell kubectl label node component.cubefs.io/master=enabled kubectl label node component.cubefs.io/metanode=enabled kubectl label node component.cubefs.io/datanode=enabled @@ -87,16 +86,17 @@ kubectl label node component.cubefs.io/csi=enabled ``` ### Deploy Cubefs cluster -``` -$ helm upgrade --install cubefs ./cubefs -f ~/cubefs.yaml -n cubefs --create-namespace + +```shell +helm upgrade --install cubefs -f ~/cubefs.yaml -n cubefs --create-namespace cubefs ``` The output of `helm install` shows servers to be deployed. Use the following command to check pod status, which may take a few minutes. -``` -$ kubectl -n cubefs get pods +```shell +kubectl -n cubefs get pods NAME READY STATUS RESTARTS AGE cfs-csi-controller-cfc7754b-ptvlq 3/3 Running 0 2m40s cfs-csi-node-q262p 2/2 Running 0 2m40s @@ -121,7 +121,7 @@ prometheus-6dcf97d7b-5v2xw 1/1 Running 0 2m40s Check cluster status -``` +```shell helm status cubefs ``` @@ -147,8 +147,8 @@ spec: storageClassName: cfs-sc ``` -``` -$ kubectl create -f pvc.yaml +```shell +kubectl create -f pvc.yaml ``` There is an example `deployment.yaml` using the PVC as below @@ -186,8 +186,8 @@ spec: claimName: cfs-pvc ``` -``` -$ kubectl create -f deployment.yaml +```shell +kubectl create -f deployment.yaml ``` ## Config Monitoring System (optional) @@ -208,37 +208,37 @@ spec: Start the ingress controller -``` -$ kubectl apply -f mandatory.yaml +```shell +kubectl apply -f mandatory.yaml ``` Get the IP address of Nginx ingress controller. -``` -$ kubectl get pods --all-namespaces -o wide | grep nginx-ingress-controller +```shell +kubectl get pods --all-namespaces -o wide | grep nginx-ingress-controller ingress-nginx nginx-ingress-controller-5bbd46cd86-q88sw 1/1 Running 0 115m 10.196.31.101 host-10-196-31-101 ``` Get the host name of Grafana which should also be used as domain name. -``` -$ kubectl get ingress -n cubefs +```shell +kubectl get ingress -n cubefs NAME HOSTS ADDRESS PORTS AGE grafana monitor.cubefs.com 10.106.207.55 80 24h ``` Add a local DNS in `/etc/hosts` in order for a request to find the ingress controller. -``` +```yaml 10.196.31.101 monitor.cubefs.com ``` At this point, dashboard can be visited by `http://monitor.cubefs.com`. -## Uninstall Cubefs +## Uninstall Cubefs uninstall Cubefs cluster using helm -``` +```shell helm delete cubefs ``` diff --git a/scripts/check-codeowners.sh b/scripts/check-codeowners.sh new file mode 100755 index 0000000..0a13b6b --- /dev/null +++ b/scripts/check-codeowners.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +cat <