This repository has been archived by the owner on May 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
290 lines (267 loc) · 8.77 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: CI
on:
push:
branches:
- '**'
pull_request:
jobs:
docker-lint:
runs-on: ubuntu-latest
name: DockerLint
steps:
- name: Checkout
uses: actions/checkout@v2
- name: lint
uses: brpaz/hadolint-action@master
# Golang tests
go-lint:
runs-on: ubuntu-latest
name: GoLint
steps:
- uses: actions/checkout@v2
- name: Run golangci-lint
uses: actions-contrib/golangci-lint@v1
with:
golangci_lint_version: 1.23
args: run -v --timeout 300s
# go-dependencies:
# runs-on: ubuntu-latest
# name: Dependencies are up to date
# steps:
# - uses: actions/setup-go@v1
# with:
# go-version: 1.14
# - name: Checkout
# uses: actions/checkout@v2
# - run: go mod tidy
# - run: go mod vendor
# - run: go mod graph
# - run: git status
# - name: Check diff
# run: |
# git diff-index --diff-filter=d --name-only --ignore-cr-at-eol HEAD -- 'vendor'
# test -z "$(git diff-index --diff-filter=d --name-only --ignore-cr-at-eol HEAD -- 'vendor' | grep -v 'vendor/modules.txt')"
# - run: make generate
# - name: Check diff
# run: |
# git restore -- go.mod go.sum
# git diff-index --exit-code --ignore-cr-at-eol HEAD
go-tests:
runs-on: ubuntu-latest
name: go tests
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.14
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: make test
run: |
go env
test -d /usr/local/kubebuilder || (curl -sSL "https://go.kubebuilder.io/dl/2.3.1/$(go env GOOS)/$(go env GOARCH)" | tar -xz -C /tmp/;sudo mv /tmp/kubebuilder_2.3.1_$(go env GOOS)_$(go env GOARCH) /usr/local/kubebuilder)
make test
k8s-tests:
runs-on: ubuntu-latest
name: K8S v${{ matrix.k8sVersion }} (CM v${{ matrix.certManager }})
strategy:
fail-fast: false
matrix:
# https://github.com/jetstack/cert-manager/tags
certManager: ["0.15.2", "0.16.1"]
# https://snapcraft.io/microk8s
k8sVersion: ["1.17", "1.18", "1.19"]
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.14
- name: Install Kubernetes v${{ matrix.k8sVersion }}
run: |
which kind || (curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64; sudo install kind /usr/local/bin/)
test -d /usr/local/kubebuilder || (curl -sSL "https://go.kubebuilder.io/dl/2.3.1/$(go env GOOS)/$(go env GOARCH)" | tar -xz -C /tmp/;sudo mv /tmp/kubebuilder_2.3.1_$(go env GOOS)_$(go env GOARCH) /usr/local/kubebuilder)
cat <<EOF | kind create cluster --name harbor --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
- uses: actions/checkout@v2
- name: Install CertManager v${{ matrix.certManager }}
run: |
# Try the recet way to install crd or fallback to the old one
version='${{ matrix.certManager }}'
kubectl apply -f "https://github.com/jetstack/cert-manager/releases/download/v${version}/cert-manager.yaml"
sleep 5
kubectl -n cert-manager wait --for=condition=Available deployment --all --timeout 300s
- name: Install Ingress
run: |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.35.0/deploy/static/provider/baremetal/deploy.yaml
sleep 5
kubectl -n ingress-nginx wait --for=condition=Available deployment --all --timeout 300s
- name: Install harbor-cluster-operator
run: |
set -xe
make manifests docker-build IMG=harbor-cluster-operator:test
kind load docker-image --name harbor harbor-cluster-operator:test
cd manifests && kustomize edit set image controller=harbor-cluster-operator:test && kustomize build | kubectl apply -f -
sleep 10
if ! kubectl -n harbor-cluster-operator-system wait --for=condition=Available deployment --all --timeout 300s; then
kubectl get all -n harbor-cluster-operator-system
kubectl get all -n harbor-operator-system
exit 1
fi
kubectl get all -n harbor-cluster-operator-system
kubectl get all -n harbor-operator-system
- name: Install harbor
run: |
set -xe
IP=`hostname -I | awk '{print $1}'`
echo "::set-env name=IP::$IP"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: sample
---
# A secret of harbor admin password.
apiVersion: v1
kind: Secret
metadata:
name: admin-secret
namespace: sample
data:
password: SGFyYm9yMTIzNDU=
type: Opaque
---
apiVersion: cert-manager.io/v1alpha2
kind: Issuer
metadata:
name: selfsigned-issuer
namespace: sample
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: public-certificate
namespace: sample
spec:
secretName: public-certificate
dnsNames:
- harbor.${IP}.xip.io
- notary-harbor.${IP}.xip.io
issuerRef:
name: selfsigned-issuer
kind: Issuer
---
apiVersion: goharbor.io/v1alpha1
kind: HarborCluster
metadata:
name: sz-harbor-cluster
namespace: sample
spec:
redis:
kind: "inCluster"
spec:
server:
replicas: 1
resources:
requests:
cpu: "100m"
memory: "300Mi"
storage: "10Gi"
sentinel:
replicas: 1
schema: "redis"
adminPasswordSecret: "admin-secret"
certificateIssuerRef:
name: selfsigned-issuer
tlsSecret: public-certificate
database:
kind: "inCluster"
spec:
replicas: 1
resources:
requests:
cpu: "100m"
memory: "300Mi"
limits:
cpu: "500m"
memory: "500Mi"
publicURL: "https://harbor.${IP}.xip.io"
disableRedirect: true
replicas: 1
notary:
publicUrl: "https://notary-harbor.${IP}.xip.io"
jobService:
workerCount: 10
replicas: 1
chartMuseum:
absoluteURL: true
clair:
updateInterval: 10
vulnerabilitySources:
- ubuntu
- alphine
storage:
kind: "inCluster"
options:
provider: minIO
spec:
replicas: 2
volumesPerServer: 2
version: RELEASE.2020-08-13T02-39-50Z
volumeClaimTemplate:
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
resources:
requests:
memory: 200Mi
cpu: 200m
limits:
memory: 500Mi
cpu: 500m
version: 1.10.4
EOF
free -h
# currently we don't have a good way to wait install done
for i in $(seq 1 6);do
sleep 30
echo $i
kubectl get all -n sample
done
if ! kubectl -n sample wait --for=condition=Ready pod --all --timeout 600s ;then
echo install harbor failed
kubectl get all -n sample
for n in $(kubectl get po -n sample |grep -v Running|grep 'sz-harbor'|awk '{print $1}');do
echo describe $n
kubectl describe pod -n sample $n
done
exit 1
else
kubectl get all -n sample
fi
free -h
if ! kubectl -n sample wait --for=condition=Available deployment/sz-harbor-cluster-harbor-core;then
echo harbor-core not ready
exit 1;
fi
- name: tests
run: |
sudo kubectl port-forward -n ingress-nginx service/ingress-nginx-controller 443:443 --address=0.0.0.0 &
sleep 10
curl -L -k -f -i -o- "https://127.0.0.1/api/systeminfo" -H "Host: harbor.${IP}.xip.io"