Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v3beta1/emqx_types_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ type EMQXReplicantTemplateSpec struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Specifies how to spread matching pods among the given topology.
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// Specifies the DNS parameters of a pod.
// Parameters specified here will be merged to the generated DNS
// configuration based on DNSPolicy (always ClusterFirst).
// More info: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config
DNSConfig *corev1.PodDNSConfig `json:"dnsConfig,omitempty"`

// Desired number of instances.
// In case of core nodes, each instance has a consistent identity.
Expand Down
5 changes: 5 additions & 0 deletions api/v3beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 88 additions & 0 deletions config/crd/bases/apps.emqx.io_emqxes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,50 @@ spec:
type: string
type: object
type: object
dnsConfig:
description: |-
Specifies the DNS parameters of a pod.
Parameters specified here will be merged to the generated DNS
configuration based on DNSPolicy (always ClusterFirst).
More info: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config
properties:
nameservers:
description: |-
A list of DNS name server IP addresses.
This will be appended to the base nameservers generated from DNSPolicy.
Duplicated nameservers will be removed.
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
description: |-
A list of DNS resolver options.
This will be merged with the base options generated from DNSPolicy.
Duplicated entries will be removed. Resolution options given in Options
will override those that appear in the base DNSPolicy.
items:
description: PodDNSConfigOption defines DNS resolver
options of a pod.
properties:
name:
description: Required.
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
description: |-
A list of DNS search domains for host-name lookup.
This will be appended to the base search paths generated from DNSPolicy.
Duplicated search paths will be removed.
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
env:
description: List of environment variables to set in the container.
items:
Expand Down Expand Up @@ -9671,6 +9715,50 @@ spec:
type: string
type: object
type: object
dnsConfig:
description: |-
Specifies the DNS parameters of a pod.
Parameters specified here will be merged to the generated DNS
configuration based on DNSPolicy (always ClusterFirst).
More info: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config
properties:
nameservers:
description: |-
A list of DNS name server IP addresses.
This will be appended to the base nameservers generated from DNSPolicy.
Duplicated nameservers will be removed.
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
description: |-
A list of DNS resolver options.
This will be merged with the base options generated from DNSPolicy.
Duplicated entries will be removed. Resolution options given in Options
will override those that appear in the base DNSPolicy.
items:
description: PodDNSConfigOption defines DNS resolver
options of a pod.
properties:
name:
description: Required.
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
description: |-
A list of DNS search domains for host-name lookup.
This will be appended to the base search paths generated from DNSPolicy.
Duplicated search paths will be removed.
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
env:
description: List of environment variables to set in the container.
items:
Expand Down
2 changes: 2 additions & 0 deletions docs/en_US/reference/v3beta1-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ _Appears in:_
| `affinity` _[Affinity](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#affinity-v1-core)_ | Affinity for pod assignment<br />ref: https://kubernetes.io/docs/concepts/config/assign-pod-node/#affinity-and-anti-affinity | | |
| `tolerations` _[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#toleration-v1-core) array_ | Pod tolerations.<br />If specified, Pod tolerates any taint that matches the triple <key,value,effect> using the matching operator. | | |
| `topologySpreadConstraints` _[TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#topologyspreadconstraint-v1-core) array_ | Specifies how to spread matching pods among the given topology. | | |
| `dnsConfig` _[PodDNSConfig](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#poddnsconfig-v1-core)_ | Specifies the DNS parameters of a pod.<br />Parameters specified here will be merged to the generated DNS<br />configuration based on DNSPolicy (always ClusterFirst).<br />More info: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config | | |
| `replicas` _integer_ | Desired number of instances.<br />In case of core nodes, each instance has a consistent identity. | 2 | Minimum: 0 <br /> |
| `minAvailable` _[IntOrString](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#intorstring-intstr-util)_ | An eviction is allowed if at least "minAvailable" pods selected by<br />"selector" will still be available after the eviction, i.e. even in the<br />absence of the evicted pod. So for example you can prevent all voluntary<br />evictions by specifying "100%". | | XIntOrString: \{\} <br /> |
| `maxUnavailable` _[IntOrString](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#intorstring-intstr-util)_ | An eviction is allowed if at most "maxUnavailable" pods selected by<br />"selector" are unavailable after the eviction, i.e. even in absence of<br />the evicted pod. For example, one can prevent all voluntary evictions<br />by specifying 0. This is a mutually exclusive setting with "minAvailable". | | XIntOrString: \{\} <br /> |
Expand Down Expand Up @@ -222,6 +223,7 @@ _Appears in:_
| `affinity` _[Affinity](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#affinity-v1-core)_ | Affinity for pod assignment<br />ref: https://kubernetes.io/docs/concepts/config/assign-pod-node/#affinity-and-anti-affinity | | |
| `tolerations` _[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#toleration-v1-core) array_ | Pod tolerations.<br />If specified, Pod tolerates any taint that matches the triple <key,value,effect> using the matching operator. | | |
| `topologySpreadConstraints` _[TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#topologyspreadconstraint-v1-core) array_ | Specifies how to spread matching pods among the given topology. | | |
| `dnsConfig` _[PodDNSConfig](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#poddnsconfig-v1-core)_ | Specifies the DNS parameters of a pod.<br />Parameters specified here will be merged to the generated DNS<br />configuration based on DNSPolicy (always ClusterFirst).<br />More info: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config | | |
| `replicas` _integer_ | Desired number of instances.<br />In case of core nodes, each instance has a consistent identity. | 2 | Minimum: 0 <br /> |
| `minAvailable` _[IntOrString](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#intorstring-intstr-util)_ | An eviction is allowed if at least "minAvailable" pods selected by<br />"selector" will still be available after the eviction, i.e. even in the<br />absence of the evicted pod. So for example you can prevent all voluntary<br />evictions by specifying "100%". | | XIntOrString: \{\} <br /> |
| `maxUnavailable` _[IntOrString](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#intorstring-intstr-util)_ | An eviction is allowed if at most "maxUnavailable" pods selected by<br />"selector" are unavailable after the eviction, i.e. even in absence of<br />the evicted pod. For example, one can prevent all voluntary evictions<br />by specifying 0. This is a mutually exclusive setting with "minAvailable". | | XIntOrString: \{\} <br /> |
Expand Down
1 change: 1 addition & 0 deletions internal/controller/add_core_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func generateStatefulSet(instance *crd.EMQX) *appsv1.StatefulSet {
TopologySpreadConstraints: template.Spec.TopologySpreadConstraints,
NodeName: template.Spec.NodeName,
NodeSelector: template.Spec.NodeSelector,
DNSConfig: template.Spec.DNSConfig,
InitContainers: template.Spec.InitContainers,
Containers: append([]corev1.Container{
{
Expand Down
12 changes: 12 additions & 0 deletions internal/controller/add_core_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ func TestGetNewStatefulSet(t *testing.T) {
)
})

t.Run("check dnsConfig propagation", func(t *testing.T) {
emqx := instance.DeepCopy()
emqx.Spec.CoreTemplate.Spec.DNSConfig = &corev1.PodDNSConfig{
Nameservers: []string{"1.1.1.1"},
Options: []corev1.PodDNSConfigOption{
{Name: "ndots", Value: ptr.To("3")},
},
}
got := generateStatefulSet(emqx)
assert.Equal(t, emqx.Spec.CoreTemplate.Spec.DNSConfig, got.Spec.Template.Spec.DNSConfig)
})

t.Run("check default volume claim templates", func(t *testing.T) {
emqx := instance.DeepCopy()

Expand Down
1 change: 1 addition & 0 deletions internal/controller/add_replicant_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func generateReplicaSet(instance *crd.EMQX) *appsv1.ReplicaSet {
TopologySpreadConstraints: template.Spec.TopologySpreadConstraints,
NodeName: template.Spec.NodeName,
NodeSelector: template.Spec.NodeSelector,
DNSConfig: template.Spec.DNSConfig,
InitContainers: template.Spec.InitContainers,
Containers: append([]corev1.Container{
{
Expand Down
13 changes: 13 additions & 0 deletions internal/controller/add_replicant_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ func TestGetNewReplicaSet(t *testing.T) {
}, got.Spec.Selector.MatchLabels)
})

t.Run("check dnsConfig propagation", func(t *testing.T) {
emqx := instance.DeepCopy()
emqx.Spec.ReplicantTemplate.Spec.DNSConfig = &corev1.PodDNSConfig{
Nameservers: []string{"1.1.1.1"},
Options: []corev1.PodDNSConfigOption{
{Name: "ndots", Value: ptr.To("3")},
},
}
conf, _ := config.EMQXConfigWithDefaults(emqx.Spec.Config.Data)
got := newReplicaSet(emqx, conf)
assert.Equal(t, emqx.Spec.ReplicantTemplate.Spec.DNSConfig, got.Spec.Template.Spec.DNSConfig)
})

t.Run("check no bootstrap API keys", func(t *testing.T) {
emqx := instance.DeepCopy()
conf, _ := config.EMQXConfigWithDefaults(emqx.Spec.Config.Data)
Expand Down
Loading