From e29a75cf54f9d81e34bbfd499a57ca181eabae71 Mon Sep 17 00:00:00 2001 From: Or Shoval Date: Sun, 13 Nov 2022 16:13:12 +0200 Subject: [PATCH] Support KubeSecondaryDNS plugin Integrate KubeSecondaryDNS as part of CNAO. "core-dns-image" can be used in order to generate a CSV manifest with custom image. Signed-off-by: Or Shoval --- Makefile | 2 + README.md | 21 +++ ...-patch.e2e-kube-secondary-dns-functests.sh | 38 +++++ automation/components-functests.setup.sh | 1 + components.yaml | 6 + data/kube-secondary-dns/secondarydns.yaml | 131 ++++++++++++++++++ hack/components/bump-kube-secondary-dns.sh | 90 ++++++++++++ hack/generate-manifests.sh | 1 + .../shared/networkaddonsconfig_types.go | 9 ++ pkg/components/components.go | 35 +++++ pkg/network/kube_secondary_dns_controller.go | 35 +++++ pkg/network/network.go | 16 +++ test/check/components.go | 7 + test/e2e/workflow/deployment_test.go | 16 +++ test/releases/99.0.0.go | 15 ++ .../manifest-templator/manifest-templator.go | 4 + 16 files changed, 427 insertions(+) create mode 100755 automation/check-patch.e2e-kube-secondary-dns-functests.sh create mode 100644 data/kube-secondary-dns/secondarydns.yaml create mode 100755 hack/components/bump-kube-secondary-dns.sh create mode 100644 pkg/network/kube_secondary_dns_controller.go diff --git a/Makefile b/Makefile index be8692a4e..92c279588 100644 --- a/Makefile +++ b/Makefile @@ -159,6 +159,8 @@ gen-manifests: manifest-templator KUBEMACPOOL_IMAGE=$(KUBEMACPOOL_IMAGE) \ MACVTAP_CNI_IMAGE=$(MACVTAP_CNI_IMAGE) \ MULTUS_DYNAMIC_NETWORKS_CONTROLLER_IMAGE=$(MULTUS_DYNAMIC_NETWORKS_CONTROLLER_IMAGE) \ + KUBE_SECONDARY_DNS_IMAGE=$(KUBE_SECONDARY_DNS_IMAGE) \ + CORE_DNS_IMAGE=$(CORE_DNS_IMAGE) \ KUBE_RBAC_PROXY_IMAGE=$(KUBE_RBAC_PROXY_IMAGE) \ ./hack/generate-manifests.sh diff --git a/README.md b/README.md index 1d57496b8..578130df8 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ spec: kubeMacPool: {} ovs: {} macvtap: {} + kubeSecondaryDNS: {} imagePullPolicy: Always ``` @@ -159,6 +160,26 @@ A simple example on how to do so, the user must deploy a `ConfigMap`, such as in Currently, this configuration is not dynamic. +## KubeSecondaryDNS + +[This controller](https://github.com/kubevirt/kubesecondarydns) +allows to support FQDN for VMI's secondary networks. + +```yaml +apiVersion: networkaddonsoperator.network.kubevirt.io/v1 +kind: NetworkAddonsConfig +metadata: + name: cluster +spec: + kubeSecondaryDNS: + DOMAIN: "" + NAME_SERVER_IP: "" +``` + +Additionally, container image used to deliver this plugin can be set using +`KUBE_SECONDARY_DNS_IMAGE` environment variable in operator +deployment manifest. + ## Image Pull Policy Administrator can specify [image pull policy](https://kubernetes.io/docs/concepts/containers/images/) diff --git a/automation/check-patch.e2e-kube-secondary-dns-functests.sh b/automation/check-patch.e2e-kube-secondary-dns-functests.sh new file mode 100755 index 000000000..ecf79d841 --- /dev/null +++ b/automation/check-patch.e2e-kube-secondary-dns-functests.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -xeuE + +# This script should be able to execute kube secondary dns +# functional tests against Kubernetes cluster with +# CNAO built with latest changes, on any +# environment with basic dependencies listed in +# check-patch.packages installed and docker running. +# +# yum -y install automation/check-patch.packages +# automation/check-patch.e2e-kube-secondary-dns-functests.sh + +teardown() { + cp $(find . -name "*junit*.xml") $ARTIFACTS || true + rm -rf "${TMP_COMPONENT_PATH}" + cd ${TMP_PROJECT_PATH} + make cluster-down +} + +main() { + # Setup CNAO and artifacts temp directory + source automation/check-patch.setup.sh + cd ${TMP_PROJECT_PATH} + + # Spin-up ephemeral cluster with latest CNAO + # this script also exports KUBECONFIG, and fetch $COMPONENT repository + COMPONENT="kube-secondary-dns" source automation/components-functests.setup.sh + + trap teardown EXIT + + cd ${TMP_COMPONENT_PATH} + make create-nodeport + echo "Run kube-secondary-dns functional tests" + make functest +} + +[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/components-functests.setup.sh b/automation/components-functests.setup.sh index 76836deb7..a63110250 100644 --- a/automation/components-functests.setup.sh +++ b/automation/components-functests.setup.sh @@ -48,6 +48,7 @@ spec: rangeEnd: "02:00:00:00:00:0F" ovs: {} macvtap: {} + kubeSecondaryDNS: {} imagePullPolicy: Always EOF diff --git a/components.yaml b/components.yaml index b59da2349..71153b71b 100644 --- a/components.yaml +++ b/components.yaml @@ -41,3 +41,9 @@ components: branch: main update-policy: tagged metadata: v0.29.1 + kube-secondary-dns: + url: https://github.com/kubevirt/kubesecondarydns + commit: a7779d99e0b196119f8bf9337186f091aea54df0 + branch: main + update-policy: tagged + metadata: v0.0.5 diff --git a/data/kube-secondary-dns/secondarydns.yaml b/data/kube-secondary-dns/secondarydns.yaml new file mode 100644 index 000000000..6babe355e --- /dev/null +++ b/data/kube-secondary-dns/secondarydns.yaml @@ -0,0 +1,131 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Namespace }} +--- +apiVersion: v1 +data: + DOMAIN: {{ .Domain }} + NAME_SERVER_IP: {{ .NameServerIp }} + Corefile: | + .:53 { + auto { + directory /zones db\.(.*) {1} + reload 45s + } + reload + log + } +kind: ConfigMap +metadata: + name: secondary-dns + namespace: {{ .Namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: secondary +rules: +- apiGroups: + - kubevirt.io + resources: + - virtualmachineinstances + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: secondary +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: secondary +subjects: + - kind: ServiceAccount + name: secondary + namespace: {{ .Namespace }} +--- +kind: ServiceAccount +apiVersion: v1 +metadata: + name: secondary + namespace: {{ .Namespace }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + k8s-app: secondary-dns + name: secondary-dns + namespace: {{ .Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + k8s-app: secondary-dns + template: + metadata: + labels: + k8s-app: secondary-dns + annotations: + kubectl.kubernetes.io/default-container: status-monitor + spec: + serviceAccountName: secondary + containers: + - args: + - -conf + - /etc/coredns/Corefile + image: {{ .CoreDNSImage }} + imagePullPolicy: {{ .ImagePullPolicy }} + name: secondary-dns + ports: + - containerPort: 53 + name: dns + protocol: UDP + resources: + limits: + memory: 170Mi + requests: + cpu: 100m + memory: 70Mi + volumeMounts: + - name: config-volume + mountPath: /etc/coredns + readOnly: true + - name: secdns-zones + mountPath: /zones + readOnly: true + - name: status-monitor + image: {{ .KubeSecondaryDNSImage }} + volumeMounts: + - name: secdns-zones + mountPath: /zones + env: + - name: DOMAIN + valueFrom: + configMapKeyRef: + name: secondary-dns + key: DOMAIN + - name: NAME_SERVER_IP + valueFrom: + configMapKeyRef: + name: secondary-dns + key: NAME_SERVER_IP + imagePullPolicy: {{ .ImagePullPolicy }} + priorityClassName: system-cluster-critical + restartPolicy: Always + terminationGracePeriodSeconds: 1 + volumes: + - name: config-volume + configMap: + defaultMode: 420 + items: + - key: Corefile + path: Corefile + name: secondary-dns + - name: secdns-zones + emptyDir: {} diff --git a/hack/components/bump-kube-secondary-dns.sh b/hack/components/bump-kube-secondary-dns.sh new file mode 100755 index 000000000..eadc2a1dd --- /dev/null +++ b/hack/components/bump-kube-secondary-dns.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +set -xeo pipefail + +source hack/components/yaml-utils.sh +source hack/components/git-utils.sh +source hack/components/docker-utils.sh + +function __parametize_by_object() { + for f in ./*; do + case "${f}" in + ./Namespace_secondary.yaml) + yaml-utils::update_param ${f} metadata.name '{{ .Namespace }}' + yaml-utils::remove_single_quotes_from_yaml ${f} + ;; + ./ConfigMap_secondary-dns.yaml) + yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}' + yaml-utils::update_param ${f} data.DOMAIN '{{ .Domain }}' + yaml-utils::update_param ${f} data.NAME_SERVER_IP '{{ .NameServerIp }}' + yaml-utils::remove_single_quotes_from_yaml ${f} + ;; + ./ClusterRoleBinding_secondary.yaml) + yaml-utils::update_param ${f} subjects[0].namespace '{{ .Namespace }}' + yaml-utils::remove_single_quotes_from_yaml ${f} + ;; + ./Deployment_secondary-dns.yaml) + yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}' + yaml-utils::update_param ${f} spec.template.spec.containers[0].image '{{ .CoreDNSImage }}' + yaml-utils::update_param ${f} spec.template.spec.containers[1].image '{{ .KubeSecondaryDNSImage }}' + yaml-utils::set_param ${f} spec.template.spec.containers[0].imagePullPolicy '{{ .ImagePullPolicy }}' + yaml-utils::set_param ${f} spec.template.spec.containers[1].imagePullPolicy '{{ .ImagePullPolicy }}' + yaml-utils::remove_single_quotes_from_yaml ${f} + ;; + ./ServiceAccount_secondary.yaml) + yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}' + yaml-utils::remove_single_quotes_from_yaml ${f} + ;; + esac + done +} + +echo 'Bumping kube-secondary-dns' +KUBE_SECONDARY_DNS_URL=$(yaml-utils::get_component_url kube-secondary-dns) +KUBE_SECONDARY_DNS_COMMIT=$(yaml-utils::get_component_commit kube-secondary-dns) +KUBE_SECONDARY_DNS_REPO=$(yaml-utils::get_component_repo ${KUBE_SECONDARY_DNS_URL}) + +TEMP_DIR=$(git-utils::create_temp_path kube-secondary-dns) +trap "rm -rf ${TEMP_DIR}" EXIT +KUBE_SECONDARY_DNS_PATH=${TEMP_DIR}/${KUBE_SECONDARY_DNS_REPO} + +echo 'Fetch kube-secondary-dns sources' +git-utils::fetch_component ${KUBE_SECONDARY_DNS_PATH} ${KUBE_SECONDARY_DNS_URL} ${KUBE_SECONDARY_DNS_COMMIT} + +echo 'Adjust kube-secondary-dns to CNAO' +( + cd ${KUBE_SECONDARY_DNS_PATH} + mkdir -p config/cnao + cp manifests/secondarydns.yaml config/cnao + + echo 'Split manifest per object' + cd config/cnao + $(yaml-utils::split_yaml_by_seperator . secondarydns.yaml) + + rm secondarydns.yaml + $(yaml-utils::rename_files_by_object .) + + echo 'parametize manifests by object' + __parametize_by_object + + echo 'rejoin sub-manifests to a final manifest' + cat Namespace_secondary.yaml \ + ConfigMap_secondary-dns.yaml \ + ClusterRole_secondary.yaml \ + ClusterRoleBinding_secondary.yaml \ + ServiceAccount_secondary.yaml \ + Deployment_secondary-dns.yaml > secondarydns.yaml +) + +echo 'copy manifests' +rm -rf data/kube-secondary-dns/* +cp ${KUBE_SECONDARY_DNS_PATH}/config/cnao/secondarydns.yaml data/kube-secondary-dns + +echo 'Get kube-secondary-dns image name and update it under CNAO' +KUBE_SECONDARY_DNS_TAG=$(git-utils::get_component_tag ${KUBE_SECONDARY_DNS_PATH}) +KUBE_SECONDARY_DNS_IMAGE=ghcr.io/kubevirt/kubesecondarydns +KUBE_SECONDARY_DNS_IMAGE_TAGGED=${KUBE_SECONDARY_DNS_IMAGE}:${KUBE_SECONDARY_DNS_TAG} +KUBE_SECONDARY_DNS_IMAGE_DIGEST="$(docker-utils::get_image_digest "${KUBE_SECONDARY_DNS_IMAGE_TAGGED}" "${KUBE_SECONDARY_DNS_IMAGE}")" + +sed -i -r "s#\"${KUBE_SECONDARY_DNS_IMAGE}(@sha256)?:.*\"#\"${KUBE_SECONDARY_DNS_IMAGE_DIGEST}\"#" pkg/components/components.go +sed -i -r "s#\"${KUBE_SECONDARY_DNS_IMAGE}(@sha256)?:.*\"#\"${KUBE_SECONDARY_DNS_IMAGE_DIGEST}\"#" test/releases/${CNAO_VERSION}.go diff --git a/hack/generate-manifests.sh b/hack/generate-manifests.sh index 0a912305b..231faaf53 100755 --- a/hack/generate-manifests.sh +++ b/hack/generate-manifests.sh @@ -26,6 +26,7 @@ for template in $templates; do --container-tag=${CONTAINER_TAG} \ --image-pull-policy=${IMAGE_PULL_POLICY} \ --kube-rbac-proxy-image=${KUBE_RBAC_PROXY_IMAGE} \ + --core-dns-image=${CORE_DNS_IMAGE} \ --input-file=${infile} \ ) if [[ ! -z "$rendered" ]]; then diff --git a/pkg/apis/networkaddonsoperator/shared/networkaddonsconfig_types.go b/pkg/apis/networkaddonsoperator/shared/networkaddonsconfig_types.go index d94ef352a..aebd51525 100644 --- a/pkg/apis/networkaddonsoperator/shared/networkaddonsconfig_types.go +++ b/pkg/apis/networkaddonsoperator/shared/networkaddonsconfig_types.go @@ -16,6 +16,7 @@ type NetworkAddonsConfigSpec struct { KubeMacPool *KubeMacPool `json:"kubeMacPool,omitempty"` ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` NMState *NMState `json:"nmstate,omitempty"` + KubeSecondaryDNS *KubeSecondaryDNS `json:"kubeSecondaryDNS,omitempty"` MacvtapCni *MacvtapCni `json:"macvtap,omitempty"` SelfSignConfiguration *SelfSignConfiguration `json:"selfSignConfiguration,omitempty"` PlacementConfiguration *PlacementConfiguration `json:"placementConfiguration,omitempty"` @@ -63,6 +64,14 @@ type Ovs struct{} // NMState is a declarative node network configuration driven through Kubernetes API type NMState struct{} +// KubeSecondaryDNS plugin allows to support FQDN for VMI's secondary networks +type KubeSecondaryDNS struct { + // Domain defines the FQDN domain + Domain string `json:"domain,omitempty"` + // NameServerIp defines the name server IP + NameServerIP string `json:"nameServerIP,omitempty"` +} + // KubeMacPool plugin manages MAC allocation to Pods and VMs in Kubernetes type KubeMacPool struct { // RangeStart defines the first mac in range diff --git a/pkg/components/components.go b/pkg/components/components.go index 4cf9c5086..7eb29a690 100644 --- a/pkg/components/components.go +++ b/pkg/components/components.go @@ -37,6 +37,8 @@ const ( OvsCniImageDefault = "quay.io/kubevirt/ovs-cni-plugin@sha256:3654b80dd5e459c3e73dd027d732620ed8b488b8a15dfe7922457d16c7e834c3" MacvtapCniImageDefault = "quay.io/kubevirt/macvtap-cni@sha256:5a288f1f9956c2ea8127fa736b598326852d2aa58a8469fa663a1150c2313b02" KubeRbacProxyImageDefault = "quay.io/openshift/origin-kube-rbac-proxy@sha256:baedb268ac66456018fb30af395bb3d69af5fff3252ff5d549f0231b1ebb6901" + KubeSecondaryDNSImageDefault = "ghcr.io/kubevirt/kubesecondarydns@sha256:b25074818c76d149cbf64bfb4b5559afcc1c3d4733b450ce70856903a80eb2c7" + CoreDNSImageDefault = "k8s.gcr.io/coredns/coredns@sha256:5b6ec0d6de9baaf3e92d0f66cd96a25b9edbce8716f5f15dcd1a616b3abd590e" ) type AddonsImages struct { @@ -48,6 +50,8 @@ type AddonsImages struct { OvsCni string MacvtapCni string KubeRbacProxy string + KubeSecondaryDNS string + CoreDNS string } type RelatedImage struct { @@ -96,6 +100,12 @@ func (ai *AddonsImages) FillDefaults() *AddonsImages { if ai.KubeRbacProxy == "" { ai.KubeRbacProxy = KubeRbacProxyImageDefault } + if ai.KubeSecondaryDNS == "" { + ai.KubeSecondaryDNS = KubeSecondaryDNSImageDefault + } + if ai.CoreDNS == "" { + ai.CoreDNS = CoreDNSImageDefault + } return ai } @@ -109,6 +119,8 @@ func (ai AddonsImages) ToRelatedImages() RelatedImages { ai.OvsCni, ai.MacvtapCni, ai.KubeRbacProxy, + ai.KubeSecondaryDNS, + ai.CoreDNS, ) } @@ -218,6 +230,14 @@ func GetDeployment(version string, operatorVersion string, namespace string, rep Name: "KUBE_RBAC_PROXY_IMAGE", Value: addonsImages.KubeRbacProxy, }, + { + Name: "KUBE_SECONDARY_DNS_IMAGE", + Value: addonsImages.KubeSecondaryDNS, + }, + { + Name: "CORE_DNS_IMAGE", + Value: addonsImages.CoreDNS, + }, { Name: "OPERATOR_IMAGE", Value: image, @@ -813,6 +833,20 @@ func GetCrd() *extv1.CustomResourceDefinition { Description: "A multus extension enabling hot-plug and hot-unplug of Pod interfaces", Type: "object", }, + "kubeSecondaryDNS": extv1.JSONSchemaProps{ + Description: "KubeSecondaryDNS plugin allows to support FQDN for VMI's secondary networks", + Type: "object", + Properties: map[string]extv1.JSONSchemaProps{ + "domain": extv1.JSONSchemaProps{ + Description: "Domain defines the FQDN domain", + Type: "string", + }, + "nameServerIP": extv1.JSONSchemaProps{ + Description: "NameServerIp defines the name server IP", + Type: "string", + }, + }, + }, "ovs": extv1.JSONSchemaProps{ Description: "Ovs plugin allows users to define Kubernetes networks on top of Open vSwitch bridges available on nodes", Type: "object", @@ -1035,6 +1069,7 @@ func GetCRV1() *cnaov1.NetworkAddonsConfig { KubeMacPool: &cnao.KubeMacPool{}, Ovs: &cnao.Ovs{}, MacvtapCni: &cnao.MacvtapCni{}, + KubeSecondaryDNS: &cnao.KubeSecondaryDNS{}, ImagePullPolicy: corev1.PullIfNotPresent, }, } diff --git a/pkg/network/kube_secondary_dns_controller.go b/pkg/network/kube_secondary_dns_controller.go new file mode 100644 index 000000000..09c9fb75b --- /dev/null +++ b/pkg/network/kube_secondary_dns_controller.go @@ -0,0 +1,35 @@ +package network + +import ( + "os" + "path/filepath" + + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + + cnao "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/shared" + "github.com/kubevirt/cluster-network-addons-operator/pkg/render" +) + +// renderKubeSecondaryDNS generates the manifests of kube-secondary-dns +func renderKubeSecondaryDNS(conf *cnao.NetworkAddonsConfigSpec, manifestDir string, clusterInfo *ClusterInfo) ([]*unstructured.Unstructured, error) { + if conf.KubeSecondaryDNS == nil { + return nil, nil + } + + // render the manifests on disk + data := render.MakeRenderData() + data.Data["Namespace"] = os.Getenv("OPERAND_NAMESPACE") + data.Data["ImagePullPolicy"] = conf.ImagePullPolicy + data.Data["Domain"] = conf.KubeSecondaryDNS.Domain + data.Data["NameServerIp"] = conf.KubeSecondaryDNS.NameServerIP + data.Data["KubeSecondaryDNSImage"] = os.Getenv("KUBE_SECONDARY_DNS_IMAGE") + data.Data["CoreDNSImage"] = os.Getenv("CORE_DNS_IMAGE") + + objs, err := render.RenderDir(filepath.Join(manifestDir, "kube-secondary-dns"), &data) + if err != nil { + return nil, errors.Wrap(err, "failed to render kube-secondary-dns state handler manifests") + } + + return objs, nil +} diff --git a/pkg/network/network.go b/pkg/network/network.go index 2aa7b7ac8..483143ffc 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -153,6 +153,13 @@ func Render(conf *cnao.NetworkAddonsConfigSpec, manifestDir string, openshiftNet } objs = append(objs, o...) + // render KubeSecondaryDNS + o, err = renderKubeSecondaryDNS(conf, manifestDir, clusterInfo) + if err != nil { + return nil, err + } + objs = append(objs, o...) + // render Monitoring Service o, err = monitoring.RenderMonitoring(manifestDir, clusterInfo.MonitoringAvailable) if err != nil { @@ -222,6 +229,15 @@ func RenderObjsToRemove(prev, conf *cnao.NetworkAddonsConfigSpec, manifestDir st objsToRemove = append(objsToRemove, o...) } + // render KubeSecondaryDNS + if conf.KubeSecondaryDNS == nil { + o, err := renderKubeSecondaryDNS(conf, manifestDir, clusterInfo) + if err != nil { + return nil, err + } + objsToRemove = append(objsToRemove, o...) + } + // Remove OPERAND_NAMESPACE occurences // TODO cleanup OPERAND_NAMESPACE once there are no components using it. objsToRemoveWithoutNamespace := []*unstructured.Unstructured{} diff --git a/test/check/components.go b/test/check/components.go index 358b536ca..f2fa6abf9 100644 --- a/test/check/components.go +++ b/test/check/components.go @@ -80,6 +80,12 @@ var ( "dynamic-networks-controller-ds", }, } + KubeSecondaryDNSComponent = Component{ + ComponentName: "KubeSecondaryDNS", + ClusterRole: "secondary", + ClusterRoleBinding: "secondary", + Deployments: []string{"secondary-dns"}, + } AllComponents = []Component{ KubeMacPoolComponent, LinuxBridgeComponent, @@ -88,6 +94,7 @@ var ( MacvtapComponent, MonitoringComponent, MultusDynamicNetworks, + KubeSecondaryDNSComponent, } ) diff --git a/test/e2e/workflow/deployment_test.go b/test/e2e/workflow/deployment_test.go index 214d5c66f..3439f881b 100644 --- a/test/e2e/workflow/deployment_test.go +++ b/test/e2e/workflow/deployment_test.go @@ -80,6 +80,13 @@ var _ = Describe("NetworkAddonsConfig", func() { }, []Component{MultusComponent, MultusDynamicNetworks}, ), + Entry( + KubeSecondaryDNSComponent.ComponentName, + cnao.NetworkAddonsConfigSpec{ + KubeSecondaryDNS: &cnao.KubeSecondaryDNS{}, + }, + []Component{KubeSecondaryDNSComponent}, + ), ) It("should deploy prometheus if NetworkAddonsConfigSpec is not empty", func() { testConfigCreate(gvk, cnao.NetworkAddonsConfigSpec{MacvtapCni: &cnao.MacvtapCni{}}, []Component{MacvtapComponent, MonitoringComponent}) @@ -93,6 +100,7 @@ var _ = Describe("NetworkAddonsConfig", func() { OvsComponent, MacvtapComponent, MultusDynamicNetworks, + KubeSecondaryDNSComponent, } configSpec := cnao.NetworkAddonsConfigSpec{ KubeMacPool: &cnao.KubeMacPool{}, @@ -101,6 +109,7 @@ var _ = Describe("NetworkAddonsConfig", func() { Ovs: &cnao.Ovs{}, MacvtapCni: &cnao.MacvtapCni{}, MultusDynamicNetworks: &cnao.MultusDynamicNetworks{}, + KubeSecondaryDNS: &cnao.KubeSecondaryDNS{}, } testConfigCreate(gvk, configSpec, components) }) @@ -144,6 +153,11 @@ var _ = Describe("NetworkAddonsConfig", func() { configSpec.MultusDynamicNetworks = &cnao.MultusDynamicNetworks{} components = append(components, MultusComponent, MultusDynamicNetworks) testConfigUpdate(gvk, configSpec, components) + + // Add KubeSecondaryDNS component + configSpec.KubeSecondaryDNS = &cnao.KubeSecondaryDNS{} + components = append(components, KubeSecondaryDNSComponent) + testConfigUpdate(gvk, configSpec, components) }) Context("and workload PlacementConfiguration is deployed on components", func() { components := []Component{ @@ -241,6 +255,7 @@ var _ = Describe("NetworkAddonsConfig", func() { MacvtapComponent, MonitoringComponent, MultusDynamicNetworks, + KubeSecondaryDNSComponent, } configSpec := cnao.NetworkAddonsConfigSpec{ LinuxBridge: &cnao.LinuxBridge{}, @@ -249,6 +264,7 @@ var _ = Describe("NetworkAddonsConfig", func() { Ovs: &cnao.Ovs{}, MacvtapCni: &cnao.MacvtapCni{}, MultusDynamicNetworks: &cnao.MultusDynamicNetworks{}, + KubeSecondaryDNS: &cnao.KubeSecondaryDNS{}, } BeforeEach(func() { CreateConfig(gvk, configSpec) diff --git a/test/releases/99.0.0.go b/test/releases/99.0.0.go index f804a9c2e..bb6043960 100644 --- a/test/releases/99.0.0.go +++ b/test/releases/99.0.0.go @@ -5,6 +5,8 @@ import ( "github.com/kubevirt/cluster-network-addons-operator/pkg/components" ) +const secondaryDNSDeployment = "secondary-dns" + func init() { release := Release{ Version: "99.0.0", @@ -69,6 +71,18 @@ func init() { Name: "ovs-cni-marker", Image: "quay.io/kubevirt/ovs-cni-plugin@sha256:3654b80dd5e459c3e73dd027d732620ed8b488b8a15dfe7922457d16c7e834c3", }, + { + ParentName: secondaryDNSDeployment, + ParentKind: "Deployment", + Name: "status-monitor", + Image: "ghcr.io/kubevirt/kubesecondarydns@sha256:b25074818c76d149cbf64bfb4b5559afcc1c3d4733b450ce70856903a80eb2c7", + }, + { + ParentName: secondaryDNSDeployment, + ParentKind: "Deployment", + Name: "secondary-dns", + Image: components.CoreDNSImageDefault, + }, }, SupportedSpec: cnao.NetworkAddonsConfigSpec{ KubeMacPool: &cnao.KubeMacPool{}, @@ -76,6 +90,7 @@ func init() { Multus: &cnao.Multus{}, Ovs: &cnao.Ovs{}, MultusDynamicNetworks: &cnao.MultusDynamicNetworks{}, + KubeSecondaryDNS: &cnao.KubeSecondaryDNS{}, }, Manifests: []string{ "network-addons-config.crd.yaml", diff --git a/tools/manifest-templator/manifest-templator.go b/tools/manifest-templator/manifest-templator.go index 60f53b868..c07ee1539 100644 --- a/tools/manifest-templator/manifest-templator.go +++ b/tools/manifest-templator/manifest-templator.go @@ -247,7 +247,9 @@ func main() { ovsCniImage := flag.String("ovs-cni-image", components.OvsCniImageDefault, "The ovs cni image managed by CNA") macvtapCniImage := flag.String("macvtap-cni-image", components.MacvtapCniImageDefault, "The macvtap cni image managed by CNA") kubeRbacProxyImage := flag.String("kube-rbac-proxy-image", components.KubeRbacProxyImageDefault, "The kube rbac proxy used by CNA") + coreDNSImage := flag.String("core-dns-image", components.CoreDNSImageDefault, "The coredns image used by CNA") multusDynamicNetworksImage := flag.String("multus-dynamic-networks-image", components.MultusDynamicNetworksImageDefault, "The multus dynamic networks controller image managed by CNA") + kubeSecondaryDNSImage := flag.String("kube-secondary-dns", components.KubeSecondaryDNSImageDefault, "The kubesecondarydns-image managed by CNA") dumpOperatorCRD := flag.Bool("dump-crds", false, "Append operator CRD to bottom of template. Used for csv-generator") inputFile := flag.String("input-file", "", "Not used for csv-generator") pflag.CommandLine.AddGoFlagSet(flag.CommandLine) @@ -272,6 +274,8 @@ func main() { MacvtapCni: *macvtapCniImage, KubeRbacProxy: *kubeRbacProxyImage, MultusDynamicNetworks: *multusDynamicNetworksImage, + KubeSecondaryDNS: *kubeSecondaryDNSImage, + CoreDNS: *coreDNSImage, }).FillDefaults(), }