cmd/k8s-operator: support imagePullSecrets on DNSConfig nameserver

The nameserver Deployment created for a DNSConfig was the only
operator-managed workload with no way to configure imagePullSecrets, so its
pods could not pull the nameserver image from a private registry.

Adds imagePullSecrets to NameserverPod and thread it through to the nameserver
Deployment pod spec.

Updates #16772

Signed-off-by: chaosinthecrd <[email protected]>
This commit is contained in:
chaosinthecrd authored and Tom Meadows committed 2026-08-04 17:14:01 +01:00
1 parent 15b03cf5bc
commit 37aca4aa2e
7 files changed
+64 -3

No files matched your search

@@ -977,6 +977,27 @@ spec:
Empty topologyKey is not allowed.
type: string
x-kubernetes-list-type: atomic
imagePullSecrets:
description: |-
Nameserver Pod's image pull Secrets.
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec
type: array
items:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
type: object
properties:
name:
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
default: ""
x-kubernetes-map-type: atomic
nodeSelector:
description: If specified, applies node selector rules to the pods deployed by the DNSConfig resource.
type: object
@@ -1315,6 +1315,27 @@ spec:
x-kubernetes-list-type: atomic
type: object
type: object
imagePullSecrets:
description: |-
Nameserver Pod's image pull Secrets.
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec
items:
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
type: array
nodeSelector:
additionalProperties:
type: string
+6 -3
View File
@@ -192,6 +192,7 @@ func (a *NameserverReconciler) maybeProvision(ctx context.Context, tsDNSCfg *tsa
dCfg.tolerations = tsDNSCfg.Spec.Nameserver.Pod.Tolerations
dCfg.affinity = tsDNSCfg.Spec.Nameserver.Pod.Affinity
dCfg.nodeSelector = tsDNSCfg.Spec.Nameserver.Pod.NodeSelector
dCfg.imagePullSecrets = tsDNSCfg.Spec.Nameserver.Pod.ImagePullSecrets
}
for _, deployable := range []deployable{saDeployable, deployDeployable, svcDeployable, cmDeployable} {
@@ -226,9 +227,10 @@ type deployConfig struct {
ownerRefs []metav1.OwnerReference
namespace string
clusterIP string
tolerations []corev1.Toleration
affinity *corev1.Affinity
nodeSelector map[string]string
tolerations []corev1.Toleration
affinity *corev1.Affinity
nodeSelector map[string]string
imagePullSecrets []corev1.LocalObjectReference
}
var (
@@ -256,6 +258,7 @@ var (
d.Spec.Template.Spec.Tolerations = cfg.tolerations
d.Spec.Template.Spec.Affinity = cfg.affinity
d.Spec.Template.Spec.NodeSelector = cfg.nodeSelector
d.Spec.Template.Spec.ImagePullSecrets = cfg.imagePullSecrets
updateF := func(oldD *appsv1.Deployment) {
oldD.Spec = d.Spec
}
+6
View File
@@ -71,6 +71,9 @@ func TestNameserverReconciler(t *testing.T) {
},
},
},
ImagePullSecrets: []corev1.LocalObjectReference{
{Name: "some-secret"},
},
},
},
},
@@ -137,6 +140,9 @@ func TestNameserverReconciler(t *testing.T) {
wantsDeploy.Spec.Template.Spec.NodeSelector = map[string]string{
"foo": "bar",
}
wantsDeploy.Spec.Template.Spec.ImagePullSecrets = []corev1.LocalObjectReference{
{Name: "some-secret"},
}
expectEqual(t, fc, wantsDeploy)
})
+1
View File
@@ -488,6 +488,7 @@ _Appears in:_
| `tolerations` _[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.3/#toleration-v1-core) array_ | If specified, applies tolerations to the pods deployed by the DNSConfig resource. | | |
| `affinity` _[Affinity](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.3/#affinity-v1-core)_ | If specified, applies affinity rules to the pods deployed by the DNSConfig resource. | | |
| `nodeSelector` _object (keys:string, values:string)_ | If specified, applies node selector rules to the pods deployed by the DNSConfig resource. | | |
| `imagePullSecrets` _[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.3/#localobjectreference-v1-core) array_ | Nameserver Pod's image pull Secrets.<br />https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec | | |
#### NameserverService
@@ -119,6 +119,10 @@ type NameserverPod struct {
// If specified, applies node selector rules to the pods deployed by the DNSConfig resource.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitzero"`
// Nameserver Pod's image pull Secrets.
// https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
}
type DNSConfigStatus struct {
@@ -481,6 +481,11 @@ func (in *NameserverPod) DeepCopyInto(out *NameserverPod) {
(*out)[key] = val
}
}
if in.ImagePullSecrets != nil {
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
*out = make([]corev1.LocalObjectReference, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NameserverPod.