Skip to content

Commit cb652f3

Browse files
committed
Test Strategic Merge and JSON 6902 patches
Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent f2bb23d commit cb652f3

3 files changed

Lines changed: 64 additions & 8 deletions

File tree

.github/workflows/e2e.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,21 @@ jobs:
8282
kubectl -n impersonation wait kustomizations/podinfo --for=condition=ready --timeout=4m
8383
kubectl -n impersonation delete kustomizations/podinfo
8484
until kubectl -n impersonation get deploy/podinfo 2>&1 | grep NotFound ; do sleep 2; done
85-
- name: Run image overide tests
85+
- name: Run images override tests
8686
run: |
87-
kubectl -n override-test apply -f ./config/testdata/overrides
88-
kubectl -n override-test wait kustomizations/podinfo --for=condition=ready --timeout=1m
89-
ACTUAL_TAG=$(kubectl -n override-test get deployments podinfo -o jsonpath='{.spec.template.spec.containers[0].image}' | cut -f2 -d ":")
87+
kubectl -n images-test apply -f ./config/testdata/overrides/images.yaml
88+
kubectl -n images-test wait kustomizations/podinfo --for=condition=ready --timeout=1m
89+
ACTUAL_TAG=$(kubectl -n images-test get deployments podinfo -o jsonpath='{.spec.template.spec.containers[0].image}' | cut -f2 -d ":")
9090
if [[ $ACTUAL_TAG != "5.0.0" ]]; then echo "Image tag did not override" && exit 1; fi
91+
- name: Run patches override tests
92+
run: |
93+
kubectl -n patches-test apply -f ./config/testdata/overrides/patches.yaml
94+
kubectl -n patches-test wait kustomizations/podinfo --for=condition=ready --timeout=1m
95+
RESULT=$(kubectl -n patches-test get deployment mypodinfo -o jsonpath='{.metadata.labels.yyyy}')
96+
if [ "$RESULT" != "xxxx" ]; then
97+
echo -e "$RESULT\n\ndoes not equal\n\nxxxx"
98+
exit 1
99+
fi
91100
- name: Logs
92101
run: |
93102
kubectl -n kustomize-system logs deploy/source-controller
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
apiVersion: v1
22
kind: Namespace
33
metadata:
4-
name: override-test
4+
name: images-test
55
---
66
apiVersion: source.toolkit.fluxcd.io/v1beta1
77
kind: GitRepository
88
metadata:
99
name: podinfo
10-
namespace: override-test
10+
namespace: images-test
1111
spec:
1212
interval: 5m
1313
url: https://github.com/stefanprodan/podinfo
@@ -18,9 +18,9 @@ apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
1818
kind: Kustomization
1919
metadata:
2020
name: podinfo
21-
namespace: override-test
21+
namespace: images-test
2222
spec:
23-
targetNamespace: override-test
23+
targetNamespace: images-test
2424
interval: 5m
2525
path: "./kustomize"
2626
prune: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: patches-test
5+
---
6+
apiVersion: source.toolkit.fluxcd.io/v1beta1
7+
kind: GitRepository
8+
metadata:
9+
name: podinfo
10+
namespace: patches-test
11+
spec:
12+
interval: 5m
13+
url: https://github.com/stefanprodan/podinfo
14+
ref:
15+
branch: master
16+
---
17+
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
18+
kind: Kustomization
19+
metadata:
20+
name: podinfo
21+
namespace: patches-test
22+
spec:
23+
targetNamespace: patches-test
24+
interval: 5m
25+
path: "./kustomize"
26+
prune: true
27+
sourceRef:
28+
kind: GitRepository
29+
name: podinfo
30+
validation: client
31+
patchesStrategicMerge:
32+
- kind: Deployment
33+
apiVersion: apps/v1
34+
metadata:
35+
name: mypodinfo
36+
labels:
37+
xxxx: yyyy
38+
patchesJson6902:
39+
- target:
40+
group: apps
41+
version: v1
42+
kind: Deployment
43+
name: mypodinfo
44+
patch:
45+
- op: add
46+
path: /metadata/labels/yyyy
47+
value: xxxx

0 commit comments

Comments
 (0)