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
+108
-15
No files matched your search
@@ -22,6 +22,7 @@ tasks:
|
|||||||
jq
|
jq
|
||||||
k0sproject/tap/k0sctl
|
k0sproject/tap/k0sctl
|
||||||
k9s
|
k9s
|
||||||
|
kubeconform
|
||||||
kubernetes-cli
|
kubernetes-cli
|
||||||
kustomize
|
kustomize
|
||||||
sops
|
sops
|
||||||
|
|||||||
@@ -8,23 +8,23 @@ tasks:
|
|||||||
desc: Clean files and directories no longer needed after cluster bootstrap
|
desc: Clean files and directories no longer needed after cluster bootstrap
|
||||||
cmds:
|
cmds:
|
||||||
# Move bootstrap directory to gitignored directory
|
# Move bootstrap directory to gitignored directory
|
||||||
- mkdir -p {{.ROOT}}/.private
|
- mkdir -p {{.ROOT_DIR}}/.private
|
||||||
- mv {{.ROOT}}/bootstrap {{.ROOT}}/.private
|
- mv {{.ROOT_DIR}}/bootstrap {{.ROOT_DIR}}/.private
|
||||||
# Update renovate.json5
|
# Update renovate.json5
|
||||||
- sed -i '' 's/(..\.j2)\?(..\.j2)\?//g' {{.ROOT}}/.github/renovate.json5
|
- sed -i '' 's/(..\.j2)\?(..\.j2)\?//g' {{.ROOT_DIR}}/.github/renovate.json5
|
||||||
- sed -i '' 's/addons/d' {{.ROOT}}/.github/renovate.json5
|
- sed -i '' 's/addons/d' {{.ROOT_DIR}}/.github/renovate.json5
|
||||||
preconditions:
|
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" }
|
- { msg: "renovate.json5 not found", sh: "test -f {{.ROOT_DIR}}/.github/renovate.json5" }
|
||||||
|
|
||||||
reset:
|
reset:
|
||||||
desc: Remove templated configuration files
|
desc: Remove templated configuration files
|
||||||
prompt: Remove templated configuration files... continue?
|
prompt: Remove templated configuration files... continue?
|
||||||
cmds:
|
cmds:
|
||||||
- rm -rf {{.ROOT}}/.sops.yaml
|
- rm -rf {{.ROOT_DIR}}/.sops.yaml
|
||||||
- rm -rf {{.ROOT}}/k0s-config.yaml
|
- rm -rf {{.ROOT_DIR}}/k0s-config.yaml
|
||||||
- rm -rf {{.ROOT}}/ansible
|
- rm -rf {{.ROOT_DIR}}/ansible
|
||||||
- rm -rf {{.ROOT}}/kubernetes
|
- rm -rf {{.ROOT_DIR}}/kubernetes
|
||||||
|
|
||||||
reset-repo:
|
reset-repo:
|
||||||
desc: Set repo back to HEAD
|
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
|
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._
|
📍 _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:
|
init:
|
||||||
desc: Initialize configuration files
|
desc: Initialize configuration files
|
||||||
dir: "{{.BOOTSTRAP_DIR}}"
|
|
||||||
cmds:
|
cmds:
|
||||||
- cp -n vars/addons.sample.yaml vars/addons.yaml
|
- cp -n {{.BOOTSTRAP_DIR}}vars/addons.sample.yaml {{.BOOTSTRAP_DIR}}/vars/addons.yaml
|
||||||
- cp -n vars/config.sample.yaml vars/config.yaml
|
- cp -n {{.BOOTSTRAP_DIR}}/vars/config.sample.yaml {{.BOOTSTRAP_DIR}}/vars/config.yaml
|
||||||
- cmd: echo "=== Configuration files copied ==="
|
- cmd: echo "=== Configuration files copied ==="
|
||||||
silent: true
|
silent: true
|
||||||
- cmd: echo "Proceed with updating the configuration files..."
|
- cmd: echo "Proceed with updating the configuration files..."
|
||||||
@@ -47,6 +46,8 @@ tasks:
|
|||||||
configure:
|
configure:
|
||||||
desc: Configure repository from Ansible vars
|
desc: Configure repository from Ansible vars
|
||||||
prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue?
|
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:
|
env:
|
||||||
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "false"
|
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "false"
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
# For dashboard sign in token:
|
# For dashboard sign in token:
|
||||||
# kubectl -n observability get secret kubernetes-dashboard -o jsonpath='{.data.token}' | base64 -d
|
# 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
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: upgrade.cattle.io/v1
|
apiVersion: upgrade.cattle.io/v1
|
||||||
kind: Plan
|
kind: Plan
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: upgrade.cattle.io/v1
|
apiVersion: upgrade.cattle.io/v1
|
||||||
kind: Plan
|
kind: Plan
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
kind: HelmRelease
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#jinja2: trim_blocks: True
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||||||
---
|
---
|
||||||
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
kind: HelmRelease
|
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