feat: implement mjfilter file for templates (#1244)

* feat: implement mjfilter file for templates

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: use data.get in mjfilters

Signed-off-by: Devin Buhl <devin@buhl.casa>

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl authored and GitHub committed 2024-01-24 14:52:50 -05:00
1 parent 9d175fcc99
commit 5d849727d8
112 files changed
+81 -184

No files matched your search

@@ -0,0 +1 @@
main = lambda data: data.get("addon_discord_template_notifier", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_discord_template_notifier.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -61,4 +60,3 @@ spec:
- path: /data/config.toml
subPath: config.toml
readOnly: true
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_discord_template_notifier.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./secret.sops.yaml
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_discord_template_notifier.enabled %#
---
apiVersion: v1
kind: Secret
@@ -13,4 +12,3 @@ stringData:
retry_limit = 5
sink.type = "discord"
sink.url = "#{ discord_template_notifier.webhook_url }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_discord_template_notifier.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_homepage", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
---
apiVersion: v1
kind: ConfigMap
@@ -76,4 +75,3 @@ data:
dateStyle: long
timeStyle: short
hourCycle: h23
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -86,4 +85,3 @@ spec:
path: /app/config/widgets.yaml
serviceAccount:
create: true
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
@@ -6,4 +5,3 @@ resources:
- ./configmap.yaml
- ./helmrelease.yaml
- ./secret.sops.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
---
apiVersion: v1
kind: Secret
@@ -10,4 +9,3 @@ stringData:
HOMEPAGE_VAR_CLOUDFLARED_API_TOKEN: "#{ bootstrap_cloudflare_token }#"
HOMEPAGE_VAR_GRAFANA_USERNAME: admin
HOMEPAGE_VAR_GRAFANA_PASSWORD: "#{ grafana.password }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_weave_gitops", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_weave_gitops.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -55,4 +54,3 @@ spec:
impersonationResourceNames: ["admin"]
podAnnotations:
secret.reloader.stakater.com/reload: cluster-user-auth
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_weave_gitops.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./secret.sops.yaml
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_weave_gitops.enabled %#
---
apiVersion: v1
kind: Secret
@@ -8,4 +7,3 @@ type: Opaque
stringData:
username: admin
password: "#{ addon_weave_gitops.password | encrypt }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_weave_gitops.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['talos']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['talos'] %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -27,4 +26,3 @@ spec:
#% filter indent(width=4, first=True) %#
#% include 'partials/kubelet-csr-approver-values.partial.yaml.j2' %#
#% endfilter %#
#% endif %#
@@ -1,7 +1,5 @@
#% if bootstrap_distribution in ['talos'] %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['talos'] %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k0s', 'talos']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'talos'] %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -28,10 +27,12 @@ spec:
#% if bootstrap_distribution in ['k0s'] %#
containerdSock: /run/k0s/containerd.sock
containerdRegistryConfigPath: /var/lib/k0s/containerd/certs.d
#% elif bootstrap_distribution in ['talos'] %#
containerdSock: /run/containerd/containerd.sock
containerdRegistryConfigPath: /etc/cri/conf.d/hosts
#% endif %#
service:
registry:
hostPort: 29999
serviceMonitor:
enabled: true
#% endif %#
@@ -1,7 +1,5 @@
#% if bootstrap_distribution in ['k0s', 'talos'] %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'talos'] %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k0s', 'k3s'] and data.get("addon_longhorn", {}).get("enabled", False) == True
@@ -1,8 +1,6 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./namespace.yaml
- ./longhorn/ks.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -45,4 +44,3 @@ spec:
ingressClassName: internal
host: longhorn.${SECRET_DOMAIN}
tls: true
#% endif %#
@@ -1,8 +1,6 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
- ./snapshot.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
@@ -13,4 +12,3 @@ allowVolumeExpansion: true
volumeBindingMode: Immediate
metadata:
name: longhorn-snapshot
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
---
apiVersion: v1
kind: Namespace
@@ -6,4 +5,3 @@ metadata:
name: longhorn-system
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_grafana", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_grafana.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -180,4 +179,3 @@ spec:
storageClassName: openebs-hostpath
testFramework:
enabled: false
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_grafana.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./secret.sops.yaml
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_grafana.enabled %#
---
apiVersion: v1
kind: Secret
@@ -7,4 +6,3 @@ metadata:
stringData:
admin-user: admin
admin-password: "#{ grafana.password }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_grafana.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_kube_prometheus_stack", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_kube_prometheus_stack.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -159,4 +158,3 @@ spec:
multicluster:
etcd:
enabled: true
#% endif %#
@@ -1,7 +1,5 @@
#% if addon_kube_prometheus_stack.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_kube_prometheus_stack.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_kubernetes_dashboard", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_kubernetes_dashboard.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -45,4 +44,3 @@ spec:
- *host
metricsScraper:
enabled: true
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_kubernetes_dashboard.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./rbac.yaml
- ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_kubernetes_dashboard.enabled %#
# For dashboard sign in token:
# kubectl -n observability get secret kubernetes-dashboard -o jsonpath='{.data.token}' | base64 -d
---
@@ -38,4 +37,3 @@ subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: observability
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_kubernetes_dashboard.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -22,4 +21,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_csi_driver_nfs", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_csi_driver_nfs.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -29,4 +28,3 @@ spec:
#% if bootstrap_distribution in ['k0s'] %#
kubeletDir: /var/lib/k0s/kubelet
#% endif %#
#% endif %#
@@ -1,8 +1,8 @@
#% if addon_csi_driver_nfs.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% if addon_csi_driver_nfs.storage_class|length > 0 %#
- ./storageclass.yaml
#% endif %#
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_csi_driver_nfs.enabled %#
#% for item in addon_csi_driver_nfs.storage_class %#
---
apiVersion: storage.k8s.io/v1
@@ -13,4 +12,3 @@ reclaimPolicy: Delete
volumeBindingMode: Immediate
mountOptions: ["hard", "noatime"]
#% endfor %#
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_csi_driver_nfs.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_csi_driver_smb", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_csi_driver_smb.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -30,4 +29,3 @@ spec:
#% else %#
kubelet: /var/lib/kubelet
#% endif %#
#% endif %#
@@ -1,11 +1,11 @@
#% if addon_csi_driver_smb.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% if addon_csi_driver_smb.storage_class|length > 0 %#
- ./storageclass.yaml
#% endif %#
#% if addon_csi_driver_smb.create_secrets|default(true) %#
- ./secrets.sops.yaml
#% endif %#
#% endif %#
@@ -1,4 +1,4 @@
#% if addon_csi_driver_smb.enabled and addon_csi_driver_smb.create_secrets|default(true) %#
#% if addon_csi_driver_smb.create_secrets|default(true) %#
#% for item in addon_csi_driver_smb.storage_class %#
#% if not item.existing_secret_name %#
---
@@ -1,4 +1,3 @@
#% if addon_csi_driver_smb.enabled %#
#% for item in addon_csi_driver_smb.storage_class %#
---
apiVersion: storage.k8s.io/v1
@@ -22,4 +21,3 @@ mountOptions:
- cache=strict
- noserverino # required to prevent data corruption
#% endfor %#
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_csi_driver_smb.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("addon_volsync", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if addon_volsync.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -40,4 +39,3 @@ spec:
tag: *tag
metrics:
disableAuth: true
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_volsync.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
- ./prometheusrule.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_volsync.enabled %#
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
@@ -22,4 +21,3 @@ spec:
for: 15m
labels:
severity: critical
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_volsync.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -10,10 +9,6 @@ spec:
commonMetadata:
labels:
app.kubernetes.io/name: *app
#% if addon_longhorn.enabled %#
dependsOn:
- name: longhorn
#% endif %#
path: ./kubernetes/apps/storage/volsync/snapshot-controller
prune: true
sourceRef:
@@ -43,4 +38,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -25,6 +25,11 @@ spec:
retries: 3
uninstall:
keepHistory: false
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
dependsOn:
- name: longhorn
namespace: longhorn-system
#% endif %#
values:
controller:
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
@@ -1,7 +1,5 @@
#% if addon_volsync.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k3s'] and data.get("addon_system_upgrade_controller", {}).get("enabled", False) == True
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
@@ -102,4 +101,3 @@ spec:
globalMounts:
- path: /etc/ca-certificates
readOnly: true
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
@@ -7,4 +6,3 @@ resources:
- https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.2/crd.yaml
- helmrelease.yaml
- rbac.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
@@ -12,4 +11,3 @@ subjects:
- kind: ServiceAccount
name: system-upgrade
namespace: tools
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
@@ -41,4 +40,3 @@ spec:
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: upgrade.cattle.io/v1
kind: Plan
@@ -17,4 +16,3 @@ spec:
args: ["prepare", "server"]
upgrade:
image: rancher/k3s-upgrade
#% endif %#
@@ -1,8 +1,6 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./server.yaml
- ./agent.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
---
apiVersion: upgrade.cattle.io/v1
kind: Plan
@@ -22,4 +21,3 @@ spec:
- {key: CriticalAddonsOnly, operator: Exists}
upgrade:
image: rancher/k3s-upgrade
#% endif %#