Hi,
I saw this issue recently in the control-plane repo: siderolabs/cluster-api-control-plane-provider-talos#230
and thought "yeah, that would be neat". Then I saw that a few years back variable support in config patches was already considered
#96
So I thought I could have a go at this and so have implemented some basic variables using go templates in my fork. It looks like this:
- we have 2 variables exposed by default -
{{ .Cluster.Name }} and {{ .Machine.Name }} - of course, we could have more, such as {{ .Machine.ProviderID }} or {{ .Cluster.Version }}
- we have a way of defining custom variables, including sourcing them from secrets
An example configuration for TalosConfigTemplate:
spec:
template:
spec:
generateType: worker
talosVersion: v1.12.2
variables:
- name: supersecret
valueFrom:
secretKeyRef:
name: somesecret
key: somekey
- name: disk
value: /dev/sda
strategicPatches:
- |
machine:
network:
hostname: {{ .Machine.Name }}
install:
image: factory.talos.dev/nocloud-installer/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515:v1.12.2
extraKernelArgs:
- net.ifnames=0
disk: {{ .Vars.disk }}
wipe: true
kubelet:
extraConfig:
serverTLSBootstrap: true
extraArgs:
cloud-provider: external
rotate-server-certificates: true
features:
rbac: true
kubePrism:
enabled: true
port: 7445
hostDNS:
enabled: true
forwardKubeDNSToHost: true
I'm interested to see some opinions on this. Some things that I think should be considered still:
- templating engine - currently using text/template which I'm not convinced is ideal since it includes features such as control flow which I'm not exactly sure have a place here - perhaps we should stick to just variable expansions
- what other variables should we expose to the config?
- should we limit this to strategicPatches and data fields? should this work with configPatches as well?
- should there be a flag that explicitly enables templating of the configuration?
Hi,
I saw this issue recently in the control-plane repo: siderolabs/cluster-api-control-plane-provider-talos#230
and thought "yeah, that would be neat". Then I saw that a few years back variable support in config patches was already considered
#96
So I thought I could have a go at this and so have implemented some basic variables using go templates in my fork. It looks like this:
{{ .Cluster.Name }}and{{ .Machine.Name }}- of course, we could have more, such as{{ .Machine.ProviderID }}or{{ .Cluster.Version }}An example configuration for TalosConfigTemplate:
I'm interested to see some opinions on this. Some things that I think should be considered still: