From e5f657a0e85217343335cdb58212970811b4752e Mon Sep 17 00:00:00 2001 From: MegaByte875 Date: Fri, 26 Jul 2024 17:05:47 +0800 Subject: [PATCH] support dns config options (#516) --- apis/apps/v1alpha1/nebulacluster_common.go | 2 + apis/apps/v1alpha1/nebulacluster_component.go | 16 ++++ apis/apps/v1alpha1/nebulacluster_types.go | 6 ++ apis/apps/v1alpha1/zz_generated.deepcopy.go | 5 ++ .../nebula-operator/crds/nebulaclusters.yaml | 88 +++++++++++++++++++ .../apps.nebula-graph.io_nebulaclusters.yaml | 88 +++++++++++++++++++ 6 files changed, 205 insertions(+) diff --git a/apis/apps/v1alpha1/nebulacluster_common.go b/apis/apps/v1alpha1/nebulacluster_common.go index 90d231c7..43da4559 100644 --- a/apis/apps/v1alpha1/nebulacluster_common.go +++ b/apis/apps/v1alpha1/nebulacluster_common.go @@ -831,6 +831,8 @@ func generateStatefulSet(c NebulaClusterComponent, cm *corev1.ConfigMap) (*appsv Affinity: c.ComponentSpec().Affinity(), Tolerations: c.ComponentSpec().Tolerations(), ServiceAccountName: NebulaServiceAccountName, + DNSConfig: c.ComponentSpec().DNSConfig(), + DNSPolicy: c.ComponentSpec().DNSPolicy(), } podSpec.TopologySpreadConstraints = c.ComponentSpec().TopologySpreadConstraints(componentLabel) diff --git a/apis/apps/v1alpha1/nebulacluster_component.go b/apis/apps/v1alpha1/nebulacluster_component.go index 6425ce9c..d03eb3ca 100644 --- a/apis/apps/v1alpha1/nebulacluster_component.go +++ b/apis/apps/v1alpha1/nebulacluster_component.go @@ -45,6 +45,8 @@ type ComponentAccessor interface { VolumeMounts() []corev1.VolumeMount ReadinessProbe() *corev1.Probe LivenessProbe() *corev1.Probe + DNSConfig() *corev1.PodDNSConfig + DNSPolicy() corev1.DNSPolicy } var _ ComponentAccessor = &componentAccessor{} @@ -187,6 +189,20 @@ func (a *componentAccessor) LivenessProbe() *corev1.Probe { return a.componentSpec.LivenessProbe } +func (a *componentAccessor) DNSConfig() *corev1.PodDNSConfig { + if a.componentSpec == nil { + return nil + } + return a.componentSpec.DNSConfig +} + +func (a *componentAccessor) DNSPolicy() corev1.DNSPolicy { + if a.componentSpec != nil && a.componentSpec.DNSPolicy != "" { + return a.componentSpec.DNSPolicy + } + return corev1.DNSClusterFirst +} + // NebulaClusterComponent is the interface for component // +k8s:deepcopy-gen=false type NebulaClusterComponent interface { diff --git a/apis/apps/v1alpha1/nebulacluster_types.go b/apis/apps/v1alpha1/nebulacluster_types.go index 00ecefa8..35d2c513 100644 --- a/apis/apps/v1alpha1/nebulacluster_types.go +++ b/apis/apps/v1alpha1/nebulacluster_types.go @@ -555,6 +555,12 @@ type ComponentSpec struct { // +optional LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"` + + // +optional + DNSConfig *corev1.PodDNSConfig `json:"dnsConfig,omitempty"` + + // +optional + DNSPolicy corev1.DNSPolicy `json:"dnsPolicy,omitempty"` } // StorageClaim contains details of storage diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go index 92db0ce7..a505ae8f 100644 --- a/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -338,6 +338,11 @@ func (in *ComponentSpec) DeepCopyInto(out *ComponentSpec) { *out = new(v1.Probe) (*in).DeepCopyInto(*out) } + if in.DNSConfig != nil { + in, out := &in.DNSConfig, &out.DNSConfig + *out = new(v1.PodDNSConfig) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentSpec. diff --git a/charts/nebula-operator/crds/nebulaclusters.yaml b/charts/nebula-operator/crds/nebulaclusters.yaml index 259adbff..a48727f5 100644 --- a/charts/nebula-operator/crds/nebulaclusters.yaml +++ b/charts/nebula-operator/crds/nebulaclusters.yaml @@ -953,6 +953,28 @@ spec: type: object collectRegex: type: string + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string env: items: properties: @@ -3667,6 +3689,28 @@ spec: additionalProperties: type: string type: object + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string env: items: properties: @@ -6483,6 +6527,28 @@ spec: storageClassName: type: string type: object + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string env: items: properties: @@ -9338,6 +9404,28 @@ spec: type: string type: object type: array + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string enableAutoBalance: type: boolean enableForceUpdate: diff --git a/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml b/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml index 259adbff..a48727f5 100644 --- a/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml +++ b/config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml @@ -953,6 +953,28 @@ spec: type: object collectRegex: type: string + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string env: items: properties: @@ -3667,6 +3689,28 @@ spec: additionalProperties: type: string type: object + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string env: items: properties: @@ -6483,6 +6527,28 @@ spec: storageClassName: type: string type: object + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string env: items: properties: @@ -9338,6 +9404,28 @@ spec: type: string type: object type: array + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string enableAutoBalance: type: boolean enableForceUpdate: