fix: annotations not rendering correctly and add kubeconform integration
Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
43 files changed
+115
-22
No files matched your search
@@ -22,6 +22,7 @@ tasks:
|
||||
jq
|
||||
k0sproject/tap/k0sctl
|
||||
k9s
|
||||
kubeconform
|
||||
kubernetes-cli
|
||||
kustomize
|
||||
sops
|
||||
|
||||
@@ -8,23 +8,23 @@ tasks:
|
||||
desc: Clean files and directories no longer needed after cluster bootstrap
|
||||
cmds:
|
||||
# Move bootstrap directory to gitignored directory
|
||||
- mkdir -p {{.ROOT}}/.private
|
||||
- mv {{.ROOT}}/bootstrap {{.ROOT}}/.private
|
||||
- mkdir -p {{.ROOT_DIR}}/.private
|
||||
- mv {{.ROOT_DIR}}/bootstrap {{.ROOT_DIR}}/.private
|
||||
# Update renovate.json5
|
||||
- sed -i '' 's/(..\.j2)\?(..\.j2)\?//g' {{.ROOT}}/.github/renovate.json5
|
||||
- sed -i '' 's/addons/d' {{.ROOT}}/.github/renovate.json5
|
||||
- sed -i '' 's/(..\.j2)\?(..\.j2)\?//g' {{.ROOT_DIR}}/.github/renovate.json5
|
||||
- sed -i '' 's/addons/d' {{.ROOT_DIR}}/.github/renovate.json5
|
||||
preconditions:
|
||||
- { msg: "bootstrap dir not found", sh: "test -d {{.ROOT}}/bootstrap" }
|
||||
- { msg: "bootstrap dir not found", sh: "test -d {{.ROOT_DIR}}/bootstrap" }
|
||||
- { msg: "renovate.json5 not found", sh: "test -f {{.ROOT_DIR}}/.github/renovate.json5" }
|
||||
|
||||
reset:
|
||||
desc: Remove templated configuration files
|
||||
prompt: Remove templated configuration files... continue?
|
||||
cmds:
|
||||
- rm -rf {{.ROOT}}/.sops.yaml
|
||||
- rm -rf {{.ROOT}}/k0s-config.yaml
|
||||
- rm -rf {{.ROOT}}/ansible
|
||||
- rm -rf {{.ROOT}}/kubernetes
|
||||
- rm -rf {{.ROOT_DIR}}/.sops.yaml
|
||||
- rm -rf {{.ROOT_DIR}}/k0s-config.yaml
|
||||
- rm -rf {{.ROOT_DIR}}/ansible
|
||||
- rm -rf {{.ROOT_DIR}}/kubernetes
|
||||
|
||||
reset-repo:
|
||||
desc: Set repo back to HEAD
|
||||
|
||||
@@ -164,7 +164,7 @@ Once you have installed Debian on your nodes, there are six stages to getting a
|
||||
task ansible:deps
|
||||
```
|
||||
|
||||
4. Install the required tools: [age](https://github.com/FiloSottile/age), [flux](https://toolkit.fluxcd.io/), [cloudflared](https://github.com/cloudflare/cloudflared), [kubectl](https://kubernetes.io/docs/tasks/tools/), [sops](https://github.com/getsops/sops)
|
||||
4. Install the required tools: [age](https://github.com/FiloSottile/age), [flux](https://toolkit.fluxcd.io/), [cloudflared](https://github.com/cloudflare/cloudflared), [kubectl](https://kubernetes.io/docs/tasks/tools/), [sops](https://github.com/getsops/sops), [kubeconform](https://github.com/yannh/kubeconform)
|
||||
|
||||
📍 _Not using brew? Make sure to look up how to install the latest version of each of these CLI tools yourself._
|
||||
|
||||
|
||||
+5
-4
@@ -26,10 +26,9 @@ tasks:
|
||||
|
||||
init:
|
||||
desc: Initialize configuration files
|
||||
dir: "{{.BOOTSTRAP_DIR}}"
|
||||
cmds:
|
||||
- cp -n vars/addons.sample.yaml vars/addons.yaml
|
||||
- cp -n vars/config.sample.yaml vars/config.yaml
|
||||
- cp -n {{.BOOTSTRAP_DIR}}vars/addons.sample.yaml {{.BOOTSTRAP_DIR}}/vars/addons.yaml
|
||||
- cp -n {{.BOOTSTRAP_DIR}}/vars/config.sample.yaml {{.BOOTSTRAP_DIR}}/vars/config.yaml
|
||||
- cmd: echo "=== Configuration files copied ==="
|
||||
silent: true
|
||||
- cmd: echo "Proceed with updating the configuration files..."
|
||||
@@ -47,6 +46,8 @@ tasks:
|
||||
configure:
|
||||
desc: Configure repository from Ansible vars
|
||||
prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue?
|
||||
cmd: ./.venv/bin/ansible-playbook {{.BOOTSTRAP_DIR}}/configure.yaml
|
||||
cmds:
|
||||
- ./.venv/bin/ansible-playbook {{.BOOTSTRAP_DIR}}/configure.yaml
|
||||
- ./scripts/kubeconform.sh {{.KUBERNETES_DIR}}
|
||||
env:
|
||||
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "false"
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
@@ -31,13 +32,13 @@ spec:
|
||||
ingress:
|
||||
enabled: true
|
||||
className: internal
|
||||
{% if homepage.enabled | default(false) %}
|
||||
annotations:
|
||||
gethomepage.dev/enabled: "true"
|
||||
gethomepage.dev/icon: kubernetes-dashboard.png
|
||||
gethomepage.dev/name: Kubernetes Dashboard
|
||||
gethomepage.dev/group: Observability
|
||||
{% endif %}
|
||||
{% if homepage.enabled | default(false) %}
|
||||
annotations:
|
||||
gethomepage.dev/enabled: "true"
|
||||
gethomepage.dev/icon: kubernetes-dashboard.png
|
||||
gethomepage.dev/name: Kubernetes Dashboard
|
||||
gethomepage.dev/group: Observability
|
||||
{% endif %}
|
||||
hosts:
|
||||
- &host "kubernetes.${SECRET_DOMAIN}"
|
||||
tls:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
# For dashboard sign in token:
|
||||
# kubectl -n observability get secret kubernetes-dashboard -o jsonpath='{.data.token}' | base64 -d
|
||||
---
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: upgrade.cattle.io/v1
|
||||
kind: Plan
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: upgrade.cattle.io/v1
|
||||
kind: Plan
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#jinja2: trim_blocks: True
|
||||
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||
kind: HelmRelease
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
|
||||
KUBERNETES_DIR=$1
|
||||
KUBE_VERSION="${2:-1.29.0}"
|
||||
|
||||
[[ -z "${KUBERNETES_DIR}" ]] && echo "Kubernetes location not specified" && exit 1
|
||||
|
||||
kustomize_args=("--load-restrictor=LoadRestrictionsNone")
|
||||
kustomize_config="kustomization.yaml"
|
||||
kubeconform_args=(
|
||||
"-strict"
|
||||
"-ignore-missing-schemas"
|
||||
"-kubernetes-version"
|
||||
"${KUBE_VERSION}"
|
||||
"-skip"
|
||||
"Secret"
|
||||
"-schema-location"
|
||||
"default"
|
||||
"-schema-location"
|
||||
"https://kubernetes-schemas.pages.dev/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json"
|
||||
"-verbose"
|
||||
)
|
||||
|
||||
echo "=== Validating standalone manifests in ${KUBERNETES_DIR}/flux ==="
|
||||
find "${KUBERNETES_DIR}/flux" -maxdepth 1 -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
|
||||
do
|
||||
kubeconform "${kubeconform_args[@]}" "${file}"
|
||||
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "=== Validating kustomizations in ${KUBERNETES_DIR}/flux ==="
|
||||
find "${KUBERNETES_DIR}/flux" -type f -name $kustomize_config -print0 | while IFS= read -r -d $'\0' file;
|
||||
do
|
||||
echo "=== Validating kustomizations in ${file/%$kustomize_config} ==="
|
||||
kustomize build "${file/%$kustomize_config}" "${kustomize_args[@]}" | \
|
||||
kubeconform "${kubeconform_args[@]}"
|
||||
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "=== Validating kustomizations in ${KUBERNETES_DIR}/apps ==="
|
||||
find "${KUBERNETES_DIR}/apps" -type f -name $kustomize_config -print0 | while IFS= read -r -d $'\0' file;
|
||||
do
|
||||
echo "=== Validating kustomizations in ${file/%$kustomize_config} ==="
|
||||
kustomize build "${file/%$kustomize_config}" "${kustomize_args[@]}" | \
|
||||
kubeconform "${kubeconform_args[@]}"
|
||||
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
Reference in new issue
Block a user