Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 30081ad

Browse files
authored
Merge pull request #1 from fluxcd-community/flux-e2e-tests
Add end-to-end tests
2 parents 9fb2ef9 + eb56c11 commit 30081ad

File tree

2 files changed

+119
-2
lines changed

2 files changed

+119
-2
lines changed

.github/workflows/flux-e2e.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: flux-e2e
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ '*' ]
7+
tags-ignore: [ '*' ]
8+
9+
jobs:
10+
kubernetes:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Setup Flux
16+
uses: fluxcd/flux2/action@main
17+
- name: Setup Kubernetes
18+
uses: engineerd/[email protected]
19+
with:
20+
version: v0.14.0
21+
- name: Install Flux in Kubernetes Kind
22+
run: flux install
23+
- name: Setup cluster reconciliation
24+
run: |
25+
kubectl apply -f - <<EOF > cat
26+
---
27+
apiVersion: v1
28+
kind: Namespace
29+
metadata:
30+
name: msdemo
31+
annotations:
32+
config.linkerd.io/proxy-await: enabled
33+
linkerd.io/inject: enabled
34+
---
35+
apiVersion: source.toolkit.fluxcd.io/v1beta2
36+
kind: GitRepository
37+
metadata:
38+
name: msdemo
39+
namespace: msdemo
40+
spec:
41+
interval: 15m
42+
ref:
43+
branch: ${GITHUB_REF#refs/heads/}
44+
url: ${{ github.event.repository.html_url }}
45+
ignore: |
46+
/clusters/**/flux-system/
47+
---
48+
apiVersion: v1
49+
kind: ServiceAccount
50+
metadata:
51+
labels:
52+
toolkit.fluxcd.io/tenant: msdemo
53+
name: flux
54+
namespace: msdemo
55+
---
56+
apiVersion: rbac.authorization.k8s.io/v1
57+
kind: RoleBinding
58+
metadata:
59+
labels:
60+
toolkit.fluxcd.io/tenant: msdemo
61+
name: flux
62+
namespace: msdemo
63+
roleRef:
64+
apiGroup: rbac.authorization.k8s.io
65+
kind: ClusterRole
66+
name: cluster-admin
67+
subjects:
68+
- kind: ServiceAccount
69+
name: flux
70+
namespace: msdemo
71+
---
72+
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
73+
kind: Kustomization
74+
metadata:
75+
name: msdemo
76+
namespace: msdemo
77+
spec:
78+
targetNamespace: msdemo
79+
interval: 60m0s
80+
retryInterval: 1m30s
81+
path: ./deploy
82+
prune: true
83+
wait: true
84+
timeout: 3m
85+
serviceAccountName: flux
86+
sourceRef:
87+
kind: GitRepository
88+
name: msdemo
89+
postBuild:
90+
substitute:
91+
app_namespace: msdemo
92+
patches:
93+
- target:
94+
kind: Kustomization
95+
patch: |
96+
- op: add
97+
path: /spec/serviceAccountName
98+
value: flux
99+
EOF
100+
- name: Wait for msdemo reconciliation
101+
run: |
102+
kubectl -n msdemo wait gitrepository/msdemo --for=condition=ready --timeout=1m
103+
kubectl -n msdemo wait kustomization/msdemo --for=condition=ready --timeout=3m
104+
- name: Flux status
105+
run: |
106+
flux -n msdemo get all
107+
- name: Debug failure
108+
if: failure()
109+
run: |
110+
flux get all --all-namespaces
111+
kubectl -n msdemo get all
112+
kubectl -n flux-system logs deploy/source-controller
113+
kubectl -n flux-system logs deploy/kustomize-controller

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# microservices-demo
22

3+
[![flux-e2e](https://github.com/fluxcd-community/microservices-demo/workflows/flux-e2e/badge.svg)](https://github.com/fluxcd-community/microservices-demo/actions)
4+
[![license](https://img.shields.io/github/license/fluxcd-community/microservices-demo.svg)](https://github.com/fluxcd-community/microservices-demo/blob/main/LICENSE)
5+
36
Microservices demo made with
47
[podinfo](https://github.com/stefanprodan/podinfo),
58
managed by [flux](https://github.com/fluxcd/flux2)
@@ -92,7 +95,7 @@ spec:
9295
path: ./deploy
9396
prune: true
9497
wait: true
95-
timeout: 2m
98+
timeout: 3m
9699
serviceAccountName: flux
97100
sourceRef:
98101
kind: GitRepository
@@ -110,7 +113,8 @@ spec:
110113
```
111114
112115
Note that the above configuration is compatible with Flux
113-
[multi-tenancy lockdown mode](https://fluxcd.io/docs/installation/#multi-tenancy-lockdown).
116+
[multi-tenancy lockdown mode](https://fluxcd.io/docs/installation/#multi-tenancy-lockdown)
117+
and is being tested in GitHub Actions by the [flux-e2e workflow](.github/workflows/flux-e2e.yaml).
114118
115119
To spin up multiple stacks, make a copy the above file, replace `msdemo` with `msdemo1` in
116120
the multi-doc YAML and add it to your repository.

0 commit comments

Comments
 (0)