Skip to content

Commit 9061c02

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 0faed40 commit 9061c02

File tree

9 files changed

+101
-113
lines changed

9 files changed

+101
-113
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/generate_certs.yaml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
apiVersion: apps/v1
2-
kind: Deployment
3-
metadata:
4-
name: coil-egress-controller
5-
namespace: system
6-
spec:
7-
template:
8-
spec:
9-
containers:
10-
- name: coil-egress-controller
11-
args:
12-
- --zap-stacktrace-level=panic
13-
- --enable-cert-rotation=true
14-
15-
---
16-
17-
apiVersion: apps/v1
18-
kind: Deployment
19-
metadata:
20-
name: coil-ipam-controller
21-
namespace: system
22-
spec:
23-
template:
24-
spec:
25-
containers:
26-
- name: coil-ipam-controller
27-
args:
28-
- --zap-stacktrace-level=panic
29-
- --enable-cert-rotation=true
1+
- op: add
2+
path: /spec/template/spec/containers/0/args/-
3+
value: --enable-cert-rotation=true

v2/config/rbac/generate_certs.yaml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,55 +24,3 @@
2424
- list
2525
- update
2626
- watch
27-
28-
# apiVersion: rbac.authorization.k8s.io/v1
29-
# kind: ClusterRole
30-
# metadata:
31-
# name: coil-egress-controller
32-
# rules:
33-
# - apiGroups:
34-
# - ""
35-
# resources:
36-
# - secrets
37-
# verbs:
38-
# - get
39-
# - list
40-
# - update
41-
# - watch
42-
# - apiGroups:
43-
# - admissionregistration.k8s.io
44-
# resources:
45-
# - mutatingwebhookconfigurations
46-
# - validatingwebhookconfigurations
47-
# verbs:
48-
# - get
49-
# - list
50-
# - update
51-
# - watch
52-
53-
# ---
54-
55-
# apiVersion: rbac.authorization.k8s.io/v1
56-
# kind: ClusterRole
57-
# metadata:
58-
# name: coil-ipam-controller
59-
# rules:
60-
# - apiGroups:
61-
# - ""
62-
# resources:
63-
# - secrets
64-
# verbs:
65-
# - get
66-
# - list
67-
# - update
68-
# - watch
69-
# - apiGroups:
70-
# - admissionregistration.k8s.io
71-
# resources:
72-
# - mutatingwebhookconfigurations
73-
# - validatingwebhookconfigurations
74-
# verbs:
75-
# - get
76-
# - list
77-
# - update
78-
# - 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-egress-controller_patch.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

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"

v2/e2e/kustomization.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,33 @@ resources:
44

55
patchesStrategicMerge:
66
- coil-ipam-controller_patch.yaml
7-
# [CERTS] Following line should be uncommented if automatic cert generation is used.
8-
# - coil-egress-controller_patch.yaml
97

10-
# [CERTS] Following patchesJson6902 should be uncommented if automatic cert generation is used.
11-
# patchesJson6902:
12-
# - target:
8+
# [CERTS] Following patches should be uncommented if automatic cert generation is used.
9+
# patches:
10+
# - path: ../config/pod/generate_certs.yaml
11+
# target:
12+
# group: apps
13+
# version: v1
14+
# kind: Deployment
15+
# name: coil-ipam-controller
16+
# - path: ../config/pod/generate_certs.yaml
17+
# target:
18+
# group: apps
19+
# version: v1
20+
# kind: Deployment
21+
# name: coil-egress-controller
22+
# - path: ../config/rbac/generate_certs.yaml
23+
# target:
1324
# group: rbac.authorization.k8s.io
1425
# version: v1
1526
# kind: ClusterRole
1627
# name: coil-ipam-controller
17-
# path: ../config/rbac/generate_certs.yaml
18-
# - target:
28+
# - path: ../config/rbac/generate_certs.yaml
29+
# target:
1930
# group: rbac.authorization.k8s.io
2031
# version: v1
2132
# kind: ClusterRole
2233
# name: coil-egress-controller
23-
# path: ../config/rbac/generate_certs.yaml
2434

2535
configMapGenerator:
2636
- name: coil-config

v2/kustomization.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,33 @@ resources:
1818
patchesStrategicMerge:
1919
# Uncomment the following if you want to run Coil with Calico network policy.
2020
# - config/pod/compat_calico.yaml
21-
# [CERTS] Following line should be uncommented if automatic cert generation is used.
22-
# - config/pod/generate_certs.yaml
2321

24-
# [CERTS] Following patchesJson6902 should be uncommented if automatic cert generation is used.
25-
# patchesJson6902:
26-
# - target:
22+
# [CERTS] Following patches should be uncommented if automatic cert generation is used.
23+
# patches:
24+
# - path: config/pod/generate_certs.yaml
25+
# target:
26+
# group: apps
27+
# version: v1
28+
# kind: Deployment
29+
# name: coil-ipam-controller
30+
# - path: config/pod/generate_certs.yaml
31+
# target:
32+
# group: apps
33+
# version: v1
34+
# kind: Deployment
35+
# name: coil-egress-controller
36+
# - path: config/rbac/generate_certs.yaml
37+
# target:
2738
# group: rbac.authorization.k8s.io
2839
# version: v1
2940
# kind: ClusterRole
3041
# name: coil-ipam-controller
31-
# path: config/rbac/generate_certs.yaml
32-
# - target:
42+
# - path: config/rbac/generate_certs.yaml
43+
# target:
3344
# group: rbac.authorization.k8s.io
3445
# version: v1
3546
# kind: ClusterRole
3647
# name: coil-egress-controller
37-
# path: config/rbac/generate_certs.yaml
3848

3949
# Edit netconf.json to customize CNI configurations
4050
configMapGenerator:

0 commit comments

Comments
 (0)