Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #279

Merged
merged 15 commits into from
Jul 25, 2023
5 changes: 5 additions & 0 deletions .github/scripts/e2e-debug-failure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kubectl -n flux-system get all
kubectl -n flux-system logs deploy/source-controller
kubectl -n flux-system logs deploy/kustomize-controller
kubectl -n flux-system logs deploy/helm-controller
flux get all --all-namespaces
20 changes: 20 additions & 0 deletions .github/scripts/e2e-setup-cluster-reconciliation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if [ -z "$1" ]; then
echo "Error: 'repository_url' argument not set"
exit 1
fi

if [ -z "$2" ]; then
echo "Error: 'branch_name' argument not set"
exit 1
fi

repository_url=$1
branch_name=$2

flux create source git flux-system \
--url=$repository_url \
--branch=$branch_name \
--ignore-paths="k8s/clusters/**/flux-system/"
flux create kustomization flux-system \
--source=flux-system \
--path=./k8s/clusters/development
2 changes: 2 additions & 0 deletions .github/scripts/e2e-verify-cluster-reconciliation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kubectl -n flux-system wait kustomization/infrastructure --for=condition=ready --timeout=5m
kubectl -n flux-system wait kustomization/apps --for=condition=ready --timeout=5m
1 change: 1 addition & 0 deletions .github/scripts/e2e-verify-helm-reconciliation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# kubectl -n ingress-traefik wait helmrelease/ingress-traefik --for=condition=ready --timeout=5m
36 changes: 36 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: End-to-end test

on:
workflow_dispatch:
push:
branches: 'main'
pull_request:
branches: 'main'

jobs:
end-to-end-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Flux
uses: fluxcd/flux2/action@main
- name: Extract branch name
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Setup Kubernetes
uses: nolar/setup-k3d-k3s@v1
with:
k3d-name: cluster-test
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Flux
run: flux install
- name: Setup cluster reconciliation
run: ./.github/scripts/e2e-setup-cluster-reconciliation.sh ${{ github.event.repository.html_url }} ${{ steps.extract_branch.outputs.branch }}
- name: Verify cluster reconciliation
run: ./.github/scripts/e2e-verify-cluster-reconciliation.sh
- name: Verify helm reconciliation
run: ./.github/scripts/e2e-verify-helm-reconciliation.sh
- name: Debug failure
if: failure()
run: ./.github/scripts/e2e-debug-failure.sh
53 changes: 0 additions & 53 deletions .github/workflows/end-to-end-test.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion k8s/clusters/development/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
spec:
interval: 10m
dependsOn:
- name: infra-configs
- name: infrastructure
sourceRef:
kind: GitRepository
name: flux-system
Expand Down
29 changes: 3 additions & 26 deletions k8s/clusters/development/infrastructure.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: infra-controllers
name: infrastructure
namespace: flux-system
spec:
interval: 1h
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux-system
path: ./k8s/infrastructure/controllers
path: ./k8s/infrastructure/overlays/development
prune: true
wait: true
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: infra-configs
namespace: flux-system
spec:
dependsOn:
- name: infra-controllers
interval: 1h
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux-system
path: ./k8s/infrastructure/configs
prune: true
patches:
- patch: |
- op: replace
path: /spec/acme/server
value: https://acme-staging-v02.api.letsencrypt.org/directory
target:
kind: ClusterIssuer
name: letsencrypt

15 changes: 15 additions & 0 deletions k8s/clusters/production/apps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps
namespace: flux-system
spec:
interval: 10m
dependsOn:
- name: infrastructure
sourceRef:
kind: GitRepository
name: flux-system
path: ./k8s/apps/overlays/production
prune: true
wait: true
15 changes: 15 additions & 0 deletions k8s/clusters/production/infrastructure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: infrastructure
namespace: flux-system
spec:
interval: 1h
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux-system
path: ./k8s/infrastructure/overlays/production
prune: true
wait: true

Empty file.
16 changes: 0 additions & 16 deletions k8s/infrastructure/configs/cluster-issuers.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions k8s/infrastructure/configs/network-policies.yaml

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions k8s/infrastructure/controllers/ingress-traefik/release.yaml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ingress-traefik
resources: []
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# - cluster-issuers.yaml
- network-policies.yaml
resources: []
3 changes: 3 additions & 0 deletions k8s/infrastructure/overlays/production/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: []