-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zhu733756 <[email protected]>
- Loading branch information
Showing
8 changed files
with
279 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
image: kindest/node:v1.21.2 | ||
extraMounts: | ||
- hostPath: /etc/localtime | ||
containerPath: /etc/localtime | ||
# extraPortMappings: | ||
# - containerPort: 19093 | ||
# hostPort: 19093 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
name: Main CI WorkFlow | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'release-*' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- 'master' | ||
- 'release-*' | ||
env: | ||
OP_IMAGE: kubesphere/notification-manager-operator:latest | ||
NM_IMAGE: kubesphere/notification-manager:latest | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
name: Basic test and verify | ||
env: | ||
GO111MODULE: "on" | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install kubebuilder-2.3.2 | ||
run: | | ||
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz" | tar -xz -C /tmp/ | ||
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64 /usr/local/kubebuilder | ||
- name: Run basic test | ||
run: make test | ||
|
||
- name: Run verify crds test | ||
run: make verify | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
name: Binary build | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- run: make binary | ||
name: Run build all binaries | ||
|
||
docker_build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
name: Docker image build | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: build image | ||
run: | | ||
docker build . -t ${{ env.OP_IMAGE }} -f cmd/operator/Dockerfile --build-arg GOPROXY="https://proxy.golang.org" | ||
docker build . -t ${{ env.NM_IMAGE }} -f cmd/notification-manager/Dockerfile --build-arg GOPROXY="https://proxy.golang.org" | ||
helm_deployment: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
name: Install and uninstall notification manager by helm | ||
steps: | ||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.4.0 | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create kind cluster | ||
uses: helm/[email protected] | ||
with: | ||
config: .github/workflows/kind/kind.yaml | ||
|
||
- name: Setting up notification manager | ||
run: | | ||
kubectl create ns kubesphere-monitoring-system | ||
helm install notification-manager ./helm -n kubesphere-monitoring-system | ||
- name: Waiting for 30 seconds to keep the notification manager installed | ||
uses: jakejarvis/wait-action@master | ||
with: | ||
time: '30s' | ||
|
||
- name: Check the related resources | ||
run: | | ||
echo "list release:" | ||
echo "-----" | ||
helm list -n kubesphere-monitoring-system | ||
echo "-----" | ||
echo "list pods:" | ||
echo "-----" | ||
kubectl get pods -n kubesphere-monitoring-system | ||
echo "-----" | ||
- name: Deploy the default SlackConfig and global SlackReceiver | ||
run: | | ||
cat config/ci/slack-pr.yaml | sed -e 's/SLACK_SECRET/${{ secrets.SLACK_SECRET }}/g' | kubectl apply -f - | ||
- name: Expose service port as nodeport | ||
run: | | ||
kubectl -n kubesphere-monitoring-system patch svc notification-manager-svc --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"},{"op":"replace","path":"/spec/ports/0/nodePort","value":30008}]' | ||
- name: Send alerts | ||
run: | | ||
NODE_IP=$(kubectl get nodes -o jsonpath={.items[0].status.addresses[0].address}) | ||
curl -XPOST -d @./config/ci/alerts.json "http://$NODE_IP:30008/api/v2/alerts" | ||
- name: Waiting for 2 seconds | ||
uses: jakejarvis/wait-action@master | ||
with: | ||
time: '2s' | ||
|
||
- name: Check the related logs | ||
run: | | ||
kubectl -n kubesphere-monitoring-system logs -l app=notification-manager | ||
- name: Uninstall notification manager | ||
run: | | ||
helm uninstall notification-manager -n kubesphere-monitoring-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"receiver": "Default", | ||
"status": "firing", | ||
"alerts": [ | ||
{ | ||
"status": "firing", | ||
"labels": { | ||
"alertname": "PullRequestNotification", | ||
"container": "pull-request-notification", | ||
"namespace": "kubsphere-monitoring-system", | ||
"pod": "pull-request-notification-67f5689d7-sqg89", | ||
"prometheus": "kubesphere-monitoring-system/k8s", | ||
"severity": "warning" | ||
}, | ||
"annotations": { | ||
"message": "Congratulations! Pull request notification triggered, your pr has passed the helm deployment test.", | ||
"runbook_url": "" | ||
}, | ||
"startsAt": "2021-10-21T05:45:44.782098546Z", | ||
"endsAt": "0001-01-01T00:00:00Z", | ||
"generatorURL": "", | ||
"fingerprint": "83fb3d34d52108b0" | ||
} | ||
], | ||
"groupLabels": { | ||
"alertname": "PullRequestTest", | ||
"namespace": "kubesphere-monitoring-system" | ||
}, | ||
"commonLabels": { | ||
"alertname": "PullRequestTest", | ||
"namespace": "kubesphere-monitoring-system", | ||
"prometheus": "kubesphere-monitoring-system/k8s", | ||
"severity": "warning" | ||
}, | ||
"commonAnnotations": { | ||
"runbook_url": "" | ||
}, | ||
"externalURL": "http://alertmanager-main-1:9093" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: notification.kubesphere.io/v2beta2 | ||
kind: Config | ||
metadata: | ||
name: default-slack-config | ||
labels: | ||
app: notification-manager | ||
type: default | ||
spec: | ||
slack: | ||
slackTokenSecret: | ||
valueFrom: | ||
secretKeyRef: | ||
namespace: kubesphere-monitoring-system | ||
key: token | ||
name: slack-token-secret | ||
--- | ||
apiVersion: notification.kubesphere.io/v2beta2 | ||
kind: Receiver | ||
metadata: | ||
name: global-slack-receiver | ||
labels: | ||
app: notification-manager | ||
type: global | ||
spec: | ||
slack: | ||
channels: | ||
- sig-observability | ||
--- | ||
apiVersion: v1 | ||
data: | ||
token: SLACK_SECRET | ||
kind: Secret | ||
metadata: | ||
labels: | ||
app: notification-manager | ||
name: slack-token-secret | ||
namespace: kubesphere-monitoring-system | ||
type: Opaque |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters