Skip to content

Commit

Permalink
Migrate to multi-cluster repo structure using kustomize (#270)
Browse files Browse the repository at this point in the history
* migrate to multi-cluster repo structure with kustomize

Signed-off-by: Michael Fornaro <[email protected]>

* remove velero prefix

Signed-off-by: Michael Fornaro <[email protected]>

* update velero schedules to include persistent volume data

Signed-off-by: Michael Fornaro <[email protected]>

* update scripts with new dir structure

Signed-off-by: Michael Fornaro <[email protected]>

* temp disable kubeval

Signed-off-by: Michael Fornaro <[email protected]>
  • Loading branch information
xunholy authored Jan 23, 2021
1 parent 79b5642 commit 19fe48a
Show file tree
Hide file tree
Showing 196 changed files with 388 additions and 15 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true
- name: Kubeval
uses: instrumenta/kubeval-action@master
with:
files: 'cluster/'
# TODO: enable with new dir stucture
# - name: Kubeval
# uses: instrumenta/kubeval-action@master
# with:
# files: 'cluster/'
compliance:
runs-on: ubuntu-latest
steps:
Expand All @@ -48,7 +49,7 @@ jobs:
result=$(docker run --rm --workdir /github/workspace \
-v $(pwd):/github/workspace \
instrumenta/conftest:v0.18.2 \
test -o table -p security-policies/policies/ --all-namespaces --combine cluster/ --no-color || exit 0)
test -o table -p security-policies/policies/ --all-namespaces --combine namespaces/ --no-color || exit 0)
result="${result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"
Expand All @@ -61,7 +62,7 @@ jobs:
result=$(docker run --rm --workdir /github/workspace \
-v $(pwd):/github/workspace \
instrumenta/conftest:v0.18.2 \
test -o stdout -p security-policies/policies/ --all-namespaces cluster/ --no-color || exit 0)
test -o stdout -p security-policies/policies/ --all-namespaces namespaces/ --no-color || exit 0)
result="${result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"
Expand Down
5 changes: 3 additions & 2 deletions bootstrap/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ if [[ -f .secrets/git-crypt/k8s-secret-sealed-secret-private-key.yaml ]]; then
kubectl apply -f .secrets/git-crypt/k8s-secret-sealed-secret-private-key.yaml
fi

if [[ -f cluster/flux-system/repo.yaml ]]; then
# TODO: add cluster ARG to script
if [[ -f clusters/production/repo.yaml ]]; then
echo "Applying Repo Sync"
kubectl apply -f cluster/flux-system/repo.yaml
kubectl apply -f clusters/production/repo.yaml
fi
4 changes: 2 additions & 2 deletions bootstrap/renovate-helm-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ shopt -s extglob

# shellcheck disable=SC2155
REPO_ROOT=$(git rev-parse --show-toplevel)
CLUSTER_ROOT="${REPO_ROOT}/cluster"
HELM_REPO_FILES=$(find "$CLUSTER_ROOT/flux-system/helm-chart-repositories" -name '*.yaml')
CLUSTER_ROOT="${REPO_ROOT}/namespaces"
HELM_REPO_FILES=$(find "$CLUSTER_ROOT/base/flux-system/helm-chart-repositories" -name '*.yaml')
HELM_RELEASE_FILES=$(find "$CLUSTER_ROOT" -name '*.yaml')

for HELM_REPO_FILE in $HELM_REPO_FILES; do
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ flux install \
--network-policy=false \
--arch=arm64 \
--log-level=info \
--export > "./cluster/flux-system/toolkit-components.yaml"
--export > "./namespaces/base/flux-system/toolkit-components.yaml"

# Uncomment for local useage
# git add -A && git commit -sam "update toolkit version to latest" && git push
30 changes: 30 additions & 0 deletions clusters/production/repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: k8s-gitops
namespace: flux-system
spec:
interval: 5m
ref:
branch: main
url: https://github.com/raspbernetes/k8s-gitops.git
ignore: |
# exclude all
/*
# include deploy dir
!/cluster/
/cluster/**/*.md
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: k8s-gitops
namespace: flux-system
spec:
interval: 5m
path: './namespaces/production'
sourceRef:
kind: GitRepository
name: k8s-gitops
prune: true
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
namespace: flux-system
spec:
interval: 5m
path: './cluster/'
path: './namespaces/staging'
sourceRef:
kind: GitRepository
name: k8s-gitops
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions namespaces/base/actions-runner-system/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- actions-runner-controller.yaml
- runner.yaml
- secret.encrypted.yaml
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- alerts.yaml
- provider.yaml
- secret.encrypted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- banzaicloud-charts.yaml
- bitnami-charts.yaml
- coredns-charts.yaml
- flagger-charts.yaml
- gatekeeper-charts.yaml
- grafana-loki.yaml
- jetstack-charts.yaml
- k8s-at-home-charts.yaml
- kubernetes-sigs-charts.yaml
- kubernetes-stable-charts.yaml
- litmuschaos-charts.yaml
- openebs-charts.yaml
- openebs-cstor-charts.yaml
- openfaas-charts.yaml
- prometheus-community-charts.yaml
- sealed-secrets-charts.yaml
- vernemq-charts.yaml
- vmware-charts.yaml
- weaveworks-kured-charts.yaml
6 changes: 6 additions & 0 deletions namespaces/base/flux-system/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- podmonitor.yaml
- toolkit-components.yaml
- webhook-receiver
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- alerts.yaml
- provider.yaml
- secret.encrypted.yaml
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- receiver.yaml
- secret.encrypted.yaml
- virtualservice.yaml
5 changes: 5 additions & 0 deletions namespaces/base/home-system/home-assistant/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- virtualservice.yaml
5 changes: 5 additions & 0 deletions namespaces/base/home-system/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
4 changes: 4 additions & 0 deletions namespaces/base/home-system/mosquitto/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/home-system/zigbee2mqtt/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- virtualservice.yaml
4 changes: 4 additions & 0 deletions namespaces/base/istio-operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- operator.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions namespaces/base/istio-system/istio/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- istio.yaml
14 changes: 14 additions & 0 deletions namespaces/base/istio-system/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- certificate.yaml
- envoyfilter-authn.yaml
- gateway.yaml
- namespace.yaml
- networkpolicy.yaml
- originissuer.yaml
- peerauthentication.yaml
- secret.encrypted.yaml
- serviceentry.yaml
- servicemonitor.yaml
- virtualservice.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions namespaces/base/kube-system/cilium/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- service.yaml
- servicemonitor.yaml
- virtualservice.yaml
File renamed without changes.
4 changes: 4 additions & 0 deletions namespaces/base/kube-system/descheduler/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/kube-system/kured/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- servicemonitor.yaml
5 changes: 5 additions & 0 deletions namespaces/base/kube-system/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
4 changes: 4 additions & 0 deletions namespaces/base/kube-system/metrics-server/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: HelmRelease
metadata:
name: sealed-secrets
namespace: kube-system
creationTimestamp: null
spec:
interval: 5m
chart:
Expand Down
6 changes: 6 additions & 0 deletions namespaces/base/kube-system/sealed-secrets/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- servicemonitor.yaml
- virtualservice.yaml
File renamed without changes.
6 changes: 6 additions & 0 deletions namespaces/base/litmus/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
- helmrelease.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions namespaces/base/network/cert-manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- servicemonitor.yaml
- secret.encrypted.yaml
- clusterissuer-prod.yaml
- clusterissuer-stg.yaml
5 changes: 5 additions & 0 deletions namespaces/base/network/cloudflare-ddns/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- secret.encrypted.yaml
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions namespaces/base/network/coredns/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions namespaces/base/network/dex/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- secret.encrypted.yaml
- virtualservice.yaml
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions namespaces/base/network/external-dns/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- secret.encrypted.yaml
- servicemonitor.yaml
5 changes: 5 additions & 0 deletions namespaces/base/network/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
File renamed without changes.
4 changes: 4 additions & 0 deletions namespaces/base/network/metallb/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
6 changes: 6 additions & 0 deletions namespaces/base/network/oauth2-proxy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- secret.encrypted.yaml
- virtualservice.yaml
File renamed without changes.
8 changes: 8 additions & 0 deletions namespaces/base/network/origin-ca-issuer/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- clusterrole.yaml
- clusterrolebinding.yaml
- customresourcedefinition.yaml
- serviceaccount.yaml
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/observability/kiali/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- virtualservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- secret.encrypted.yaml
- secret.encrypted-grafana.yaml
- secret.oauth2.encrypted.yaml
- virtualservice.yaml
5 changes: 5 additions & 0 deletions namespaces/base/observability/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
5 changes: 5 additions & 0 deletions namespaces/base/observability/loki-stack/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- servicemonitor.yaml
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/observability/speedtest/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- servicemonitor.yaml
File renamed without changes.
7 changes: 7 additions & 0 deletions namespaces/base/observability/thanos/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- secret.encrypted.yaml
- servicemonitor.yaml
- virtualservice.yaml
5 changes: 5 additions & 0 deletions namespaces/base/openfaas-fn/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/openfaas/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions namespaces/base/openfaas/openfaas/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/security/gatekeeper/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helmrelease.yaml
- podmonitor.yaml
File renamed without changes.
5 changes: 5 additions & 0 deletions namespaces/base/security/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- networkpolicy.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 19fe48a

Please sign in to comment.