Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
Signed-off-by: fengshunli <[email protected]>
  • Loading branch information
fengshunli committed Apr 15, 2024
1 parent 8fdc440 commit 443e89d
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 33 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MD013:
line_length: 600
10 changes: 10 additions & 0 deletions .github/linters/ct.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
48 changes: 48 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
version: v3.8.1

- uses: actions/setup-python@v3
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config .github/linters/ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
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/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --config .github/linters/ct.yaml
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.8.1

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
32 changes: 32 additions & 0 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions .github/workflows/sync-codeowners.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
git add .github/CODEOWNERS
git commit --signoff -m "change code owners"
git push
23 changes: 23 additions & 0 deletions .github/workflows/sync-readme.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
git add README.md
git commit --signoff -m "Sync README from master"
git push
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

<div width="100%" style="text-align:center;"><img alt="Cubefs Components" src="assets/cubefs-component.jpg" width="700"/></div>
![Cubefs Components](assets/cubefs-component.jpg)

## Cubefs Deployment

**Cubefs Deployment**
![Cubefs Deployment](assets/cubefs-deployment.jpg)

<div width="100%" style="text-align:center;"><img alt="Cubefs Deployment" src="assets/cubefs-deployment.jpg" width="700"/></div>
### 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
vi ~/cubefs.yaml
```

``` yaml
Expand Down Expand Up @@ -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 <nodename> component.cubefs.io/master=enabled
kubectl label node <nodename> component.cubefs.io/metanode=enabled
kubectl label node <nodename> component.cubefs.io/datanode=enabled
Expand All @@ -87,16 +86,17 @@ kubectl label node <nodename> 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 ./cubefs -f ~/cubefs.yaml -n cubefs --create-namespace
```

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
Expand All @@ -121,7 +121,7 @@ prometheus-6dcf97d7b-5v2xw 1/1 Running 0 2m40s

Check cluster status

```
```shell
helm status cubefs
```

Expand All @@ -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
Expand Down Expand Up @@ -186,8 +186,8 @@ spec:
claimName: cfs-pvc
```

```
$ kubectl create -f deployment.yaml
```shell
kubectl create -f deployment.yaml
```

## Config Monitoring System (optional)
Expand All @@ -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 <none> <none>
```

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
```
18 changes: 18 additions & 0 deletions scripts/check-codeowners.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

cat <<EOF
# 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.
EOF

for DIR in $(ls -1 -d ./cubefs/*)
do
FILE="$DIR/Chart.yaml"
DIR=$(echo $DIR | sed 's/^\.//')
MAINTAINERS=$(yq e '.maintainers.[].name' $FILE| sed 's/^/@/' | sort --ignore-case)
echo $DIR/ $MAINTAINERS
done

0 comments on commit 443e89d

Please sign in to comment.