Skip to content

Commit 14ac41f

Browse files
authored
cmd/k8s-operator,k8s-operator: proxyclass affinity (tailscale#11862)
add ability to set affinity rules to proxyclass Updates#11861 Signed-off-by: Lee Briggs <[email protected]>
1 parent 31e6bdb commit 14ac41f

File tree

8 files changed

+2420
-1
lines changed

8 files changed

+2420
-1
lines changed

cmd/k8s-operator/deploy/crds/tailscale.com_proxyclasses.yaml

Lines changed: 520 additions & 0 deletions
Large diffs are not rendered by default.

cmd/k8s-operator/deploy/manifests/operator.yaml

Lines changed: 520 additions & 0 deletions
Large diffs are not rendered by default.

cmd/k8s-operator/sts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ func applyProxyClassToStatefulSet(pc *tsapi.ProxyClass, ss *appsv1.StatefulSet)
641641
ss.Spec.Template.Spec.ImagePullSecrets = wantsPod.ImagePullSecrets
642642
ss.Spec.Template.Spec.NodeName = wantsPod.NodeName
643643
ss.Spec.Template.Spec.NodeSelector = wantsPod.NodeSelector
644+
ss.Spec.Template.Spec.Affinity = wantsPod.Affinity
644645
ss.Spec.Template.Spec.Tolerations = wantsPod.Tolerations
645646

646647
// Update containers.

cmd/k8s-operator/sts_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func Test_applyProxyClassToStatefulSet(t *testing.T) {
6666
ImagePullSecrets: []corev1.LocalObjectReference{{Name: "docker-creds"}},
6767
NodeName: "some-node",
6868
NodeSelector: map[string]string{"beta.kubernetes.io/os": "linux"},
69+
Affinity: &corev1.Affinity{NodeAffinity: &corev1.NodeAffinity{RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{}}},
6970
Tolerations: []corev1.Toleration{{Key: "", Operator: "Exists"}},
7071
TailscaleContainer: &tsapi.Container{
7172
SecurityContext: &corev1.SecurityContext{
@@ -139,6 +140,7 @@ func Test_applyProxyClassToStatefulSet(t *testing.T) {
139140
wantSS.Spec.Template.Spec.ImagePullSecrets = proxyClassAllOpts.Spec.StatefulSet.Pod.ImagePullSecrets
140141
wantSS.Spec.Template.Spec.NodeName = proxyClassAllOpts.Spec.StatefulSet.Pod.NodeName
141142
wantSS.Spec.Template.Spec.NodeSelector = proxyClassAllOpts.Spec.StatefulSet.Pod.NodeSelector
143+
wantSS.Spec.Template.Spec.Affinity = proxyClassAllOpts.Spec.StatefulSet.Pod.Affinity
142144
wantSS.Spec.Template.Spec.Tolerations = proxyClassAllOpts.Spec.StatefulSet.Pod.Tolerations
143145
wantSS.Spec.Template.Spec.Containers[0].SecurityContext = proxyClassAllOpts.Spec.StatefulSet.Pod.TailscaleContainer.SecurityContext
144146
wantSS.Spec.Template.Spec.InitContainers[0].SecurityContext = proxyClassAllOpts.Spec.StatefulSet.Pod.TailscaleInitContainer.SecurityContext
@@ -176,6 +178,7 @@ func Test_applyProxyClassToStatefulSet(t *testing.T) {
176178
wantSS.Spec.Template.Spec.ImagePullSecrets = proxyClassAllOpts.Spec.StatefulSet.Pod.ImagePullSecrets
177179
wantSS.Spec.Template.Spec.NodeName = proxyClassAllOpts.Spec.StatefulSet.Pod.NodeName
178180
wantSS.Spec.Template.Spec.NodeSelector = proxyClassAllOpts.Spec.StatefulSet.Pod.NodeSelector
181+
wantSS.Spec.Template.Spec.Affinity = proxyClassAllOpts.Spec.StatefulSet.Pod.Affinity
179182
wantSS.Spec.Template.Spec.Tolerations = proxyClassAllOpts.Spec.StatefulSet.Pod.Tolerations
180183
wantSS.Spec.Template.Spec.Containers[0].SecurityContext = proxyClassAllOpts.Spec.StatefulSet.Pod.TailscaleContainer.SecurityContext
181184
wantSS.Spec.Template.Spec.Containers[0].Resources = proxyClassAllOpts.Spec.StatefulSet.Pod.TailscaleContainer.Resources

0 commit comments

Comments
 (0)