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

+1
View File
@@ -4,6 +4,7 @@ export SOPS_AGE_KEY_FILE="$(expand_path ./age.key)"
# Venv # Venv
PATH_add "$(expand_path ./.venv/bin)" PATH_add "$(expand_path ./.venv/bin)"
export VIRTUAL_ENV="$(expand_path ./.venv)" export VIRTUAL_ENV="$(expand_path ./.venv)"
export PYTHONDONTWRITEBYTECODE="1"
# Ann Seabelle # Ann Seabelle
export ANSIBLE_COLLECTIONS_PATH=$(expand_path ./.venv/galaxy) export ANSIBLE_COLLECTIONS_PATH=$(expand_path ./.venv/galaxy)
export ANSIBLE_ROLES_PATH=$(expand_path ./.venv/galaxy/ansible_roles) export ANSIBLE_ROLES_PATH=$(expand_path ./.venv/galaxy/ansible_roles)
-4
View File
@@ -1,7 +1,3 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Trash # Trash
.DS_Store .DS_Store
Thumbs.db Thumbs.db
+2
View File
@@ -17,6 +17,8 @@ vars:
SOPS_AGE_FILE: "{{.ROOT_DIR}}/age.key" SOPS_AGE_FILE: "{{.ROOT_DIR}}/age.key"
# Binaries # Binaries
PYTHON_BIN: python3 PYTHON_BIN: python3
# Python
PYTHONDONTWRITEBYTECODE: "1"
includes: includes:
ansible: .taskfiles/Ansible/Taskfile.yaml ansible: .taskfiles/Ansible/Taskfile.yaml
+41 -6
View File
@@ -1,12 +1,18 @@
import importlib.util
import sys
from collections.abc import Callable
from pathlib import Path
from typing import Any from typing import Any
import bcrypt
import makejinja
import netaddr
from typing import Any
from bcrypt import hashpw, gensalt
from netaddr import IPNetwork
import makejinja
import validation import validation
def nthhost(value: str, query: int) -> str: def nthhost(value: str, query: int) -> str:
value = netaddr.IPNetwork(value) value = IPNetwork(value)
try: try:
nth = int(query) nth = int(query)
if value.size > nth: if value.size > nth:
@@ -16,11 +22,40 @@ def nthhost(value: str, query: int) -> str:
return value return value
def encrypt(value: str) -> str: def encrypt(value: str) -> str:
return bcrypt.hashpw(value.encode(), bcrypt.gensalt(rounds=10)).decode("ascii") return hashpw(value.encode(), gensalt(rounds=10)).decode("ascii")
def import_filter(file: Path) -> Callable[[dict[str, Any]], bool]:
module_path = file.relative_to(Path.cwd()).with_suffix("")
module_name = str(module_path).replace("/", ".")
spec = importlib.util.spec_from_file_location(module_name, file)
assert spec is not None
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
assert spec.loader is not None
spec.loader.exec_module(module)
return module.main
class Plugin(makejinja.plugin.Plugin): class Plugin(makejinja.plugin.Plugin):
def __init__(self, data: dict[str, Any]): def __init__(self, data: dict[str, Any], config: makejinja.config.Config):
self._data = data
self._config = config
self._excluded_dirs: set[Path] = set()
for input_path in config.inputs:
for filter_file in input_path.rglob(".mjfilter.py"):
filter_func = import_filter(filter_file)
if filter_func(data) is False:
self._excluded_dirs.add(filter_file.parent)
validation.validate(data) validation.validate(data)
def filters(self) -> makejinja.plugin.Filters: def filters(self) -> makejinja.plugin.Filters:
return [nthhost, encrypt] return [nthhost, encrypt]
def path_filters(self):
return [self._mjfilter_func]
def _mjfilter_func(self, path: Path) -> bool:
return not any(
path.is_relative_to(excluded_dir) for excluded_dir in self._excluded_dirs
)
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
skip_list: skip_list:
- yaml[commas] - yaml[commas]
- yaml[line-length] - yaml[line-length]
@@ -8,4 +7,3 @@ warn_list:
- deprecated-command-syntax - deprecated-command-syntax
- experimental - experimental
- no-changed-when - no-changed-when
#% endif %#
+1
View File
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k0s', 'k3s']
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k0s', 'k3s']
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k3s']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
# https://github.com/PyratLabs/ansible-role-k3s # https://github.com/PyratLabs/ansible-role-k3s
# renovate: datasource=github-releases depName=k3s-io/k3s # renovate: datasource=github-releases depName=k3s-io/k3s
@@ -13,4 +12,3 @@ k3s_server_manifests_templates:
- custom-cilium-helmchart.yaml - custom-cilium-helmchart.yaml
- kube-vip-ds.yaml - kube-vip-ds.yaml
- kube-vip-rbac.yaml - kube-vip-rbac.yaml
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k3s']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
# https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/ # https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/
# https://github.com/PyratLabs/ansible-role-k3s # https://github.com/PyratLabs/ansible-role-k3s
@@ -40,4 +39,3 @@ k3s_server:
kubelet-arg: kubelet-arg:
- "image-gc-high-threshold=55" - "image-gc-high-threshold=55"
- "image-gc-low-threshold=50" - "image-gc-low-threshold=50"
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k3s']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
# https://rancher.com/docs/k3s/latest/en/installation/install-options/agent-config/ # https://rancher.com/docs/k3s/latest/en/installation/install-options/agent-config/
# https://github.com/PyratLabs/ansible-role-k3s # https://github.com/PyratLabs/ansible-role-k3s
@@ -13,4 +12,3 @@ k3s_agent:
kubelet-arg: kubelet-arg:
- "image-gc-high-threshold=55" - "image-gc-high-threshold=55"
- "image-gc-low-threshold=50" - "image-gc-low-threshold=50"
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
--- ---
kubernetes: kubernetes:
children: children:
@@ -18,4 +17,3 @@ kubernetes:
ansible_host: "#{ item.address }#" ansible_host: "#{ item.address }#"
#% endfor %# #% endfor %#
#% endif %# #% endif %#
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
--- ---
- name: Cluster kube-vip - name: Cluster kube-vip
hosts: master hosts: master
@@ -28,4 +27,3 @@
dest: "/var/lib/k0s/manifests/kube-vip/kube-vip-ds.yaml" dest: "/var/lib/k0s/manifests/kube-vip/kube-vip-ds.yaml"
#% endif %# #% endif %#
mode: preserve mode: preserve
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
--- ---
- name: Reboot - name: Reboot
hosts: kubernetes hosts: kubernetes
@@ -14,4 +13,3 @@
ansible.builtin.reboot: ansible.builtin.reboot:
msg: Rebooting nodes msg: Rebooting nodes
reboot_timeout: 3600 reboot_timeout: 3600
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
--- ---
# https://github.com/kevincoakley/ansible-role-k8s-rolling-update # https://github.com/kevincoakley/ansible-role-k8s-rolling-update
- name: Cluster rollout update - name: Cluster rollout update
@@ -56,8 +55,7 @@
terminate_grace_period: 600 terminate_grace_period: 600
wait_timeout: 900 wait_timeout: 900
pod_selectors: pod_selectors:
# Rook Ceph - app!=rook-ceph-osd # Rook Ceph
- app!=rook-ceph-osd
delegate_to: "{{ groups['master'][0] }}" delegate_to: "{{ groups['master'][0] }}"
- name: Update - name: Update
@@ -87,4 +85,3 @@
#% endif %# #% endif %#
state: uncordon state: uncordon
delegate_to: "{{ groups['master'][0] }}" delegate_to: "{{ groups['master'][0] }}"
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k3s']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
- name: Cilium - name: Cilium
block: block:
@@ -55,4 +54,3 @@
definition: definition:
metadata: metadata:
finalizers: [] finalizers: []
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
# https://github.com/k3s-io/k3s/issues/1971 # https://github.com/k3s-io/k3s/issues/1971
- name: Cruft - name: Cruft
@@ -31,4 +30,3 @@
namespace: kube-system namespace: kube-system
state: absent state: absent
loop: "{{ addons_list.resources | selectattr('metadata.name', 'match', '^custom-.*') | list }}" loop: "{{ addons_list.resources | selectattr('metadata.name', 'match', '^custom-.*') | list }}"
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
- name: Get absolute path to this Git repository # noqa: command-instead-of-module - name: Get absolute path to this Git repository # noqa: command-instead-of-module
ansible.builtin.command: git rev-parse --show-toplevel ansible.builtin.command: git rev-parse --show-toplevel
@@ -25,4 +24,3 @@
path: "{{ repository_path.stdout }}/kubeconfig" path: "{{ repository_path.stdout }}/kubeconfig"
regexp: https://127.0.0.1:6443 regexp: https://127.0.0.1:6443
replace: "https://{{ k3s_registration_address }}:6443" replace: "https://{{ k3s_registration_address }}:6443"
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k3s']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
# https://docs.k3s.io/helm # https://docs.k3s.io/helm
apiVersion: helm.cattle.io/v1 apiVersion: helm.cattle.io/v1
@@ -17,4 +16,3 @@ spec:
#% filter indent(width=4, first=True) %# #% filter indent(width=4, first=True) %#
#% include 'partials/cilium-values-init.partial.yaml.j2' %# #% include 'partials/cilium-values-init.partial.yaml.j2' %#
#% endfilter %# #% endfilter %#
#% endif %#
@@ -1,4 +1,2 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
#% include 'partials/kube-vip-ds.partial.yaml.j2' %# #% include 'partials/kube-vip-ds.partial.yaml.j2' %#
#% endif %#
@@ -1,4 +1,2 @@
#% if bootstrap_distribution in ['k3s'] %#
--- ---
#% include 'partials/kube-vip-rbac.partial.yaml.j2' %# #% include 'partials/kube-vip-rbac.partial.yaml.j2' %#
#% endif %#
@@ -1,7 +1,5 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
# Ansible # Ansible
ansible-lint==6.22.2 ansible-lint==6.22.2
ansible==9.1.0 ansible==9.1.0
jmespath==1.0.1 jmespath==1.0.1
openshift==0.13.2 openshift==0.13.2
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] %#
--- ---
collections: collections:
- name: ansible.posix - name: ansible.posix
@@ -15,4 +14,3 @@ roles:
src: https://github.com/PyratLabs/ansible-role-k3s src: https://github.com/PyratLabs/ansible-role-k3s
version: v3.4.3 version: v3.4.3
#% endif %# #% endif %#
#% endif %#
@@ -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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -61,4 +60,3 @@ spec:
- path: /data/config.toml - path: /data/config.toml
subPath: config.toml subPath: config.toml
readOnly: true readOnly: true
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_discord_template_notifier.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./secret.sops.yaml - ./secret.sops.yaml
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_discord_template_notifier.enabled %#
--- ---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@@ -13,4 +12,3 @@ stringData:
retry_limit = 5 retry_limit = 5
sink.type = "discord" sink.type = "discord"
sink.url = "#{ discord_template_notifier.webhook_url }#" sink.url = "#{ discord_template_notifier.webhook_url }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_discord_template_notifier.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@@ -76,4 +75,3 @@ data:
dateStyle: long dateStyle: long
timeStyle: short timeStyle: short
hourCycle: h23 hourCycle: h23
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
--- ---
apiVersion: helm.toolkit.fluxcd.io/v2beta2 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -86,4 +85,3 @@ spec:
path: /app/config/widgets.yaml path: /app/config/widgets.yaml
serviceAccount: serviceAccount:
create: true create: true
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
@@ -6,4 +5,3 @@ resources:
- ./configmap.yaml - ./configmap.yaml
- ./helmrelease.yaml - ./helmrelease.yaml
- ./secret.sops.yaml - ./secret.sops.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
--- ---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@@ -10,4 +9,3 @@ stringData:
HOMEPAGE_VAR_CLOUDFLARED_API_TOKEN: "#{ bootstrap_cloudflare_token }#" HOMEPAGE_VAR_CLOUDFLARED_API_TOKEN: "#{ bootstrap_cloudflare_token }#"
HOMEPAGE_VAR_GRAFANA_USERNAME: admin HOMEPAGE_VAR_GRAFANA_USERNAME: admin
HOMEPAGE_VAR_GRAFANA_PASSWORD: "#{ grafana.password }#" HOMEPAGE_VAR_GRAFANA_PASSWORD: "#{ grafana.password }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_homepage.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -55,4 +54,3 @@ spec:
impersonationResourceNames: ["admin"] impersonationResourceNames: ["admin"]
podAnnotations: podAnnotations:
secret.reloader.stakater.com/reload: cluster-user-auth secret.reloader.stakater.com/reload: cluster-user-auth
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_weave_gitops.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./secret.sops.yaml - ./secret.sops.yaml
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_weave_gitops.enabled %#
--- ---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@@ -8,4 +7,3 @@ type: Opaque
stringData: stringData:
username: admin username: admin
password: "#{ addon_weave_gitops.password | encrypt }#" password: "#{ addon_weave_gitops.password | encrypt }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_weave_gitops.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -27,4 +26,3 @@ spec:
#% filter indent(width=4, first=True) %# #% filter indent(width=4, first=True) %#
#% include 'partials/kubelet-csr-approver-values.partial.yaml.j2' %# #% include 'partials/kubelet-csr-approver-values.partial.yaml.j2' %#
#% endfilter %# #% endfilter %#
#% endif %#
@@ -1,7 +1,5 @@
#% if bootstrap_distribution in ['talos'] %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['talos'] %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -28,10 +27,12 @@ spec:
#% if bootstrap_distribution in ['k0s'] %# #% if bootstrap_distribution in ['k0s'] %#
containerdSock: /run/k0s/containerd.sock containerdSock: /run/k0s/containerd.sock
containerdRegistryConfigPath: /var/lib/k0s/containerd/certs.d containerdRegistryConfigPath: /var/lib/k0s/containerd/certs.d
#% elif bootstrap_distribution in ['talos'] %#
containerdSock: /run/containerd/containerd.sock
containerdRegistryConfigPath: /etc/cri/conf.d/hosts
#% endif %# #% endif %#
service: service:
registry: registry:
hostPort: 29999 hostPort: 29999
serviceMonitor: serviceMonitor:
enabled: true enabled: true
#% endif %#
@@ -1,7 +1,5 @@
#% if bootstrap_distribution in ['k0s', 'talos'] %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'talos'] %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./namespace.yaml - ./namespace.yaml
- ./longhorn/ks.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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -45,4 +44,3 @@ spec:
ingressClassName: internal ingressClassName: internal
host: longhorn.${SECRET_DOMAIN} host: longhorn.${SECRET_DOMAIN}
tls: true tls: true
#% endif %#
@@ -1,8 +1,6 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
- ./snapshot.yaml - ./snapshot.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
--- ---
apiVersion: storage.k8s.io/v1 apiVersion: storage.k8s.io/v1
kind: StorageClass kind: StorageClass
@@ -13,4 +12,3 @@ allowVolumeExpansion: true
volumeBindingMode: Immediate volumeBindingMode: Immediate
metadata: metadata:
name: longhorn-snapshot name: longhorn-snapshot
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m timeout: 5m
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
--- ---
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
@@ -6,4 +5,3 @@ metadata:
name: longhorn-system name: longhorn-system
labels: labels:
kustomize.toolkit.fluxcd.io/prune: disabled 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -180,4 +179,3 @@ spec:
storageClassName: openebs-hostpath storageClassName: openebs-hostpath
testFramework: testFramework:
enabled: false enabled: false
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_grafana.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./secret.sops.yaml - ./secret.sops.yaml
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_grafana.enabled %#
--- ---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@@ -7,4 +6,3 @@ metadata:
stringData: stringData:
admin-user: admin admin-user: admin
admin-password: "#{ grafana.password }#" admin-password: "#{ grafana.password }#"
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_grafana.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -159,4 +158,3 @@ spec:
multicluster: multicluster:
etcd: etcd:
enabled: true enabled: true
#% endif %#
@@ -1,7 +1,5 @@
#% if addon_kube_prometheus_stack.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_kube_prometheus_stack.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -45,4 +44,3 @@ spec:
- *host - *host
metricsScraper: metricsScraper:
enabled: true enabled: true
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_kubernetes_dashboard.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./rbac.yaml - ./rbac.yaml
- ./helmrelease.yaml - ./helmrelease.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_kubernetes_dashboard.enabled %#
# 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
--- ---
@@ -38,4 +37,3 @@ subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: kubernetes-dashboard name: kubernetes-dashboard
namespace: observability namespace: observability
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_kubernetes_dashboard.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -22,4 +21,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -29,4 +28,3 @@ spec:
#% if bootstrap_distribution in ['k0s'] %# #% if bootstrap_distribution in ['k0s'] %#
kubeletDir: /var/lib/k0s/kubelet kubeletDir: /var/lib/k0s/kubelet
#% endif %# #% endif %#
#% endif %#
@@ -1,8 +1,8 @@
#% if addon_csi_driver_nfs.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
#% if addon_csi_driver_nfs.storage_class|length > 0 %#
- ./storageclass.yaml - ./storageclass.yaml
#% endif %# #% endif %#
@@ -1,4 +1,3 @@
#% if addon_csi_driver_nfs.enabled %#
#% for item in addon_csi_driver_nfs.storage_class %# #% for item in addon_csi_driver_nfs.storage_class %#
--- ---
apiVersion: storage.k8s.io/v1 apiVersion: storage.k8s.io/v1
@@ -13,4 +12,3 @@ reclaimPolicy: Delete
volumeBindingMode: Immediate volumeBindingMode: Immediate
mountOptions: ["hard", "noatime"] mountOptions: ["hard", "noatime"]
#% endfor %# #% endfor %#
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_csi_driver_nfs.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -30,4 +29,3 @@ spec:
#% else %# #% else %#
kubelet: /var/lib/kubelet kubelet: /var/lib/kubelet
#% endif %# #% endif %#
#% endif %#
@@ -1,11 +1,11 @@
#% if addon_csi_driver_smb.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
#% if addon_csi_driver_smb.storage_class|length > 0 %#
- ./storageclass.yaml - ./storageclass.yaml
#% endif %#
#% if addon_csi_driver_smb.create_secrets|default(true) %# #% if addon_csi_driver_smb.create_secrets|default(true) %#
- ./secrets.sops.yaml - ./secrets.sops.yaml
#% endif %# #% 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 %# #% for item in addon_csi_driver_smb.storage_class %#
#% if not item.existing_secret_name %# #% 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 %# #% for item in addon_csi_driver_smb.storage_class %#
--- ---
apiVersion: storage.k8s.io/v1 apiVersion: storage.k8s.io/v1
@@ -22,4 +21,3 @@ mountOptions:
- cache=strict - cache=strict
- noserverino # required to prevent data corruption - noserverino # required to prevent data corruption
#% endfor %# #% endfor %#
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_csi_driver_smb.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -19,4 +18,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m 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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -40,4 +39,3 @@ spec:
tag: *tag tag: *tag
metrics: metrics:
disableAuth: true disableAuth: true
#% endif %#
@@ -1,8 +1,6 @@
#% if addon_volsync.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
- ./prometheusrule.yaml - ./prometheusrule.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_volsync.enabled %#
--- ---
apiVersion: monitoring.coreos.com/v1 apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule kind: PrometheusRule
@@ -22,4 +21,3 @@ spec:
for: 15m for: 15m
labels: labels:
severity: critical severity: critical
#% endif %#
@@ -1,4 +1,3 @@
#% if addon_volsync.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -10,10 +9,6 @@ spec:
commonMetadata: commonMetadata:
labels: labels:
app.kubernetes.io/name: *app app.kubernetes.io/name: *app
#% if addon_longhorn.enabled %#
dependsOn:
- name: longhorn
#% endif %#
path: ./kubernetes/apps/storage/volsync/snapshot-controller path: ./kubernetes/apps/storage/volsync/snapshot-controller
prune: true prune: true
sourceRef: sourceRef:
@@ -43,4 +38,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m timeout: 5m
#% endif %#
@@ -25,6 +25,11 @@ spec:
retries: 3 retries: 3
uninstall: uninstall:
keepHistory: false keepHistory: false
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
dependsOn:
- name: longhorn
namespace: longhorn-system
#% endif %#
values: values:
controller: controller:
#% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %# #% if bootstrap_distribution in ['k0s', 'k3s'] and addon_longhorn.enabled %#
@@ -1,7 +1,5 @@
#% if addon_volsync.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./helmrelease.yaml - ./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 apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease kind: HelmRelease
@@ -102,4 +101,3 @@ spec:
globalMounts: globalMounts:
- path: /etc/ca-certificates - path: /etc/ca-certificates
readOnly: true readOnly: true
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
@@ -7,4 +6,3 @@ resources:
- https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.2/crd.yaml - https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.2/crd.yaml
- helmrelease.yaml - helmrelease.yaml
- rbac.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 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
@@ -12,4 +11,3 @@ subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: system-upgrade name: system-upgrade
namespace: tools namespace: tools
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
--- ---
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
@@ -41,4 +40,3 @@ spec:
interval: 30m interval: 30m
retryInterval: 1m retryInterval: 1m
timeout: 5m timeout: 5m
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
--- ---
apiVersion: upgrade.cattle.io/v1 apiVersion: upgrade.cattle.io/v1
kind: Plan kind: Plan
@@ -17,4 +16,3 @@ spec:
args: ["prepare", "server"] args: ["prepare", "server"]
upgrade: upgrade:
image: rancher/k3s-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 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./server.yaml - ./server.yaml
- ./agent.yaml - ./agent.yaml
#% endif %#
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k3s'] and addon_system_upgrade_controller.enabled %#
--- ---
apiVersion: upgrade.cattle.io/v1 apiVersion: upgrade.cattle.io/v1
kind: Plan kind: Plan
@@ -22,4 +21,3 @@ spec:
- {key: CriticalAddonsOnly, operator: Exists} - {key: CriticalAddonsOnly, operator: Exists}
upgrade: upgrade:
image: rancher/k3s-upgrade image: rancher/k3s-upgrade
#% endif %#
@@ -0,0 +1 @@
main = lambda data: data.get("bootstrap_distribution") in ['k0s']
@@ -1,4 +1,3 @@
#% if bootstrap_distribution in ['k0s'] %#
--- ---
apiVersion: k0sctl.k0sproject.io/v1beta1 apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster kind: Cluster
@@ -98,4 +97,3 @@ spec:
#% filter indent(width=18, first=True) %# #% filter indent(width=18, first=True) %#
#% include 'partials/cilium-values-init.partial.yaml.j2' %# #% include 'partials/cilium-values-init.partial.yaml.j2' %#
#% endfilter %# #% endfilter %#
#% endif %#
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more