cmd/k8s-operator: add affinity rules to DNSConfig (#19360)

This commit modifies the `DNSConfig` custom resource to allow the
user to specify affinity rules on the nameserver pods.

Updates: https://github.com/tailscale/tailscale/issues/18556

Signed-off-by: David Bond <davidsbond93@gmail.com>
This commit is contained in:
David Bond
2026-04-15 22:39:04 +01:00
committed by GitHub
parent acc43356c6
commit eea39eaf52
7 changed files with 1792 additions and 0 deletions
+3
View File
@@ -190,6 +190,7 @@ func (a *NameserverReconciler) maybeProvision(ctx context.Context, tsDNSCfg *tsa
}
if tsDNSCfg.Spec.Nameserver.Pod != nil {
dCfg.tolerations = tsDNSCfg.Spec.Nameserver.Pod.Tolerations
dCfg.affinity = tsDNSCfg.Spec.Nameserver.Pod.Affinity
}
for _, deployable := range []deployable{saDeployable, deployDeployable, svcDeployable, cmDeployable} {
@@ -225,6 +226,7 @@ type deployConfig struct {
namespace string
clusterIP string
tolerations []corev1.Toleration
affinity *corev1.Affinity
}
var (
@@ -250,6 +252,7 @@ var (
d.ObjectMeta.Labels = cfg.labels
d.ObjectMeta.OwnerReferences = cfg.ownerRefs
d.Spec.Template.Spec.Tolerations = cfg.tolerations
d.Spec.Template.Spec.Affinity = cfg.affinity
updateF := func(oldD *appsv1.Deployment) {
oldD.Spec = d.Spec
}