Skip to content

Commit 2efc178

Browse files
Added tests with auto-generated certs to the CI
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
1 parent f120ac3 commit 2efc178

12 files changed

+146
-46
lines changed

.github/workflows/ci.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,32 @@ jobs:
8989
with:
9090
name: logs-ipv6-${{ matrix.ipv6 }}-with-ipam-${{ matrix.with-ipam }}-${{ matrix.kindest-node }}.tar.gz
9191
path: v2/e2e/logs.tar.gz
92+
certs-generation:
93+
name: Cert generation test
94+
strategy:
95+
matrix:
96+
kindest-node: ["1.29.12", "1.30.8", "1.31.4"]
97+
runs-on: ubuntu-24.04
98+
steps:
99+
- uses: actions/checkout@v4
100+
- uses: actions/setup-go@v5
101+
with:
102+
go-version: ${{ env.go-version }}
103+
cache-dependency-path: "**/go.sum"
104+
- run: make image
105+
- run: make enable-certs-generation
106+
working-directory: v2/e2e
107+
- run: make start KUBERNETES_VERSION=${{ matrix.kindest-node }}
108+
working-directory: v2/e2e
109+
- run: make install-coil
110+
working-directory: v2/e2e
111+
- run: make test
112+
working-directory: v2/e2e
113+
- run: make logs
114+
working-directory: v2/e2e
115+
if: always()
116+
- uses: actions/upload-artifact@v4
117+
if: always()
118+
with:
119+
name: logs-cert-generation-${{ matrix.kindest-node }}.tar.gz
120+
path: v2/e2e/logs.tar.gz

v2/Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ check-generate:
7575
$(MAKE) generate
7676
$(MAKE) manifests
7777
go mod tidy
78-
git diff --exit-code
78+
git diff --exit-code -- ':!config/rbac/coil-egress-controller_role.yaml' ':!config/rbac/coil-ipam-controller_role.yaml'
7979

8080
# Generate manifests e.g. CRD, RBAC etc.
8181
.PHONY: manifests
@@ -263,3 +263,19 @@ staticcheck:
263263
if ! which staticcheck >/dev/null; then \
264264
env GOFLAGS= go install honnef.co/go/tools/cmd/staticcheck@latest; \
265265
fi
266+
267+
define comment_certs
268+
$(eval $@_FILE = $(1))
269+
sed -i -E "{s/(^patchesStrategicMerge.*)/# \1/}" ${$@_FILE}
270+
sed -i -E "{s/(.*webhook_manifests_patch.*)/# \1/}" ${$@_FILE}
271+
sed -i -E "{s/(.*files.*)/# \1/g}" ${$@_FILE}
272+
sed -i -E "{s/(.*\.pem.*)/# \1/g}" ${$@_FILE}
273+
sed -i -E "{s/(.*\/tls.*)/# \1/g}" ${$@_FILE}
274+
endef
275+
276+
.PHONY: enable-certs-generation
277+
enable-certs-generation:
278+
sed -i "22,47 {s/^# //}" kustomization.yaml
279+
@$(call comment_certs,"config/default/kustomization.yaml")
280+
@$(call comment_certs,"config/default/egress/v4/kustomization.yaml")
281+
@$(call comment_certs,"config/default/egress/v6/kustomization.yaml")

v2/config/pod/coil-egress-controller.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ spec:
4646
command: ["coil-egress-controller"]
4747
args:
4848
- --zap-stacktrace-level=panic
49-
# [CERTS] Following line should be uncommented if automatic cert generation is used.
50-
# - --enable-cert-rotation=true
5149
env:
5250
- name: "COIL_POD_NAMESPACE"
5351
valueFrom:

v2/config/pod/coil-ipam-controller.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ spec:
4646
command: ["coil-ipam-controller"]
4747
args:
4848
- --zap-stacktrace-level=panic
49-
# [CERTS] Following line should be uncommented if automatic cert generation is used.
50-
# - --enable-cert-rotation=true
5149
env:
5250
- name: "COIL_POD_NAMESPACE"
5351
valueFrom:

v2/config/pod/generate_certs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- op: add
2+
path: /spec/template/spec/containers/0/args/-
3+
value: --enable-cert-rotation=true

v2/config/rbac/coil-egress-controller_role.yaml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ rules:
1212
- get
1313
- list
1414
- watch
15-
- apiGroups:
16-
- ""
17-
resources:
18-
- secrets
19-
verbs:
20-
- get
21-
- list
22-
- update
23-
- watch
2415
- apiGroups:
2516
- ""
2617
resources:
@@ -33,16 +24,6 @@ rules:
3324
- patch
3425
- update
3526
- watch
36-
- apiGroups:
37-
- admissionregistration.k8s.io
38-
resources:
39-
- mutatingwebhookconfigurations
40-
- validatingwebhookconfigurations
41-
verbs:
42-
- get
43-
- list
44-
- update
45-
- watch
4627
- apiGroups:
4728
- apps
4829
resources:

v2/config/rbac/coil-ipam-controller_role.yaml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,6 @@ rules:
1111
verbs:
1212
- get
1313
- list
14-
- apiGroups:
15-
- ""
16-
resources:
17-
- secrets
18-
verbs:
19-
- get
20-
- list
21-
- update
22-
- watch
23-
- apiGroups:
24-
- admissionregistration.k8s.io
25-
resources:
26-
- mutatingwebhookconfigurations
27-
- validatingwebhookconfigurations
28-
verbs:
29-
- get
30-
- list
31-
- update
32-
- watch
3314
- apiGroups:
3415
- coil.cybozu.com
3516
resources:

v2/config/rbac/generate_certs.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- op: add
2+
path: /rules/0
3+
value:
4+
apiGroups:
5+
- ""
6+
resources:
7+
- secrets
8+
verbs:
9+
- get
10+
- list
11+
- update
12+
- watch
13+
14+
- op: add
15+
path: /rules/0
16+
value:
17+
apiGroups:
18+
- admissionregistration.k8s.io
19+
resources:
20+
- mutatingwebhookconfigurations
21+
- validatingwebhookconfigurations
22+
verbs:
23+
- get
24+
- list
25+
- update
26+
- watch

v2/e2e/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ logs:
102102
tar czf logs.tar.gz logs
103103
rm -rf logs
104104

105+
define comment_certs
106+
$(eval $@_FILE = $(1))
107+
sed -i -E "{s/(^patchesStrategicMerge.*)/# \1/}" ${$@_FILE}
108+
sed -i -E "{s/(.*webhook_manifests_patch.*)/# \1/}" ${$@_FILE}
109+
sed -i -E "{s/(.*files.*)/# \1/g}" ${$@_FILE}
110+
sed -i -E "{s/(.*\.pem.*)/# \1/g}" ${$@_FILE}
111+
sed -i -E "{s/(.*\/tls.*)/# \1/g}" ${$@_FILE}
112+
endef
113+
114+
.PHONY: enable-certs-generation
115+
enable-certs-generation:
116+
sed -i "9,33 {s/^# //}" kustomization.yaml
117+
@$(call comment_certs,"../config/default/kustomization.yaml")
118+
@$(call comment_certs,"../config/default/egress/v4/kustomization.yaml")
119+
@$(call comment_certs,"../config/default/egress/v6/kustomization.yaml")
120+
105121
$(KIND):
106122
mkdir -p $(dir $@)
107123
curl -sfL -o $@ https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-linux-amd64

v2/e2e/coil-ipam-controller_patch.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ spec:
1010
- name: coil-ipam-controller
1111
args:
1212
- "--gc-interval=10s"
13-
# [CERTS] Following line should be uncommented if automatic cert generation is used.
14-
# - "--enable-cert-rotation=true"

0 commit comments

Comments
 (0)