Skip to content

Commit 9b0bf95

Browse files
author
Gunther Klessinger
committed
1 parent e3f211e commit 9b0bf95

28 files changed

+505
-0
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 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@v3
15+
- name: Setup Flux
16+
uses: fluxcd/flux2/action@main
17+
- name: Setup Kubernetes
18+
uses: helm/[email protected]
19+
with:
20+
cluster_name: flux
21+
- name: Install Flux in Kubernetes Kind
22+
run: flux install
23+
- name: Setup cluster reconciliation
24+
run: |
25+
flux create source git flux-system \
26+
--url=${{ github.event.repository.html_url }} \
27+
--branch=${GITHUB_REF#refs/heads/} \
28+
--username=${GITHUB_ACTOR} \
29+
--password=${{ secrets.GITHUB_TOKEN }} \
30+
--ignore-paths="clusters/**/flux-system/"
31+
flux create kustomization flux-system \
32+
--source=flux-system \
33+
--path=./clusters/staging
34+
- name: Verify cluster reconciliation
35+
run: |
36+
kubectl -n flux-system wait kustomization/infra-controllers --for=condition=ready --timeout=5m
37+
kubectl -n flux-system wait kustomization/apps --for=condition=ready --timeout=5m
38+
- name: Verify helm reconciliation
39+
run: |
40+
kubectl -n podinfo wait helmrelease/podinfo --for=condition=ready --timeout=5m
41+
- name: Debug failure
42+
if: failure()
43+
run: |
44+
kubectl -n flux-system get all
45+
kubectl -n flux-system logs deploy/source-controller
46+
kubectl -n flux-system logs deploy/kustomize-controller
47+
kubectl -n flux-system logs deploy/helm-controller
48+
flux get all --all-namespaces
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: [ '*' ]
8+
tags-ignore: [ '*' ]
9+
10+
jobs:
11+
manifests:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Setup yq
17+
uses: fluxcd/pkg/actions/yq@main
18+
- name: Setup kubeconform
19+
uses: fluxcd/pkg/actions/kubeconform@main
20+
- name: Setup kustomize
21+
uses: fluxcd/pkg/actions/kustomize@main
22+
- name: Validate manifests
23+
run: ./scripts/validate.sh

tmp/tmpl.git/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GitHub actions binaries
2+
bin/

tmp/tmpl.git/.sourceignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Flux ignore
2+
# https://fluxcd.io/flux/components/source/gitrepositories/#excluding-files
3+
4+
# Exclude all
5+
/*
6+
7+
# Include manifest directories
8+
!/apps/
9+
!/clusters/
10+
!/infrastructure/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: podinfo
4+
resources:
5+
- namespace.yaml
6+
- repository.yaml
7+
- release.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: podinfo
5+
labels:
6+
toolkit.fluxcd.io/tenant: dev-team
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: helm.toolkit.fluxcd.io/v2
2+
kind: HelmRelease
3+
metadata:
4+
name: podinfo
5+
namespace: podinfo
6+
spec:
7+
releaseName: podinfo
8+
chart:
9+
spec:
10+
chart: podinfo
11+
sourceRef:
12+
kind: HelmRepository
13+
name: podinfo
14+
interval: 50m
15+
install:
16+
remediation:
17+
retries: 3
18+
# Default values
19+
# https://github.com/stefanprodan/podinfo/blob/master/charts/podinfo/values.yaml
20+
values:
21+
redis:
22+
enabled: true
23+
repository: public.ecr.aws/docker/library/redis
24+
tag: 7.0.6
25+
ingress:
26+
enabled: true
27+
className: nginx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: source.toolkit.fluxcd.io/v1
2+
kind: HelmRepository
3+
metadata:
4+
name: podinfo
5+
namespace: podinfo
6+
spec:
7+
interval: 5m
8+
url: https://stefanprodan.github.io/podinfo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ../base/podinfo
5+
patches:
6+
- path: podinfo-values.yaml
7+
target:
8+
kind: HelmRelease
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: helm.toolkit.fluxcd.io/v2
2+
kind: HelmRelease
3+
metadata:
4+
name: podinfo
5+
namespace: podinfo
6+
spec:
7+
chart:
8+
spec:
9+
version: ">=1.0.0"
10+
values:
11+
ingress:
12+
hosts:
13+
- host: podinfo.production
14+
paths:
15+
- path: /
16+
pathType: ImplementationSpecific
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: podinfo
4+
resources:
5+
- ../base/podinfo
6+
patches:
7+
- path: podinfo-values.yaml
8+
target:
9+
kind: HelmRelease
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: helm.toolkit.fluxcd.io/v2
2+
kind: HelmRelease
3+
metadata:
4+
name: podinfo
5+
namespace: podinfo
6+
spec:
7+
chart:
8+
spec:
9+
version: ">=1.0.0-alpha"
10+
test:
11+
enable: false
12+
values:
13+
ingress:
14+
hosts:
15+
- host: podinfo.staging
16+
paths:
17+
- path: /
18+
pathType: ImplementationSpecific
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: kustomize.toolkit.fluxcd.io/v1
3+
kind: Kustomization
4+
metadata:
5+
name: apps
6+
namespace: flux-system
7+
spec:
8+
interval: 10m0s
9+
dependsOn:
10+
- name: infra-configs
11+
sourceRef:
12+
kind: GitRepository
13+
name: flux-system
14+
path: ./apps/production
15+
prune: true
16+
wait: true
17+
timeout: 5m0s
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file will be generated automatically by flux boostrap.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file will be generated automatically by flux boostrap.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- gotk-components.yaml
5+
- gotk-sync.yaml
6+
labels:
7+
- pairs:
8+
toolkit.fluxcd.io/tenant: sre-team
9+
patches:
10+
- patch: |
11+
- op: add
12+
path: /spec/template/spec/containers/0/args/-
13+
value: --concurrent=20
14+
- op: add
15+
path: /spec/template/spec/containers/0/args/-
16+
value: --requeue-dependency=5s
17+
target:
18+
kind: Deployment
19+
name: "(kustomize-controller|helm-controller|source-controller)"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
apiVersion: kustomize.toolkit.fluxcd.io/v1
3+
kind: Kustomization
4+
metadata:
5+
name: infra-controllers
6+
namespace: flux-system
7+
spec:
8+
interval: 1h
9+
retryInterval: 1m
10+
timeout: 5m
11+
sourceRef:
12+
kind: GitRepository
13+
name: flux-system
14+
path: ./infrastructure/controllers
15+
prune: true
16+
wait: true
17+
---
18+
apiVersion: kustomize.toolkit.fluxcd.io/v1
19+
kind: Kustomization
20+
metadata:
21+
name: infra-configs
22+
namespace: flux-system
23+
spec:
24+
dependsOn:
25+
- name: infra-controllers
26+
interval: 1h
27+
retryInterval: 1m
28+
timeout: 5m
29+
sourceRef:
30+
kind: GitRepository
31+
name: flux-system
32+
path: ./infrastructure/configs
33+
prune: true
34+
patches:
35+
- patch: |
36+
- op: replace
37+
path: /spec/acme/server
38+
value: https://acme-v02.api.letsencrypt.org/directory
39+
target:
40+
kind: ClusterIssuer
41+
name: letsencrypt
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: kustomize.toolkit.fluxcd.io/v1
2+
kind: Kustomization
3+
metadata:
4+
name: apps
5+
namespace: flux-system
6+
spec:
7+
interval: 10m0s
8+
dependsOn:
9+
- name: infra-configs
10+
sourceRef:
11+
kind: GitRepository
12+
name: flux-system
13+
path: ./apps/staging
14+
prune: true
15+
wait: true
16+
timeout: 5m0s
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file will be generated automatically by flux boostrap.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file will be generated automatically by flux boostrap.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- gotk-components.yaml
5+
- gotk-sync.yaml
6+
labels:
7+
- pairs:
8+
toolkit.fluxcd.io/tenant: sre-team
9+
patches:
10+
- patch: |
11+
- op: add
12+
path: /spec/template/spec/containers/0/args/-
13+
value: --concurrent=20
14+
- op: add
15+
path: /spec/template/spec/containers/0/args/-
16+
value: --requeue-dependency=5s
17+
target:
18+
kind: Deployment
19+
name: "(kustomize-controller|helm-controller|source-controller)"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
apiVersion: kustomize.toolkit.fluxcd.io/v1
3+
kind: Kustomization
4+
metadata:
5+
name: infra-controllers
6+
namespace: flux-system
7+
spec:
8+
interval: 1h
9+
retryInterval: 1m
10+
timeout: 5m
11+
sourceRef:
12+
kind: GitRepository
13+
name: flux-system
14+
path: ./infrastructure/controllers
15+
prune: true
16+
wait: true
17+
---
18+
apiVersion: kustomize.toolkit.fluxcd.io/v1
19+
kind: Kustomization
20+
metadata:
21+
name: infra-configs
22+
namespace: flux-system
23+
spec:
24+
dependsOn:
25+
- name: infra-controllers
26+
interval: 1h
27+
retryInterval: 1m
28+
timeout: 5m
29+
sourceRef:
30+
kind: GitRepository
31+
name: flux-system
32+
path: ./infrastructure/configs
33+
prune: true
34+
patches:
35+
- patch: |
36+
- op: replace
37+
path: /spec/acme/server
38+
value: https://acme-staging-v02.api.letsencrypt.org/directory
39+
target:
40+
kind: ClusterIssuer
41+
name: letsencrypt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: cert-manager.io/v1
3+
kind: ClusterIssuer
4+
metadata:
5+
name: letsencrypt
6+
spec:
7+
acme:
8+
# Replace the email address with your own contact email
9+
10+
# The server is replaced in /clusters/production/infrastructure.yaml
11+
server: https://acme-staging-v02.api.letsencrypt.org/directory
12+
privateKeySecretRef:
13+
name: letsencrypt-nginx
14+
solvers:
15+
- http01:
16+
ingress:
17+
class: nginx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- cluster-issuers.yaml

0 commit comments

Comments
 (0)