diff --git a/api/src/main/java/io/strimzi/api/kafka/model/common/template/PodTemplate.java b/api/src/main/java/io/strimzi/api/kafka/model/common/template/PodTemplate.java index e8a43e58ba1..ef3d6ad0780 100644 --- a/api/src/main/java/io/strimzi/api/kafka/model/common/template/PodTemplate.java +++ b/api/src/main/java/io/strimzi/api/kafka/model/common/template/PodTemplate.java @@ -10,6 +10,7 @@ import io.fabric8.kubernetes.api.model.Affinity; import io.fabric8.kubernetes.api.model.HostAlias; import io.fabric8.kubernetes.api.model.LocalObjectReference; +import io.fabric8.kubernetes.api.model.PodDNSConfig; import io.fabric8.kubernetes.api.model.PodSecurityContext; import io.fabric8.kubernetes.api.model.Toleration; import io.fabric8.kubernetes.api.model.TopologySpreadConstraint; @@ -37,7 +38,7 @@ ) @JsonInclude(JsonInclude.Include.NON_DEFAULT) @JsonPropertyOrder({"metadata", "imagePullSecrets", "securityContext", "terminationGracePeriodSeconds", "affinity", - "tolerations", "topologySpreadConstraints", "priorityClassName", "schedulerName", "hostAliases", + "tolerations", "topologySpreadConstraints", "priorityClassName", "schedulerName", "hostAliases", "dnsPolicy", "dnsConfig", "enableServiceLinks", "tmpDirSizeLimit", "volumes"}) @EqualsAndHashCode @ToString @@ -53,6 +54,8 @@ public class PodTemplate implements HasMetadataTemplate, UnknownPropertyPreservi private String priorityClassName; private String schedulerName; private List hostAliases; + private PodDNSConfig dnsConfig; + private String dnsPolicy; private Boolean enableServiceLinks; private String tmpDirSizeLimit; private List volumes; @@ -174,6 +177,30 @@ public void setHostAliases(List hostAliases) { this.hostAliases = hostAliases; } + @Description("The pod's DNSPolicy. " + + "Defaults to `ClusterFirst`. " + + "Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`.") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + public String getDnsPolicy() { + return dnsPolicy; + } + + public void setDnsPolicy(String dnsPolicy) { + this.dnsPolicy = dnsPolicy; + } + + @Description("The pod's DNSConfig. " + + "If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy.") + @KubeLink(group = "core", version = "v1", kind = "poddnsconfig") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + public PodDNSConfig getDnsConfig() { + return dnsConfig; + } + + public void setDnsConfig(PodDNSConfig dnsConfig) { + this.dnsConfig = dnsConfig; + } + @Description("Indicates whether information about services should be injected into Pod's environment variables.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public Boolean getEnableServiceLinks() { diff --git a/api/src/test/java/io/strimzi/api/kafka/model/connect/KafkaConnectCrdIT.java b/api/src/test/java/io/strimzi/api/kafka/model/connect/KafkaConnectCrdIT.java index c6cb3c2eb32..90d1a72ce56 100644 --- a/api/src/test/java/io/strimzi/api/kafka/model/connect/KafkaConnectCrdIT.java +++ b/api/src/test/java/io/strimzi/api/kafka/model/connect/KafkaConnectCrdIT.java @@ -98,6 +98,11 @@ void testKafkaConnectWithInvalidExternalConfiguration() { assertMissingRequiredPropertiesMessage(exception.getMessage(), "valueFrom"); } + @Test + public void testKafkaConnectWithDnsConfig() { + createDeleteCustomResource("KafkaConnect-with-dnsConfig.yaml"); + } + @BeforeAll void setupEnvironment() { client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build(); diff --git a/api/src/test/java/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2CrdIT.java b/api/src/test/java/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2CrdIT.java index 3e6fdb38757..b5cb6d31f46 100644 --- a/api/src/test/java/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2CrdIT.java +++ b/api/src/test/java/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2CrdIT.java @@ -98,6 +98,11 @@ public void testKafkaMirrorMaker2WithInvalidExternalConfiguration() { assertMissingRequiredPropertiesMessage(exception.getMessage(), "valueFrom"); } + @Test + void testKafkaMirrorMaker2WithDnsConfig() { + createDeleteCustomResource("KafkaMirrorMaker2-with-dnsConfig.yaml"); + } + @BeforeAll void setupEnvironment() { client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build(); diff --git a/api/src/test/resources/io/strimzi/api/kafka/model/connect/KafkaConnect-with-dnsConfig.yaml b/api/src/test/resources/io/strimzi/api/kafka/model/connect/KafkaConnect-with-dnsConfig.yaml new file mode 100644 index 00000000000..ad991c87cd5 --- /dev/null +++ b/api/src/test/resources/io/strimzi/api/kafka/model/connect/KafkaConnect-with-dnsConfig.yaml @@ -0,0 +1,77 @@ +apiVersion: kafka.strimzi.io/v1beta2 +kind: KafkaConnect +metadata: + name: test-kafka-connect +spec: + image: foo + replicas: 6 + bootstrapServers: kafka:9092 + template: + deployment: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 + pod: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 + imagePullSecrets: + - name: some-secret + - name: some-other-secret + dnsPolicy: "None" + dnsConfig: + nameservers: + - 192.0.2.1 + searches: + - ns1.svc.cluster-domain.example + - my.dns.search.suffix + options: + - name: ndots + value: "2" + - name: edns0 + securityContext: + runAsUser: 1000001 + runAsGroup: 1000001 + fsGroup: 0 + terminationGracePeriodSeconds: 30 + volumes: + - name: example-secret + secret: + secretName: secret-name + - name: example-configmap + configMap: + name: config-map-name + connectContainer: + volumeMounts: + - name: example-secret + mountPath: /path/to/mount/secret-volume + subPath: subPath1 + initContainer: + volumeMounts: + - name: example-configmap + mountPath: /path/to/mount/cm-volume + podDisruptionBudget: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 + maxUnavailable: 1 + apiService: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 diff --git a/api/src/test/resources/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2-with-dnsConfig.yaml b/api/src/test/resources/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2-with-dnsConfig.yaml new file mode 100644 index 00000000000..c58ed5eb580 --- /dev/null +++ b/api/src/test/resources/io/strimzi/api/kafka/model/mirrormaker2/KafkaMirrorMaker2-with-dnsConfig.yaml @@ -0,0 +1,87 @@ +apiVersion: kafka.strimzi.io/v1beta2 +kind: KafkaMirrorMaker2 +metadata: + name: test-kafka-mirror-maker-2 +spec: + image: foo + replicas: 6 + connectCluster: target + clusters: + - alias: source + bootstrapServers: my-source-kafka:9092 + - alias: target + bootstrapServers: my-target-kafka:9092 + mirrors: + - sourceCluster: source + targetCluster: target + sourceConnector: {} + topicsPattern: my-topic + template: + deployment: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 + pod: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 + imagePullSecrets: + - name: some-secret + - name: some-other-secret + dnsPolicy: "None" + dnsConfig: + nameservers: + - 192.0.2.1 + searches: + - ns1.svc.cluster-domain.example + - my.dns.search.suffix + options: + - name: ndots + value: "2" + - name: edns0 + securityContext: + runAsUser: 1000001 + runAsGroup: 1000001 + fsGroup: 0 + terminationGracePeriodSeconds: 30 + volumes: + - name: example-secret + secret: + secretName: secret-name + - name: example-configmap + configMap: + name: config-map-name + connectContainer: + volumeMounts: + - name: example-secret + mountPath: /path/to/mount/secret-volume + subPath: subPath1 + initContainer: + volumeMounts: + - name: example-configmap + mountPath: /path/to/mount/cm-volume + podDisruptionBudget: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 + maxUnavailable: 1 + apiService: + metadata: + labels: + key1: label1 + key2: label2 + annotations: + key1: label1 + key2: label2 diff --git a/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/WorkloadUtils.java b/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/WorkloadUtils.java index 4f2997960b5..f72135e4b1d 100644 --- a/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/WorkloadUtils.java +++ b/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/WorkloadUtils.java @@ -279,6 +279,8 @@ public static Pod createStatefulPod( .withPriorityClassName(template != null ? template.getPriorityClassName() : null) .withSchedulerName(template != null && template.getSchedulerName() != null ? template.getSchedulerName() : "default-scheduler") .withHostAliases(template != null ? template.getHostAliases() : null) + .withDnsPolicy(template != null ? template.getDnsPolicy() : null) + .withDnsConfig(template != null ? template.getDnsConfig() : null) .withTopologySpreadConstraints(template != null ? template.getTopologySpreadConstraints() : null) .endSpec() .build(); @@ -339,6 +341,8 @@ public static PodTemplateSpec createPodTemplateSpec( .withPriorityClassName(template != null ? template.getPriorityClassName() : null) .withSchedulerName(template != null && template.getSchedulerName() != null ? template.getSchedulerName() : "default-scheduler") .withHostAliases(template != null ? template.getHostAliases() : null) + .withDnsPolicy(template != null ? template.getDnsPolicy() : null) + .withDnsConfig(template != null ? template.getDnsConfig() : null) .withTopologySpreadConstraints(template != null ? template.getTopologySpreadConstraints() : null) .endSpec() .build(); @@ -402,6 +406,8 @@ public static Pod createPod( .withPriorityClassName(template != null ? template.getPriorityClassName() : null) .withSchedulerName(template != null && template.getSchedulerName() != null ? template.getSchedulerName() : "default-scheduler") .withHostAliases(template != null ? template.getHostAliases() : null) + .withDnsPolicy(template != null ? template.getDnsPolicy() : null) + .withDnsConfig(template != null ? template.getDnsConfig() : null) .withTopologySpreadConstraints(template != null ? template.getTopologySpreadConstraints() : null) .endSpec() .build(); @@ -458,4 +464,4 @@ private static DeploymentStrategy rollingUpdateStrategy() { /* test */ static List imagePullSecrets(PodTemplate template, List defaultValue) { return template != null && template.getImagePullSecrets() != null ? template.getImagePullSecrets() : defaultValue; } -} \ No newline at end of file +} diff --git a/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/KafkaMirrorMaker2ClusterTest.java b/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/KafkaMirrorMaker2ClusterTest.java index a5ef54e8b29..7737722a16f 100644 --- a/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/KafkaMirrorMaker2ClusterTest.java +++ b/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/KafkaMirrorMaker2ClusterTest.java @@ -18,6 +18,9 @@ import io.fabric8.kubernetes.api.model.PersistentVolumeClaimVolumeSource; import io.fabric8.kubernetes.api.model.PersistentVolumeClaimVolumeSourceBuilder; import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.api.model.PodDNSConfig; +import io.fabric8.kubernetes.api.model.PodDNSConfigBuilder; +import io.fabric8.kubernetes.api.model.PodDNSConfigOptionBuilder; import io.fabric8.kubernetes.api.model.PodSecurityContextBuilder; import io.fabric8.kubernetes.api.model.Quantity; import io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder; @@ -954,6 +957,21 @@ public void testTemplate() { .withIp("192.168.1.87") .build(); + String dnsPolicy = "None"; + PodDNSConfig dnsConfig = new PodDNSConfigBuilder() + .withNameservers("192.0.2.1") + .withSearches("ns1.svc.cluster-domain.example", "my.dns.search.suffix") + .withOptions( + new PodDNSConfigOptionBuilder() + .withName("ndots") + .withValue("2") + .build(), + new PodDNSConfigOptionBuilder() + .withName("edns0") + .build() + ) + .build(); + ConfigMapVolumeSource configMap = new ConfigMapVolumeSourceBuilder() .withName("configMap1") .build(); @@ -1002,6 +1020,8 @@ public void testTemplate() { .withPriorityClassName("top-priority") .withSchedulerName("my-scheduler") .withHostAliases(hostAlias1, hostAlias2) + .withDnsPolicy(dnsPolicy) + .withDnsConfig(dnsConfig) .withEnableServiceLinks(false) .withTmpDirSizeLimit("10Mi") .withVolumes(additionalVolumeConfigMap, additionalVolumePvc) @@ -1054,6 +1074,8 @@ public void testTemplate() { assertThat(pod.getMetadata().getAnnotations().entrySet().containsAll(podAnots.entrySet()), is(true)); assertThat(pod.getSpec().getSchedulerName(), is("my-scheduler")); assertThat(pod.getSpec().getHostAliases(), containsInAnyOrder(hostAlias1, hostAlias2)); + assertThat(pod.getSpec().getDnsPolicy(), is(dnsPolicy)); + assertThat(pod.getSpec().getDnsConfig(), is(dnsConfig)); assertThat(pod.getSpec().getEnableServiceLinks(), is(false)); assertThat(getVolume(pod, "strimzi-tmp").getEmptyDir().getSizeLimit(), is(new Quantity("10Mi"))); assertThat(getVolume(pod, additionalVolumeConfigMap.getName()).getConfigMap(), is(configMap)); diff --git a/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/WorkloadUtilsTest.java b/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/WorkloadUtilsTest.java index 24cf20c80ad..3d4f7e9bb1c 100644 --- a/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/WorkloadUtilsTest.java +++ b/cluster-operator/src/test/java/io/strimzi/operator/cluster/model/WorkloadUtilsTest.java @@ -19,6 +19,9 @@ import io.fabric8.kubernetes.api.model.OwnerReferenceBuilder; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; +import io.fabric8.kubernetes.api.model.PodDNSConfig; +import io.fabric8.kubernetes.api.model.PodDNSConfigBuilder; +import io.fabric8.kubernetes.api.model.PodDNSConfigOptionBuilder; import io.fabric8.kubernetes.api.model.PodSecurityContext; import io.fabric8.kubernetes.api.model.PodSecurityContextBuilder; import io.fabric8.kubernetes.api.model.PodTemplateSpec; @@ -121,6 +124,20 @@ public class WorkloadUtilsTest { .withIp("127.0.0.1") .withHostnames("home") .build(); + private static final String DEFAULT_DNS_POLICY = "None"; + private static final PodDNSConfig DEFAULT_DNS_CONFIG = new PodDNSConfigBuilder() + .withNameservers("192.0.2.1") + .withSearches("ns1.svc.cluster-domain.example", "my.dns.search.suffix") + .withOptions( + new PodDNSConfigOptionBuilder() + .withName("ndots") + .withValue("2") + .build(), + new PodDNSConfigOptionBuilder() + .withName("edns0") + .build() + ) + .build(); ////////////////////////////////////////////////// // Deployment tests @@ -452,6 +469,8 @@ public void testCreateStatefulPodWithNullValues() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -502,6 +521,8 @@ public void testCreateStatefulPodWithNullValuesAndNullTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -552,6 +573,8 @@ public void testCreateStatefulPodWithEmptyTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -574,6 +597,8 @@ public void testCreateStatefulPodWithTemplate() { .withImagePullSecrets(List.of(new LocalObjectReference("some-other-pull-secret"))) .withPriorityClassName("my-priority-class") .withHostAliases(DEFAULT_HOST_ALIAS) + .withDnsPolicy(DEFAULT_DNS_POLICY) + .withDnsConfig(DEFAULT_DNS_CONFIG) .withTolerations(DEFAULT_TOLERATION) .withTerminationGracePeriodSeconds(15) .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(0L).build()) // => should be ignored @@ -598,7 +623,7 @@ public void testCreateStatefulPodWithTemplate() { .withStrimziPodName(NAME + "-0") .withAdditionalLabels(Map.of("statefulset.kubernetes.io/pod-name", "my-workload-0", "default-label", "default-value", "label-3", "value-3", "label-4", "value-4")) .toMap())); - assertThat(pod.getMetadata().getAnnotations(), is(Map.of("extra", "annotations", "anno-1", "value-1", "anno-2", "value-2", PodRevision.STRIMZI_REVISION_ANNOTATION, "4c2e5618"))); + assertThat(pod.getMetadata().getAnnotations(), is(Map.of("extra", "annotations", "anno-1", "value-1", "anno-2", "value-2", PodRevision.STRIMZI_REVISION_ANNOTATION, "d3ffc657"))); assertThat(pod.getSpec().getRestartPolicy(), is("Always")); assertThat(pod.getSpec().getHostname(), is(NAME + "-0")); @@ -617,6 +642,8 @@ public void testCreateStatefulPodWithTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is("my-priority-class")); assertThat(pod.getSpec().getSchedulerName(), is("my-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(List.of(DEFAULT_HOST_ALIAS))); + assertThat(pod.getSpec().getDnsPolicy(), is(DEFAULT_DNS_POLICY)); + assertThat(pod.getSpec().getDnsConfig(), is(DEFAULT_DNS_CONFIG)); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(List.of(DEFAULT_TOPOLOGY_SPREAD_CONSTRAINT))); } @@ -657,6 +684,8 @@ public void testCreatePodTemplateSpecWithNullValues() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -694,6 +723,8 @@ public void testCreatePodTemplateSpecWithNullTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -731,6 +762,8 @@ public void testCreatePodTemplateSpecWithEmptyTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -749,6 +782,8 @@ public void testCreatePodTemplateSpecWithTemplate() { .withImagePullSecrets(List.of(new LocalObjectReference("some-other-pull-secret"))) .withPriorityClassName("my-priority-class") .withHostAliases(DEFAULT_HOST_ALIAS) + .withDnsPolicy(DEFAULT_DNS_POLICY) + .withDnsConfig(DEFAULT_DNS_CONFIG) .withTolerations(DEFAULT_TOLERATION) .withTerminationGracePeriodSeconds(15) .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(0L).build()) // => should be ignored @@ -783,6 +818,8 @@ public void testCreatePodTemplateSpecWithTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is("my-priority-class")); assertThat(pod.getSpec().getSchedulerName(), is("my-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(List.of(DEFAULT_HOST_ALIAS))); + assertThat(pod.getSpec().getDnsPolicy(), is(DEFAULT_DNS_POLICY)); + assertThat(pod.getSpec().getDnsConfig(), is(DEFAULT_DNS_CONFIG)); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(List.of(DEFAULT_TOPOLOGY_SPREAD_CONSTRAINT))); } @@ -828,6 +865,8 @@ public void testCreatePodWithNullValues() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -870,6 +909,8 @@ public void testCreatePodWithNullValuesAndNullTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -912,6 +953,8 @@ public void testCreatePodWithEmptyTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is(nullValue())); assertThat(pod.getSpec().getSchedulerName(), is("default-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(nullValue())); + assertThat(pod.getSpec().getDnsPolicy(), is(nullValue())); + assertThat(pod.getSpec().getDnsConfig(), is(nullValue())); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(nullValue())); } @@ -932,6 +975,8 @@ public void testCreatePodWithTemplate() { .withImagePullSecrets(List.of(new LocalObjectReference("some-other-pull-secret"))) .withPriorityClassName("my-priority-class") .withHostAliases(DEFAULT_HOST_ALIAS) + .withDnsPolicy(DEFAULT_DNS_POLICY) + .withDnsConfig(DEFAULT_DNS_CONFIG) .withTolerations(DEFAULT_TOLERATION) .withTerminationGracePeriodSeconds(15) .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(0L).build()) // => should be ignored @@ -969,6 +1014,8 @@ public void testCreatePodWithTemplate() { assertThat(pod.getSpec().getPriorityClassName(), is("my-priority-class")); assertThat(pod.getSpec().getSchedulerName(), is("my-scheduler")); assertThat(pod.getSpec().getHostAliases(), is(List.of(DEFAULT_HOST_ALIAS))); + assertThat(pod.getSpec().getDnsPolicy(), is(DEFAULT_DNS_POLICY)); + assertThat(pod.getSpec().getDnsConfig(), is(DEFAULT_DNS_CONFIG)); assertThat(pod.getSpec().getTopologySpreadConstraints(), is(List.of(DEFAULT_TOPOLOGY_SPREAD_CONSTRAINT))); } diff --git a/documentation/modules/appendix_crds.adoc b/documentation/modules/appendix_crds.adoc index d5dd99dab36..6cfc9f1d836 100644 --- a/documentation/modules/appendix_crds.adoc +++ b/documentation/modules/appendix_crds.adoc @@ -1240,6 +1240,12 @@ include::../api/io.strimzi.api.kafka.model.common.template.PodTemplate.adoc[leve |hostAliases |https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#hostalias-v1-core[HostAlias] array |The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. +|dnsPolicy +|string +|The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`. +|dnsConfig +|https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#poddnsconfig-v1-core[PodDNSConfig] +|The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy. |enableServiceLinks |boolean |Indicates whether information about services should be injected into Pod's environment variables. diff --git a/packaging/install/cluster-operator/040-Crd-kafka.yaml b/packaging/install/cluster-operator/040-Crd-kafka.yaml index 03c66e938fe..6ceaf40dc8d 100644 --- a/packaging/install/cluster-operator/040-Crd-kafka.yaml +++ b/packaging/install/cluster-operator/040-Crd-kafka.yaml @@ -1494,6 +1494,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -3048,6 +3072,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -4416,6 +4464,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -5835,6 +5907,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -7041,6 +7137,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -7939,6 +8059,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. diff --git a/packaging/install/cluster-operator/041-Crd-kafkaconnect.yaml b/packaging/install/cluster-operator/041-Crd-kafkaconnect.yaml index c8db6039c65..0d3d422d8cb 100644 --- a/packaging/install/cluster-operator/041-Crd-kafkaconnect.yaml +++ b/packaging/install/cluster-operator/041-Crd-kafkaconnect.yaml @@ -1024,6 +1024,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -2037,6 +2061,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. diff --git a/packaging/install/cluster-operator/046-Crd-kafkabridge.yaml b/packaging/install/cluster-operator/046-Crd-kafkabridge.yaml index 23b02fa4999..1a59f9ef649 100644 --- a/packaging/install/cluster-operator/046-Crd-kafkabridge.yaml +++ b/packaging/install/cluster-operator/046-Crd-kafkabridge.yaml @@ -1013,6 +1013,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. diff --git a/packaging/install/cluster-operator/048-Crd-kafkamirrormaker2.yaml b/packaging/install/cluster-operator/048-Crd-kafkamirrormaker2.yaml index f69f377b676..5ca56dfa9f4 100644 --- a/packaging/install/cluster-operator/048-Crd-kafkamirrormaker2.yaml +++ b/packaging/install/cluster-operator/048-Crd-kafkamirrormaker2.yaml @@ -1241,6 +1241,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. @@ -2254,6 +2278,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables. diff --git a/packaging/install/cluster-operator/04A-Crd-kafkanodepool.yaml b/packaging/install/cluster-operator/04A-Crd-kafkanodepool.yaml index 5c7eb6729ed..81b0df1585d 100644 --- a/packaging/install/cluster-operator/04A-Crd-kafkanodepool.yaml +++ b/packaging/install/cluster-operator/04A-Crd-kafkanodepool.yaml @@ -751,6 +751,30 @@ spec: ip: type: string description: The pod's HostAliases. HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified. + dnsPolicy: + type: string + description: "The pod's DNSPolicy. Defaults to `ClusterFirst`. Valid values are `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`." + dnsConfig: + type: object + properties: + nameservers: + type: array + items: + type: string + options: + type: array + items: + type: object + properties: + name: + type: string + value: + type: string + searches: + type: array + items: + type: string + description: "The pod's DNSConfig. If specified, the parameters specified here will be merged to the generated DNS configuration based on the DNSPolicy." enableServiceLinks: type: boolean description: Indicates whether information about services should be injected into Pod's environment variables.