cmd/k8s-operator: allow pod tolerations on nameservers (#17260)

This commit modifies the `DNSConfig` custom resource to allow specifying
[tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
on the nameserver pods.

This will allow users to dictate where their nameserver pods are located
within their clusters.

Fixes: https://github.com/tailscale/tailscale/issues/17092

Signed-off-by: David Bond <davidsbond93@gmail.com>
This commit is contained in:
David Bond
2025-10-17 18:32:30 +01:00
committed by GitHub
parent 6493206ac7
commit 9083ef1ac4
7 changed files with 171 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -84,6 +85,9 @@ type Nameserver struct {
// Service configuration.
// +optional
Service *NameserverService `json:"service,omitempty"`
// Pod configuration.
// +optional
Pod *NameserverPod `json:"pod,omitempty"`
// Replicas specifies how many Pods to create. Defaults to 1.
// +optional
// +kubebuilder:validation:Minimum=0
@@ -105,6 +109,12 @@ type NameserverService struct {
ClusterIP string `json:"clusterIP,omitempty"`
}
type NameserverPod struct {
// If specified, applies tolerations to the pods deployed by the DNSConfig resource.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}
type DNSConfigStatus struct {
// +listType=map
// +listMapKey=type

View File

@@ -422,6 +422,11 @@ func (in *Nameserver) DeepCopyInto(out *Nameserver) {
*out = new(NameserverService)
**out = **in
}
if in.Pod != nil {
in, out := &in.Pod, &out.Pod
*out = new(NameserverPod)
(*in).DeepCopyInto(*out)
}
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
@@ -454,6 +459,28 @@ func (in *NameserverImage) DeepCopy() *NameserverImage {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NameserverPod) DeepCopyInto(out *NameserverPod) {
*out = *in
if in.Tolerations != nil {
in, out := &in.Tolerations, &out.Tolerations
*out = make([]corev1.Toleration, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NameserverPod.
func (in *NameserverPod) DeepCopy() *NameserverPod {
if in == nil {
return nil
}
out := new(NameserverPod)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NameserverService) DeepCopyInto(out *NameserverService) {
*out = *in