Skip to content

Instantly share code, notes, and snippets.

@zxkane
Last active June 13, 2022 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zxkane/7e13b79b8b95b1e43b690b7fb5416ecd to your computer and use it in GitHub Desktop.
Save zxkane/7e13b79b8b95b1e43b690b7fb5416ecd to your computer and use it in GitHub Desktop.
use kind to debug gitops flux locally
# set kubeconfig for your kind cluster
export KUBECONFIG=$HOME/.kube/kind
# create kind cluster
kind create cluster --name gitops
# provisioning flux
flux install --components-extra=image-reflector-controller,image-automation-controller --export > gotk-components.yaml
cat <<EOF > kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-components.yaml
patches:
- patch: |
- op: add
path: /spec/template/spec/containers/0/args/0
value: --no-cross-namespace-refs=true
target:
kind: Deployment
name: "(kustomize-controller|helm-controller|notification-controller|image-reflector-controller|image-automation-controller)"
- patch: |
- op: add
path: /spec/template/spec/containers/0/args/0
value: --default-service-account=default
target:
kind: Deployment
name: "(kustomize-controller|helm-controller)"
- patch: |
- op: add
path: /spec/serviceAccountName
value: kustomize-controller
target:
kind: Kustomization
name: "flux-system"
- patch: |
- op: add
path: /spec/serviceAccountName
value: helm-controller
target:
kind: HelmRelease
name: "flux-system"
- patch: |
- op: add
path: /spec/template/spec/containers/0/args/-
value: --concurrent=20
- op: add
path: /spec/template/spec/containers/0/args/-
value: --kube-api-qps=500
- op: add
path: /spec/template/spec/containers/0/args/-
value: --kube-api-burst=1000
- op: add
path: /spec/template/spec/containers/0/args/-
value: --requeue-dependency=5s
target:
kind: Deployment
name: "(kustomize-controller|helm-controller|source-controller)"
EOF
kubectl apply -k ./
# configure flux source repo
cat <<EOF | kubectl apply -f -
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 1m
ref:
branch: external-secrets
url: https://github.com/zxkane/eks-gitops.git
ignore: |
/clusters/cluster-dev/flux-system/
/clusters/cluster-staging/flux-system/
/clusters/cluster-prod/flux-system/
EOF
# configure entry kustomization
flux create kustomization flux-system \
--source=flux-system \
--service-account=kustomize-controller \
--prune=true \
--path=./clusters/cluster-dev
# clean cluster if necessary
# kind delete cluster --name gitops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment