diff --git a/.github/tests/config-k0s.yaml b/.github/tests/config-k0s.yaml index 95510d19..f5a44761 100644 --- a/.github/tests/config-k0s.yaml +++ b/.github/tests/config-k0s.yaml @@ -22,11 +22,9 @@ bootstrap_k8s_gateway_addr: 10.10.10.253 bootstrap_external_ingress_addr: 10.10.10.252 bootstrap_internal_ingress_addr: 10.10.10.251 bootstrap_dns_server: 1.1.1.1 -bootstrap_cilium_loadbalancer_mode: dsr bootstrap_ipv6_enabled: false bootstrap_cluster_cidr: 10.42.0.0/16 bootstrap_service_cidr: 10.43.0.0/16 -bootstrap_local_storage_path: /var/openebs/local bootstrap_nodes: master: - name: k8s-0 diff --git a/.github/tests/config-k3s-ipv4.yaml b/.github/tests/config-k3s-ipv4.yaml index ce75ee68..215b6e8c 100644 --- a/.github/tests/config-k3s-ipv4.yaml +++ b/.github/tests/config-k3s-ipv4.yaml @@ -22,11 +22,9 @@ bootstrap_k8s_gateway_addr: 10.10.10.253 bootstrap_external_ingress_addr: 10.10.10.252 bootstrap_internal_ingress_addr: 10.10.10.251 bootstrap_dns_server: 1.1.1.1 -bootstrap_cilium_loadbalancer_mode: dsr bootstrap_ipv6_enabled: false bootstrap_cluster_cidr: 10.42.0.0/16 bootstrap_service_cidr: 10.43.0.0/16 -bootstrap_local_storage_path: /var/openebs/local bootstrap_nodes: master: - name: k8s-0 diff --git a/.github/tests/config-k3s-ipv6.yaml b/.github/tests/config-k3s-ipv6.yaml index 0a509d75..512174e8 100644 --- a/.github/tests/config-k3s-ipv6.yaml +++ b/.github/tests/config-k3s-ipv6.yaml @@ -21,12 +21,10 @@ bootstrap_kube_api_hostname: fake bootstrap_k8s_gateway_addr: 10.10.10.253 bootstrap_external_ingress_addr: 10.10.10.252 bootstrap_internal_ingress_addr: 10.10.10.251 -bootstrap_cilium_loadbalancer_mode: dsr bootstrap_dns_server: 1.1.1.1 bootstrap_ipv6_enabled: true bootstrap_cluster_cidr: 10.42.0.0/16,fd7f:8f5:e87c:a::/64 bootstrap_service_cidr: 10.43.0.0/16,fd7f:8f5:e87c:e::/112 -bootstrap_local_storage_path: /var/openebs/local bootstrap_nodes: master: - name: k8s-0 diff --git a/.github/tests/config-k3s-no-kube-vip.yaml b/.github/tests/config-k3s-no-kube-vip.yaml index 35e19fd0..88e64bd5 100644 --- a/.github/tests/config-k3s-no-kube-vip.yaml +++ b/.github/tests/config-k3s-no-kube-vip.yaml @@ -22,11 +22,9 @@ bootstrap_k8s_gateway_addr: 10.10.10.253 bootstrap_external_ingress_addr: 10.10.10.252 bootstrap_internal_ingress_addr: 10.10.10.251 bootstrap_dns_server: 1.1.1.1 -bootstrap_cilium_loadbalancer_mode: dsr bootstrap_ipv6_enabled: false bootstrap_cluster_cidr: 10.42.0.0/16 bootstrap_service_cidr: 10.43.0.0/16 -bootstrap_local_storage_path: /var/openebs/local bootstrap_nodes: master: - name: k8s-0 diff --git a/.github/tests/config-talos.yaml b/.github/tests/config-talos.yaml index 1ee3b64b..15d1540c 100644 --- a/.github/tests/config-talos.yaml +++ b/.github/tests/config-talos.yaml @@ -21,12 +21,10 @@ bootstrap_kube_api_hostname: fake bootstrap_k8s_gateway_addr: 10.10.10.253 bootstrap_external_ingress_addr: 10.10.10.252 bootstrap_internal_ingress_addr: 10.10.10.251 -bootstrap_cilium_loadbalancer_mode: dsr bootstrap_dns_server: 1.1.1.1 bootstrap_ipv6_enabled: false bootstrap_cluster_cidr: 10.42.0.0/16 bootstrap_service_cidr: 10.43.0.0/16 -bootstrap_local_storage_path: /var/openebs/local bootstrap_nodes: master: - name: k8s-0 diff --git a/bootstrap/scripts/loader.py b/bootstrap/scripts/loader.py index e5ba7f7e..b053741e 100644 --- a/bootstrap/scripts/loader.py +++ b/bootstrap/scripts/loader.py @@ -31,8 +31,6 @@ class Loader: validation.validate_cloudflare(data) validation.validate_host_network(data) validation.validate_bootstrap_dns_server(data) - validation.validate_cilium_loadbalancer_mode(data) - validation.validate_local_storage_path(data) validation.validate_cluster_cidrs(data) validation.validate_nodes(data) diff --git a/bootstrap/scripts/validation.py b/bootstrap/scripts/validation.py index 6d1de1d8..845d1bad 100644 --- a/bootstrap/scripts/validation.py +++ b/bootstrap/scripts/validation.py @@ -1,6 +1,5 @@ from email_validator import validate_email, EmailNotValidError from functools import wraps -from pathvalidate import is_valid_filepath, ValidationError from shutil import which from typing import Callable, Optional from zoneinfo import available_timezones @@ -11,11 +10,10 @@ import requests import socket import sys -DISTRIBUTIONS = ["k0s", "k3s", "talos"] -CILIUM_LOADBALANCER_MODES = ["dsr", "snat"] -GLOBAL_CLI_TOOLS = ["age", "cloudflared", "flux", "sops", "jq", "kubeconform", "kustomize"] -TALOS_CLI_TOOLS = ["talosctl", "talhelper"] -K0S_CLI_TOOLS = ["k0sctl"] +DISTRIBUTIONS = ["k0s", "k3s", "talos"] +GLOBAL_CLI_TOOLS = ["age", "cloudflared", "flux", "sops", "jq", "kubeconform", "kustomize"] +TALOS_CLI_TOOLS = ["talosctl", "talhelper"] +K0S_CLI_TOOLS = ["k0sctl"] def required(*keys: str): def wrapper_outter(func: Callable): @@ -158,19 +156,6 @@ def validate_cloudflare(domain: str, token: str, account_tag: str, tunnel_secret except CloudFlare.exceptions.CloudFlareAPIError as e: raise ValueError(f"Cloudflare domain {domain} not found or token does not have access to it") from e -@required("bootstrap_cilium_loadbalancer_mode") -def validate_cilium_loadbalancer_mode(mode: str, **_) -> None: - if mode not in CILIUM_LOADBALANCER_MODES: - raise ValueError(f"Invalid Cilium load balancer mode {mode}") - -@required("bootstrap_local_storage_path") -def validate_local_storage_path(path: str, **_) -> None: - try: - if not is_valid_filepath(path, platform="linux"): - raise ValueError(f"Invalid local storage path {path}") - except ValidationError as e: - raise ValueError(f"Invalid local storage path {path}") from e - @required("bootstrap_dns_server") def validate_bootstrap_dns_server(dns_server: str, **_) -> None: _validate_ip(dns_server) diff --git a/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 b/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 index ca86af25..21eabb0f 100644 --- a/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 +++ b/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 @@ -93,7 +93,7 @@ - name: Remove local storage path ansible.builtin.file: - path: "#{ bootstrap_local_storage_path }#" + path: "#{ bootstrap_advanced_flags.local_storage_path|default('/var/openebs/local', true) }#" state: absent - name: Reboot diff --git a/bootstrap/templates/kubernetes/apps/storage/openebs/app/helmrelease.yaml.j2 b/bootstrap/templates/kubernetes/apps/storage/openebs/app/helmrelease.yaml.j2 index 16fec3dd..0cd13e40 100644 --- a/bootstrap/templates/kubernetes/apps/storage/openebs/app/helmrelease.yaml.j2 +++ b/bootstrap/templates/kubernetes/apps/storage/openebs/app/helmrelease.yaml.j2 @@ -28,4 +28,4 @@ spec: enabled: true name: openebs-hostpath isDefaultClass: false - basePath: "#{ bootstrap_local_storage_path }#" + basePath: "#{ bootstrap_advanced_flags.local_storage_path|default('/var/openebs/local', true) }#" diff --git a/bootstrap/templates/kubernetes/k0s/resources/hooks/reset-system.sh.j2 b/bootstrap/templates/kubernetes/k0s/resources/hooks/reset-system.sh.j2 index 48695e77..ee63be36 100755 --- a/bootstrap/templates/kubernetes/k0s/resources/hooks/reset-system.sh.j2 +++ b/bootstrap/templates/kubernetes/k0s/resources/hooks/reset-system.sh.j2 @@ -4,7 +4,7 @@ [ $(id -u) -eq 0 ] || exec sudo $0 $@ # Remove local storage data -rm -rf "#{ bootstrap_local_storage_path }#" +rm -rf "#{ bootstrap_advanced_flags.local_storage_path|default('/var/openebs/local', true) }#" # Reboot (sleep 10 && systemctl reboot)& diff --git a/bootstrap/templates/partials/cilium-values-full.partial.yaml.j2 b/bootstrap/templates/partials/cilium-values-full.partial.yaml.j2 index 8cc5ecd3..c9c65b49 100644 --- a/bootstrap/templates/partials/cilium-values-full.partial.yaml.j2 +++ b/bootstrap/templates/partials/cilium-values-full.partial.yaml.j2 @@ -88,7 +88,7 @@ l2announcements: #% endif %# loadBalancer: algorithm: maglev - mode: "#{ bootstrap_cilium_loadbalancer_mode|default('dsr', true) }#" + mode: "#{ bootstrap_advanced_flags.cilium_loadbalancer_mode|default('dsr', true) }#" localRedirectPolicy: true operator: replicas: 1 diff --git a/bootstrap/templates/partials/cilium-values-init.partial.yaml.j2 b/bootstrap/templates/partials/cilium-values-init.partial.yaml.j2 index 0dd69d17..6efd4829 100644 --- a/bootstrap/templates/partials/cilium-values-init.partial.yaml.j2 +++ b/bootstrap/templates/partials/cilium-values-init.partial.yaml.j2 @@ -49,7 +49,7 @@ l2announcements: #% endif %# loadBalancer: algorithm: maglev - mode: "#{ bootstrap_cilium_loadbalancer_mode|default('dsr', true) }#" + mode: "#{ bootstrap_advanced_flags.cilium_loadbalancer_mode|default('dsr', true) }#" localRedirectPolicy: true operator: replicas: 1 diff --git a/bootstrap/vars/config.sample.yaml b/bootstrap/vars/config.sample.yaml index 2fb5be5c..d47221a5 100644 --- a/bootstrap/vars/config.sample.yaml +++ b/bootstrap/vars/config.sample.yaml @@ -62,12 +62,6 @@ bootstrap_internal_ingress_addr: # 3. you are not force redirecting DNS requests to it - this will break cert generation over DNS01 bootstrap_dns_server: 1.1.1.1 -# (Advanced) Cilium load balancer mode, choose either 'dsr' or 'snat' -# Due to unknown reasons some people need this set to 'snat' in order -# for Cilium L2 announcements to work properly. Keep this dsr unless -# you have issues with connecting to Cilium L2 announcements. -bootstrap_cilium_loadbalancer_mode: dsr - # Keep the next three options default unless you know what you are doing # (Advanced) Enable ipv6 bootstrap_ipv6_enabled: false @@ -77,9 +71,6 @@ bootstrap_cluster_cidr: 10.42.0.0/16 # (Advanced) For ipv6 use format 10.43.0.0/16,fd78:c889:47fb:e0::/112 bootstrap_service_cidr: 10.43.0.0/16 -# (Advanced) Path for openebs openebs-hostpath to use for storage on ALL nodes -bootstrap_local_storage_path: /var/openebs/local - # Node information bootstrap_nodes: # Use only 1, 3 or more odd master nodes, recommended is 3 @@ -98,7 +89,16 @@ bootstrap_nodes: # # Do not make changes below this line unless you know what you are doing +# These options are not validated and may break your cluster # # bootstrap_advanced_flags: -# update_resolv_conf: true # Disable to prevent changes to nodes /etc/resolv.conf +# # Disable to prevent changes to nodes /etc/resolv.conf +# update_resolv_conf: true +# # Cilium load balancer mode, choose either 'dsr' or 'snat' +# # Due to unknown reasons some people need this set to 'snat' in order +# # for Cilium L2 announcements to work properly. Keep this dsr unless +# # you have issues with connecting to Cilium L2 announcements. +# cilium_loadbalancer_mode: dsr +# # Path for openebs openebs-hostpath to use for storage on ALL nodes +# local_storage_path: /var/openebs/local diff --git a/requirements.txt b/requirements.txt index b1a882ee..b57b43e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ email-validator==2.1.0 makejinja==2.3.5 netaddr==0.10.1 passlib==1.7.4 -pathvalidate==3.2.0