This repository represents how implement a Kubernetes DevOps Workflow which simplifies evolve bricks of a DevOps infrastructure.
Who have never got the temptation to fork a helm chart repository in order to add some functionalities ? Me first ...
This workflow try bring closer the state of the art using the better of DevOps tools: Package Management (Helm) >> Config Management (Kustomize) >> GitOps (ArgoCD) >> Admission Controller (kyverno)
This implementation is based on following publictions:
Some killer features:
- based on App Of Apps Pattern & ArgoCD Applicationset
- ArgoCD manages itself ... Chicken or the egg ?
- Custom Ressource Definitions management
- Performing Async Actions using Hooks
- Pre-installed Unified Grafana Dashboards (logging/monitoring) + ArgoCD notifications correlation
- Backup of ingress's logs into an object storage using a low level tool (fast, memory efficient, and designed to handle the most demanding workloads)
- Backup of app's logs into an object storage
- ArgoCD notifications ready: slack or teams
- Private key encryption of passwords
- Pod Security Standards implemented as Kyverno policies
- extra policies: Best Practices, mitigates CVE
Helm must be installed to use the charts. Please refer to Helm's documentation to get started.
Once Helm has been set up correctly, add the repo as follows:
helm repo add kustomization https://kube-components-stack.github.io/kustomization
If you had already added this repo earlier, run helm repo update
to retrieve
the latest versions of the packages. You can then run helm search repo kustomization
to see the charts.
To install the kustomization chart:
helm install my-kustomization kustomization/kustomization
To uninstall the chart:
helm delete my-kustomization
.
βββ manifests
β βββ argocd-applicationset
β β βββ addons-apps.yaml
β β βββ addons-crds.yaml
β β βββ core-apps.yaml
β β βββ core-crds.yaml
β βββ argocd-appproject
β βββ addons-apps.yaml
β βββ addons-crds.yaml
β βββ core-apps.yaml
β βββ core-crds.yaml
βββ rendered-manifests
β βββ core
β β βββ apps
β β β βββ namespace-01
β β β β βββ base
β β β β β βββ helm-generator.yaml
β β β β β βββ kustomization.yaml
β β β β β βββ namespace.yaml
β β β β βββ overlays
β β β β βββ kind-dev
β β β β β βββ kustomization.yaml
β β β | | βββ secrets.yaml
β β β β β βββ values.yaml
β β β β βββ kind-prod
β β β β βββ kustomization.yaml
β β β | βββ secrets.yaml
β β β β βββ values.yaml
β β β βββ namespace-x
β β β βββ base
β β β β βββ helm-generator.yaml
β β β β βββ kustomization.yaml
β β β β βββ namespace.yaml
β β β βββ overlays
β β β βββ kind-dev
β β β | βββ kustomization.yaml
β β β | βββ secrets.yaml
β β β | βββ values.yaml
β β β βββ kind-prod
β β β βββ kustomization.yaml
β β β βββ secrets.yaml
β β β βββ values.yaml
β β βββ crds
β β βββ crds-01
β β β βββ base
β β β β βββ kustomization.yaml
β β β βββ overlays
β β β βββ kind-dev
β β β β βββ kustomization.yaml
β β β βββ kind-prod
β β β βββ kustomization.yaml
β β βββ crds-x
β β βββ base
β β β βββ kustomization.yaml
β β βββ overlays
β β βββ kind-dev
β β β βββ kustomization.yaml
β β βββ kind-prod
β β βββ kustomization.yaml
β βββ addons
β βββ apps
β β βββ namespace-01
β β β βββ base
β β β β βββ helm-generator.yaml
β β β β βββ kustomization.yaml
β β β β βββ namespace.yaml
β β β βββ overlays
β β β βββ kind-dev
β β β β βββ kustomization.yaml
β β | | βββ secrets.yaml
β β β β βββ values.yaml
β β β βββ kind-prod
β β β βββ kustomization.yaml
β β | βββ secrets.yaml
β β β βββ values.yaml
β β βββ namespace-x
β β βββ base
β β β βββ helm-generator.yaml
β β β βββ kustomization.yaml
β β β βββ namespace.yaml
β β βββ overlays
β β βββ kind-dev
β β | βββ kustomization.yaml
β β | βββ secrets.yaml
β β | βββ values.yaml
β β βββ kind-prod
β β βββ kustomization.yaml
β β βββ secrets.yaml
β β βββ values.yaml
β βββ crds
β βββ crds-addon-01
β β βββ base
β β β βββ kustomization.yaml
β β βββ overlays
β β βββ kind-dev
β β β βββ kustomization.yaml
β β βββ kind-prod
β β βββ kustomization.yaml
β βββ crds-addon-x
β βββ base
β β βββ kustomization.yaml
β βββ overlays
β βββ kind-dev
β β βββ kustomization.yaml
β βββ kind-prod
β βββ kustomization.yaml
βββ Makefile
βββ README.md
βββ scripts
βΒ Β βββ tools
βββ secrets
βββ core
β βββ loki
β β βββ overlays
β β βββ kind-dev
β β β βββ kustomization.yaml
β β βββ kind-prod
β β β βββ kustomization.yaml
β β β βββ secrets
β β β βββ bucket-s3.yaml
β β βββ plato-devncoargo
β β βββ kustomization.yaml
β β βββ secrets
β β βββ bucket-s3.yaml
β βββ vector
β βββ overlays
β βββ kind-dev
β β βββ kustomization.yaml
β βββ kind-prod
β β βββ kustomization.yaml
β β βββ secrets
β β βββ bucket-s3.yaml
β βββ plato-devncoargo
β βββ kustomization.yaml
β βββ secrets
β βββ bucket-s3.yaml
βββ addons
β βββ argocd
β βββ overlays
β βββ kind-dev
β β βββ kustomization.yaml
β β βββ secrets
β β βββ argocd-secret.yaml
β β βββ grafana-secret.yaml
β βββ kind-prod
β β βββ kustomization.yaml
β β βββ secrets
β β βββ argocd-notifications-secret.yaml
β β βββ argocd-secret.yaml
β β βββ grafana-secret.yaml
β β βββ keycloak-ca.yaml
β βββ plato-devncoargo
β βββ kustomization.yaml
β βββ secrets
β βββ argocd-notifications-secret.yaml
β βββ argocd-secret.yaml
β βββ grafana-secret.yaml
β βββ keycloak-ca.yaml
βββ clusters
βΒ Β βββ kind-dev
βΒ Β | βββ sealed-secrets-private-key.yaml
βΒ Β βββ kind-prod
βΒ Β βββ sealed-secrets-private-key.yaml
βββ README.md
addon=aws-efs-csi-driver
declare clusters=("plato-devncoargo")
namespace=kube-system
type=core
mkdir -p rendered-manifests/$type/namespaces/$addon/base
cat << EOF > rendered-manifests/$type/namespaces/$addon/base/helm-chart-$addon.yaml
apiVersion: builtin
kind: HelmChartInflationGenerator
metadata:
name: helm-chart-$addon
name: &name $addon
version: ""
repo: ""
releaseName: *name
namespace: $namespace
includeCRDs: false
valuesFile: values-$addon.yaml
valuesMerge: override # merge, override or replace
valuesInline: {}
EOF
cat << EOF > rendered-manifests/$type/namespaces/$addon/base/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: $namespace
EOF
cat << EOF > rendered-manifests/$type/namespaces/$addon/base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: $namespace
resources:
- namespace.yaml
EOF
for c in $clusters; do
mkdir -p rendered-manifests/$type/namespaces/$addon/overlays/$c
touch rendered-manifests/$type/namespaces/$addon/overlays/$c/{kustomization.yaml,values-$addon.yaml}
cat << EOF > rendered-manifests/$type/namespaces/$addon/overlays/$c/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: $namespace
generators:
- ../../base/helm-chart-$addon.yaml
resources:
- ../../base
EOF
done
current_path=$PWD
cluster=plato
env=devncoargo
cd rendered-manifests/addons/namespaces
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
cd ../crds
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
cd ../../core/namespaces
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
cd ../crds
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
cd $current_path
cd secrets/addons
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
cd ../core
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
cd ../clusters
for dir in $(find $PWD -type d -regex '.*/kind-prod'); do cp -ra $dir $(dirname $dir)/$cluster-$env; done
openssl req -days 3650 -x509 -nodes -newkey rsa:4096 -keyout "tls.key" -out "tls.crt" -subj "/CN=sealed-secret/O=sealed-secret"
cluster=plato
env=devncoargo
mkdir -p secrets/clusters/$cluster-$env
cat > secrets/clusters/$cluster-$env/sealed-secrets-private-key.yaml << EOF
apiVersion: v1
kind: Secret
metadata:
generateName: sealed-secrets-key
labels:
sealedsecrets.bitnami.com/sealed-secrets-key: active
name: sealed-secrets-key
namespace: kube-system
type: kubernetes.io/tls
data:
EOF
crt=`cat tls.crt|base64 -w 0`
key=`cat tls.key|base64 -w 0`
echo " tls.crt: $crt" >> secrets/clusters/$cluster-$env/sealed-secrets-private-key.yaml
echo " tls.key: $key" >> secrets/clusters/$cluster-$env/sealed-secrets-private-key.yaml
rm -Rf tls.crt tls.key
edit Makefile, in target "create-secrets:" adjust cluster & env vars and use command: make create-secrets
edit ingress values like this
ingress:
enabled: true
hostname: keycloak-nco.admin.plato-devncoargo.dev-sbr.com
tls: true
selfSigned: true
generate template, catch secret, extract datas, store them into a file and create, ca, crt and key files.
kustomize build --enable-alpha-plugins --enable-helm --load-restrictor LoadRestrictionsNone rendered-manifests/addons/namespaces/keycloak/overlays/plato-devncoargo|yq -ojson|jq -s|jq '.[]|select(.kind == "Secret")|select(.metadata.name == "keycloak-nco.admin.plato-devncoargo.dev-sbr.com-tls")'|jq -s '.[0].data|{"ca.crt": .["ca.crt"]|@base64d,"tls.crt": .["tls.crt"]|@base64d,"tls.key": .["tls.key"]|@base64d}' > secrets/addons/keycloak/overlays/plato-devncoargo/secrets/tls.json
cd secrets/addons/keycloak/overlays/plato-devncoargo/secrets
cat tls.json| jq -r '.["ca.crt"]' > ca.crt
cat tls.json| jq -r '.["tls.crt"]' > tls.crt
cat tls.json| jq -r '.["tls.key"]' > tls.key
rm tls.json
cd $OLDPWD
edit ingress values like this
tls:
enabled: true
autoGenerated: true
existingSecret: ""
generate template, catch secret, extract datas, store them into a file and create, ca, crt and key files.
kustomize build --enable-alpha-plugins --enable-helm --load-restrictor LoadRestrictionsNone rendered-manifests/addons/namespaces/keycloak/overlays/plato-devncoargo|yq -ojson|jq -s|jq '.[]|select(.kind == "Secret")|select(.metadata.name == "keycloak-crt")'|jq -s '.[0].data|{"ca.crt": .["ca.crt"]|@base64d,"tls.crt": .["tls.crt"]|@base64d,"tls.key": .["tls.key"]|@base64d}' > secrets/addons/keycloak/overlays/plato-devncoargo/secrets/tls.json
cd secrets/addons/keycloak/overlays/plato-devncoargo/secrets
cat tls.json| jq -r '.["ca.crt"]' > ca.crt
cat tls.json| jq -r '.["tls.crt"]' > tls.crt
cat tls.json| jq -r '.["tls.key"]' > tls.key
rm tls.json
cd $OLDPWD