File tree Expand file tree Collapse file tree 4 files changed +66
-5
lines changed
Expand file tree Collapse file tree 4 files changed +66
-5
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -x
4+
5+ DIR=$1
6+ kubectl kustomize " ${DIR} " | kube-score score - --ignore-test pod-networkpolicy -o ci | grep -v OK
Original file line number Diff line number Diff line change 1+ name : kube-score
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - " k8s/**/*.yaml"
7+
8+ jobs :
9+ kube-score :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v2
13+
14+ - name : Set up kubectl command
15+ run : |
16+ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.21.0/bin/linux/amd64/kubectl
17+ chmod +x ./kubectl
18+ sudo mv ./kubectl /usr/local/bin/kubectl
19+ kubectl version --client
20+
21+ - name : Set up kube score command
22+ run : |
23+ wget https://github.com/zegl/kube-score/releases/download/v1.11.0/kube-score_1.11.0_linux_amd64.tar.gz
24+ tar xvzf kube-score_1.11.0_linux_amd64.tar.gz
25+ chmod +x ./kube-score
26+ sudo mv ./kube-score /usr/local/bin/kube-score
27+ kube-score version
28+
29+ - name : Perform static check
30+ run : |
31+ touch check-result.txt
32+ TARGET_DIRS=$(find . | grep ".overlays/.*/kustomization.yaml" | sed 's%kustomization.yaml%%')
33+ for DIR in $TARGET_DIRS; do
34+ echo "Check Kubernetes resources in" $DIR
35+ bash ./.github/actions/calculate-kube-scores.sh $DIR >> check-result.txt
36+ done;
37+
38+ - name : Show check result
39+ run : |
40+ TOTAL_CRITICAL_ISSUE_NUM=$(cat check-result.txt | grep CRITICAL | wc -l)
41+ echo "TOTAL_CRITICAL_ISSUE_NUM:" $TOTAL_CRITICAL_ISSUE_NUM
42+ if [[ "$TOTAL_CRITICAL_ISSUE_NUM" != 0 ]]; then
43+ cat check-result.txt
44+ exit 1
45+ fi
Original file line number Diff line number Diff line change @@ -5,10 +5,15 @@ metadata:
55 labels :
66 app : fastapi
77spec :
8- replicas : 3
8+ replicas : 1
99 selector :
1010 matchLabels :
1111 app : fastapi
12+ strategy :
13+ rollingUpdate :
14+ maxSurge : 0
15+ maxUnavailable : 1
16+ type : RollingUpdate
1217 template :
1318 metadata :
1419 labels :
Original file line number Diff line number Diff line change 11namespace : api-app
2+
23bases :
34 - ../../base
5+
46patchesStrategicMerge :
57 - deployment.yaml
8+
69configMapGenerator :
710 - name : fastapi-configmap
811 literals :
9- - MYSQL_HOST=mysql-0.mysql-headless.database.svc.cluster.local
10- - MYSQL_USER=root
11- - MYSQL_DATABASE=test
12+ - MYSQL_HOST=mysql-0.mysql-headless.database.svc.cluster.local
13+ - MYSQL_USER=root
14+ - MYSQL_DATABASE=test
15+
1216resources :
13- - secret.yaml
17+ - secret.yaml
18+ - network-policy.yaml
You can’t perform that action at this time.
0 commit comments