cmd/k8s-operator: Allow specifying cluster ips for nameservers (#16477)

This commit modifies the kubernetes operator's `DNSConfig` resource
with the addition of a new field at `nameserver.service.clusterIP`.

This field allows users to specify a static in-cluster IP address of
the nameserver when deployed.

Fixes #14305

Signed-off-by: David Bond <davidsbond93@gmail.com>
This commit is contained in:
David Bond
2025-07-21 19:06:36 +01:00
committed by GitHub
parent 0d03a3746a
commit c989824aac
7 changed files with 179 additions and 75 deletions

View File

@@ -422,6 +422,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `image` _[NameserverImage](#nameserverimage)_ | Nameserver image. Defaults to tailscale/k8s-nameserver:unstable. | | |
| `service` _[NameserverService](#nameserverservice)_ | Service configuration. | | |
#### NameserverImage
@@ -441,6 +442,22 @@ _Appears in:_
| `tag` _string_ | Tag defaults to unstable. | | |
#### NameserverService
_Appears in:_
- [Nameserver](#nameserver)
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `clusterIP` _string_ | ClusterIP sets the static IP of the service used by the nameserver. | | |
#### NameserverStatus
@@ -454,7 +471,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `ip` _string_ | IP is the ClusterIP of the Service fronting the deployed ts.net nameserver.<br />Currently you must manually update your cluster DNS config to add<br />this address as a stub nameserver for ts.net for cluster workloads to be<br />able to resolve MagicDNS names associated with egress or Ingress<br />proxies.<br />The IP address will change if you delete and recreate the DNSConfig. | | |
| `ip` _string_ | IP is the ClusterIP of the Service fronting the deployed ts.net nameserver.<br />Currently, you must manually update your cluster DNS config to add<br />this address as a stub nameserver for ts.net for cluster workloads to be<br />able to resolve MagicDNS names associated with egress or Ingress<br />proxies.<br />The IP address will change if you delete and recreate the DNSConfig. | | |
#### NodePortConfig

View File

@@ -82,6 +82,9 @@ type Nameserver struct {
// Nameserver image. Defaults to tailscale/k8s-nameserver:unstable.
// +optional
Image *NameserverImage `json:"image,omitempty"`
// Service configuration.
// +optional
Service *NameserverService `json:"service,omitempty"`
}
type NameserverImage struct {
@@ -93,6 +96,12 @@ type NameserverImage struct {
Tag string `json:"tag,omitempty"`
}
type NameserverService struct {
// ClusterIP sets the static IP of the service used by the nameserver.
// +optional
ClusterIP string `json:"clusterIP,omitempty"`
}
type DNSConfigStatus struct {
// +listType=map
// +listMapKey=type
@@ -105,7 +114,7 @@ type DNSConfigStatus struct {
type NameserverStatus struct {
// IP is the ClusterIP of the Service fronting the deployed ts.net nameserver.
// Currently you must manually update your cluster DNS config to add
// Currently, you must manually update your cluster DNS config to add
// this address as a stub nameserver for ts.net for cluster workloads to be
// able to resolve MagicDNS names associated with egress or Ingress
// proxies.

View File

@@ -385,6 +385,11 @@ func (in *Nameserver) DeepCopyInto(out *Nameserver) {
*out = new(NameserverImage)
**out = **in
}
if in.Service != nil {
in, out := &in.Service, &out.Service
*out = new(NameserverService)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Nameserver.
@@ -412,6 +417,21 @@ 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 *NameserverService) DeepCopyInto(out *NameserverService) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NameserverService.
func (in *NameserverService) DeepCopy() *NameserverService {
if in == nil {
return nil
}
out := new(NameserverService)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NameserverStatus) DeepCopyInto(out *NameserverStatus) {
*out = *in