/k8s-tf-eks-gitops

Multitenant+Multicluster Amazon EKS installation using Terraform, GitHub Actions and GitOps

Primary LanguageHCLApache License 2.0Apache-2.0

β›΅ Build Amazon EKS using Terraform, GitHub Actions and GitOps

... managed by Flux/ArgoCD and serviced with Renovate ...

Kubernetes Amazon EKS Cilium Argo CD Rancher Prometheus Grafana Renovate

Build Status



πŸ“–  Overview


✨  Cluster setup


🎨  Cluster components

  • cilium: For cluster networking.
  • ingress-nginx: Provides ingress cluster services.
  • SOPS: Encrypts secrets which is safe to store - even to a public repository.
  • external-dns: Creates DNS entries in Cloud Provider's DNS service.
  • cert-manager: Configured to create TLS certs for all ingress services automatically using LetsEncrypt.

πŸ“‚  Repository structure

flux tree kustomization flux-system --compact

Output:

Kustomization/flux-system/flux-system
β”œβ”€β”€ Kustomization/flux-system/cluster-apps
β”‚   β”œβ”€β”€ HelmRelease/metrics-server/metrics-server
β”‚   β”œβ”€β”€ HelmRelease/polaris/polaris
β”‚   β”œβ”€β”€ Kustomization/flux-system/cert-manager
β”‚   β”‚   └── HelmRelease/cert-manager/cert-manager
β”‚   β”œβ”€β”€ Kustomization/flux-system/cert-manager-certificate
β”‚   β”œβ”€β”€ Kustomization/flux-system/cert-manager-clusterissuer
β”‚   β”œβ”€β”€ Kustomization/flux-system/cert-manager-crds
β”‚   β”œβ”€β”€ Kustomization/flux-system/cluster-autoscaler
β”‚   β”‚   └── HelmRelease/cluster-autoscaler/cluster-autoscaler
β”‚   β”œβ”€β”€ Kustomization/flux-system/crossplane
β”‚   β”‚   └── HelmRelease/crossplane-system/crossplane
β”‚   β”œβ”€β”€ Kustomization/flux-system/crossplane-provider
β”‚   β”œβ”€β”€ Kustomization/flux-system/crossplane-providerconfig
β”‚   β”œβ”€β”€ Kustomization/flux-system/dex
β”‚   β”‚   └── HelmRelease/dex/dex
β”‚   β”œβ”€β”€ Kustomization/flux-system/external-dns
β”‚   β”‚   └── HelmRelease/external-dns/external-dns
β”‚   β”œβ”€β”€ Kustomization/flux-system/ingress-nginx
β”‚   β”‚   └── HelmRelease/ingress-nginx/ingress-nginx
β”‚   β”œβ”€β”€ Kustomization/flux-system/kube-prometheus-stack
β”‚   β”‚   └── HelmRelease/kube-prometheus-stack/kube-prometheus-stack
β”‚   β”œβ”€β”€ Kustomization/flux-system/kubernetes-dashboard
β”‚   β”‚   └── HelmRelease/kubernetes-dashboard/kubernetes-dashboard
β”‚   β”œβ”€β”€ Kustomization/flux-system/oauth2-proxy
β”‚   β”‚   └── HelmRelease/oauth2-proxy/oauth2-proxy
β”‚   └── Kustomization/flux-system/podinfo
β”‚       └── HelmRelease/podinfo/podinfo
β”œβ”€β”€ Kustomization/flux-system/cluster-apps-secrets
β”œβ”€β”€ Kustomization/flux-system/sources
β”‚   β”œβ”€β”€ HelmRepository/flux-system/autoscaler
β”‚   β”œβ”€β”€ HelmRepository/flux-system/bitnami
β”‚   β”œβ”€β”€ HelmRepository/flux-system/crossplane
β”‚   β”œβ”€β”€ HelmRepository/flux-system/dex
β”‚   β”œβ”€β”€ HelmRepository/flux-system/fairwinds-stable
β”‚   β”œβ”€β”€ HelmRepository/flux-system/ingress-nginx
β”‚   β”œβ”€β”€ HelmRepository/flux-system/jetstack
β”‚   β”œβ”€β”€ HelmRepository/flux-system/kubernetes-dashboard
β”‚   β”œβ”€β”€ HelmRepository/flux-system/metrics-server
β”‚   β”œβ”€β”€ HelmRepository/flux-system/oauth2-proxy
β”‚   β”œβ”€β”€ HelmRepository/flux-system/podinfo
β”‚   └── HelmRepository/flux-system/prometheus-community
└── GitRepository/flux-system/flux-system

πŸ€–  Automate all the things

  • GitHub Actions for checking code formatting
  • Renovate Renovate GitHub action keeps my application charts and container images up-to-date

πŸ•ΈοΈ  Secrets

There are several secrets:


πŸ€·β€β™‚οΈ  Notes

  • Describe the directory structure
  • Check emails form policy-reporter
  • Put all HelmRepository objects to flux-system instead of "namespaces" to be able to share them
  • Check snapshots (cnpg/velero) + KMS keys (if they are being deleted)
  • kubernetes-dashboard - auto login not working

🀝  Thanks

A lot of inspiration for my cluster came from the people that have shared their clusters over at k8s-at-home and many other "GitHub" repositories...

Requirements for K8s cluster management

Not complete...

  • Run change on only 3% of the clusters, then another 3%, ...
  • Changes applied to group of clusters
  • Easily add / remove application from specific cluster / cluster group
  • One source (file) for "variables/secrets"
  • Move cluster from one cluster to another... ?
  • Different TF code for different clusters / cluster groups