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
+34
View File
@@ -51,6 +51,23 @@ func TestNameserverReconciler(t *testing.T) {
Effect: corev1.TaintEffectNoSchedule,
},
},
Affinity: &corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "some-key",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"some-value"},
},
},
},
},
},
},
},
},
},
},
@@ -97,6 +114,23 @@ func TestNameserverReconciler(t *testing.T) {
Effect: corev1.TaintEffectNoSchedule,
},
}
wantsDeploy.Spec.Template.Spec.Affinity = &corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "some-key",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"some-value"},
},
},
},
},
},
},
}
expectEqual(t, fc, wantsDeploy)
})