chore(clustertool) change included patch format and add nvidia patch (#31813)

**Description**
Change clustertool included patches from RFC6902 (json patches) to
strategic merge patches, see
[talos-guides](https://www.talos.dev/v1.9/talos-guides/configuration/patching/).
This allows for the used to easily add to some of the "list" values like
sysctls and kernel modules.

For example, this list operation overwrites any previous adds to
sysctls.
```yaml
- op: add
  path: /machine/sysctls
  value:
    fs.inotify.max_queued_events: "65536"
    fs.inotify.max_user_instances: "8192"
```

this is not the case when using strategic merge patches
```yaml
machine:
  sysctls:
    fs.inotify.max_queued_events: "65536"
    fs.inotify.max_user_instances: "8192"
```

for example nvidia.yaml can add to this
```yaml
machine:
  sysctls:
    net.core.bpf_jit_harden: 1
```
⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [x] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
I ran clustertool genconfig with the default configs before and after
the change. The resulting main-k8s-control-1.yaml was identical (except,
see below).

**📃 Notes:**

The bind addresses for proxy and scheduler did never end up in the
generated config because they got overwritten by subsequent patch
operations. Now these entries will be in the generated config, not sure
if that could be an issue?

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning
- [x] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
This commit is contained in:
jogotcha
2025-02-09 11:25:51 +01:00
committed by GitHub
parent 5fd65bb3d5
commit 10d5877232
4 changed files with 125 additions and 152 deletions
+42 -54
View File
@@ -1,33 +1,26 @@
- op: replace cluster:
path: /machine/time proxy:
value: disabled: true
"disabled": false machine:
"servers": time:
- "time.cloudflare.com" disabled: false
- op: replace servers:
path: /cluster/proxy - time.cloudflare.com
value: kubelet:
"disabled": true extraArgs:
- op: add rotate-server-certificates: "true"
path: /machine/kubelet/extraArgs extraConfig:
value: maxPods: 250
"rotate-server-certificates": true shutdownGracePeriod: 15s
- op: add shutdownGracePeriodCriticalPods: 10s
path: /machine/kubelet/extraConfig extraMounts:
value: - destination: /var/openebs/local
"maxPods": 250 type: bind
"shutdownGracePeriod": "15s" source: /var/openebs/local
"shutdownGracePeriodCriticalPods": "10s" options:
- op: add - bind
path: /machine/kubelet/extraMounts - rshared
value: - rw
- "destination": "/var/openebs/local"
"type": "bind"
"source": "/var/openebs/local"
"options":
- "bind"
- "rshared"
- "rw"
- destination: /var/lib/longhorn - destination: /var/lib/longhorn
type: bind type: bind
source: /var/lib/longhorn source: /var/lib/longhorn
@@ -35,15 +28,12 @@
- bind - bind
- rshared - rshared
- rw - rw
- op: replace features:
path: /machine/features/hostDNS hostDNS:
value:
enabled: true enabled: true
resolveMemberNames: true
forwardKubeDNSToHost: true forwardKubeDNSToHost: true
- op: add resolveMemberNames: true
path: /machine/sysctls sysctls:
value:
fs.inotify.max_queued_events: "65536" fs.inotify.max_queued_events: "65536"
fs.inotify.max_user_instances: "8192" fs.inotify.max_user_instances: "8192"
fs.inotify.max_user_watches: "524288" fs.inotify.max_user_watches: "524288"
@@ -58,10 +48,8 @@
net.ipv4.tcp_wmem: 4096 65536 33554432 # 10Gb/s net.ipv4.tcp_wmem: 4096 65536 33554432 # 10Gb/s
net.ipv4.tcp_window_scaling: 1 # 10Gb/s net.ipv4.tcp_window_scaling: 1 # 10Gb/s
vm.nr_hugepages: 1024 # PostgreSQL vm.nr_hugepages: 1024 # PostgreSQL
registries:
- op: add mirrors:
path: /machine/registries/mirrors
value:
cgr.dev: cgr.dev:
endpoints: endpoints:
- https://cgr.dev - https://cgr.dev
@@ -70,35 +58,35 @@
- https://mirror.gcr.io - https://mirror.gcr.io
- https://registry-1.docker.io - https://registry-1.docker.io
- https://docker.io - https://docker.io
registry-1.docker.io: factory.talos.dev:
endpoints: endpoints:
- https://mirror.gcr.io - https://factory.talos.dev
- https://registry-1.docker.io gcr.io:
endpoints:
- https://gcr.io
ghcr.io: ghcr.io:
endpoints: endpoints:
- https://ghcr.io - https://ghcr.io
quay.io: k8s.gcr.io:
endpoints: endpoints:
- https://quay.io - https://k8s.gcr.io
mcr.microsoft.com: mcr.microsoft.com:
endpoints: endpoints:
- https://mcr.microsoft.com - https://mcr.microsoft.com
public.ecr.aws: public.ecr.aws:
endpoints: endpoints:
- https://public.ecr.aws - https://public.ecr.aws
gcr.io: quay.io:
endpoints: endpoints:
- https://gcr.io - https://quay.io
registry-1.docker.io:
endpoints:
- https://mirror.gcr.io
- https://registry-1.docker.io
registry.k8s.io: registry.k8s.io:
endpoints: endpoints:
- https://registry.k8s.io - https://registry.k8s.io
k8s.gcr.io:
endpoints:
- https://k8s.gcr.io
tccr.io: tccr.io:
endpoints: endpoints:
- https://quay.io - https://quay.io
- https://tccr.io - https://tccr.io
factory.talos.dev:
endpoints:
- https://factory.talos.dev
@@ -1,40 +1,28 @@
- op: add machine:
path: /cluster/proxy/extraArgs features:
value: kubernetesTalosAPIAccess:
"metrics-bind-address": "0.0.0.0:10249" enabled: true
- op: add allowedRoles:
path: /cluster/controllerManager/extraArgs - os:admin
value: allowedKubernetesNamespaces:
"bind-address": "0.0.0.0" - system-upgrade
cluster:
- op: add controllerManager:
path: /cluster/scheduler/extraArgs extraArgs:
value: bind-address: 0.0.0.0
"bind-address": "0.0.0.0" proxy:
extraArgs:
- op: add metrics-bind-address: 0.0.0.0:10249
path: /cluster/apiServer/extraArgs apiServer:
value: extraArgs:
enable-aggregator-routing: true enable-aggregator-routing: "true"
runtime-config: admissionregistration.k8s.io/v1alpha1=true
feature-gates: MutatingAdmissionPolicy=true feature-gates: MutatingAdmissionPolicy=true
runtime-config: admissionregistration.k8s.io/v1alpha1=true
- op: replace admissionControl:
path: /cluster/apiServer/admissionControl
value:
- name: PodSecurity - name: PodSecurity
configuration: configuration:
apiVersion: pod-security.admission.config.k8s.io/v1alpha1
defaults:
audit: restricted
audit-version: latest
enforce: baseline
enforce-version: latest
warn: restricted
warn-version: latest
exemptions: exemptions:
namespaces: namespaces:
- kube-system
- metallb - metallb
- metallb-config - metallb-config
- topolvm-system - topolvm-system
@@ -45,34 +33,23 @@
- snapshot-controller - snapshot-controller
- volsync - volsync
- flux-system - flux-system
runtimeClasses: [] scheduler:
usernames: [] extraArgs:
kind: PodSecurityConfiguration bind-address: 0.0.0.0
- op: add
path: /machine/features/kubernetesTalosAPIAccess
value:
enabled: true
allowedRoles:
- os:admin
allowedKubernetesNamespaces:
- system-upgrade
- op: add
path: /cluster/scheduler
value:
config: config:
apiVersion: kubescheduler.config.k8s.io/v1 apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration kind: KubeSchedulerConfiguration
profiles: profiles:
- schedulerName: default-scheduler - pluginConfig:
plugins: - args:
score:
disabled:
- name: ImageLocality
pluginConfig:
- name: PodTopologySpread
args:
defaultingType: List
defaultConstraints: defaultConstraints:
- maxSkew: 1 - maxSkew: 1
topologyKey: kubernetes.io/hostname topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway whenUnsatisfiable: ScheduleAnyway
defaultingType: List
name: PodTopologySpread
plugins:
score:
disabled:
- name: ImageLocality
schedulerName: default-scheduler
@@ -0,0 +1,9 @@
machine:
kernel:
modules:
- name: nvidia
- name: nvidia_uvm
- name: nvidia_drm
- name: nvidia_modeset
sysctls:
net.core.bpf_jit_harden: 1
@@ -1,6 +1,5 @@
- op: replace machine:
path: /machine/time time:
value: disabled: false
"disabled": false servers:
"servers": - time.cloudflare.com
- "time.cloudflare.com"