diff --git a/pkg/dns/dns.go b/pkg/dns/dns.go index 88e0807b5..6f7166e03 100644 --- a/pkg/dns/dns.go +++ b/pkg/dns/dns.go @@ -55,8 +55,7 @@ func NewClient(logger logrus.FieldLogger, kubeClient kubernetes.Interface) *Clie } } -// CheckDNSProvider checks that the DNS provider that is deployed in the cluster -// is supported and returns it. +// CheckDNSProvider checks that the DNS provider deployed in the cluster is supported and returns it. func (c *Client) CheckDNSProvider() (Provider, error) { c.logger.Info("Checking DNS provider") @@ -134,7 +133,7 @@ func (c *Client) kubeDNSMatch() (bool, error) { } if err != nil { - return false, fmt.Errorf("unable to get KubeDNS deployment in namesapce %q: %w", metav1.NamespaceSystem, err) + return false, fmt.Errorf("unable to get KubeDNS deployment in namespace %q: %w", metav1.NamespaceSystem, err) } c.logger.Info("KubeDNS match") @@ -170,7 +169,7 @@ func (c *Client) ConfigureCoreDNS(coreDNSNamespace, clusterDomain, maeshNamespac } func (c *Client) patchCoreDNSConfig(deployment *appsv1.Deployment, clusterDomain, maeshNamespace string) (*corev1.ConfigMap, error) { - customConfigMap, err := c.getConfigMap(deployment.Namespace, "coredns-custom") + customConfigMap, err := c.getConfigMap(deployment, "coredns-custom") // For AKS the CoreDNS config have to be added to the coredns-custom ConfigMap. // See https://docs.microsoft.com/en-us/azure/aks/coredns-custom @@ -184,11 +183,7 @@ func (c *Client) patchCoreDNSConfig(deployment *appsv1.Deployment, clusterDomain return customConfigMap, nil } - if !kerrors.IsNotFound(err) { - return nil, fmt.Errorf("unable to get coredns-custom configmap: %w", err) - } - - coreDNSConfigMap, err := c.getCorefileConfigMap(deployment) + coreDNSConfigMap, err := c.getConfigMap(deployment, "coredns") if err != nil { return nil, err } @@ -245,102 +240,75 @@ maesh:53 { func (c *Client) ConfigureKubeDNS(clusterDomain, maeshNamespace string) error { c.logger.Debug("Patching KubeDNS") - deployment, err := c.kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Get("kube-dns", metav1.GetOptions{}) + kubeDNSDeployment, err := c.kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Get("kube-dns", metav1.GetOptions{}) if err != nil { return err } - var ( - serviceIP string - ebo = backoff.NewConstantBackOff(10 * time.Second) - ) - c.logger.Debug("Getting CoreDNS service IP") - if err = backoff.Retry(safe.OperationWithRecover(func() error { - svc, errSvc := c.kubeClient.CoreV1().Services(maeshNamespace).Get("coredns", metav1.GetOptions{}) - if errSvc != nil { - return fmt.Errorf("unable get the service %q in namespace %q: %w", "coredns", "maesh", errSvc) + var coreDNSServiceIP string + + operation := func() error { + svc, svcErr := c.kubeClient.CoreV1().Services(maeshNamespace).Get("coredns", metav1.GetOptions{}) + if svcErr != nil { + return fmt.Errorf("unable to get coredns service in namespace %q: %w", maeshNamespace, err) } + if svc.Spec.ClusterIP == "" { - return fmt.Errorf("service %q has no clusterIP", "coredns") + return fmt.Errorf("coredns service in namespace %q has no clusterip", maeshNamespace) } - serviceIP = svc.Spec.ClusterIP + coreDNSServiceIP = svc.Spec.ClusterIP + return nil - }), backoff.WithMaxRetries(ebo, 12)); err != nil { - return fmt.Errorf("unable get the service %q in namespace %q: %w", "coredns", "maesh", err) } - configMap, err := c.getKubeDNSConfigMap(deployment) - if err != nil { + if err = backoff.Retry(safe.OperationWithRecover(operation), backoff.WithMaxRetries(backoff.NewConstantBackOff(10*time.Second), 12)); err != nil { return err } - c.logger.Debug("Patching KubeDNS configmap with IP", serviceIP) + c.logger.Debugf("Patching KubeDNS ConfigMap with CoreDNS service IP %q", coreDNSServiceIP) - if err := c.patchKubeDNSConfigMap(configMap, deployment.Namespace, serviceIP); err != nil { + if err := c.patchKubeDNSConfig(kubeDNSDeployment, coreDNSServiceIP); err != nil { return err } - c.logger.Debug("Patching CoreDNS configmap") - if err := c.ConfigureCoreDNS(maeshNamespace, clusterDomain, maeshNamespace); err != nil { return err } - if err := c.restartPods(deployment); err != nil { + if err := c.restartPods(kubeDNSDeployment); err != nil { return err } return nil } -// getKubeDNSConfigMap parses the deployment and returns the associated configuration configmap. -func (c *Client) getKubeDNSConfigMap(kubeDeployment *appsv1.Deployment) (*corev1.ConfigMap, error) { - for _, volume := range kubeDeployment.Spec.Template.Spec.Volumes { - if volume.ConfigMap == nil { - continue - } - - cfgMap, err := c.kubeClient.CoreV1().ConfigMaps(kubeDeployment.Namespace).Get(volume.ConfigMap.Name, metav1.GetOptions{}) - if err != nil { - return nil, err - } - - return cfgMap, nil - } - - return nil, errors.New("corefile configmap not found") -} - -func (c *Client) patchKubeDNSConfigMap(kubeConfigMap *corev1.ConfigMap, namespace, coreDNSIp string) error { - originalBlock, exist := kubeConfigMap.Data["stubDomains"] - if !exist { - originalBlock = "{}" +func (c *Client) patchKubeDNSConfig(deployment *appsv1.Deployment, coreDNSServiceIP string) error { + configMap, err := c.getOrCreateConfigMap(deployment, "kube-dns") + if err != nil { + return err } stubDomains := make(map[string][]string) - if err := json.Unmarshal([]byte(originalBlock), &stubDomains); err != nil { - return err - } - stubDomains["maesh"] = []string{coreDNSIp} + if stubDomainsStr := configMap.Data["stubDomains"]; stubDomainsStr != "" { + if err = json.Unmarshal([]byte(stubDomainsStr), &stubDomains); err != nil { + return fmt.Errorf("unable to unmarshal stub domains: %w", err) + } + } - var newData []byte + stubDomains["maesh"] = []string{coreDNSServiceIP} - newData, err := json.Marshal(stubDomains) + configMapData, err := json.Marshal(stubDomains) if err != nil { - return err - } - - if kubeConfigMap.Data == nil { - kubeConfigMap.Data = make(map[string]string) + return fmt.Errorf("unable to marshal stub domains: %w", err) } - kubeConfigMap.Data["stubDomains"] = string(newData) + configMap.Data["stubDomains"] = string(configMapData) - if _, err := c.kubeClient.CoreV1().ConfigMaps(namespace).Update(kubeConfigMap); err != nil { + if _, err := c.kubeClient.CoreV1().ConfigMaps(configMap.Namespace).Update(configMap); err != nil { return err } @@ -388,7 +356,7 @@ func (c *Client) RestoreCoreDNS() error { } func (c *Client) unpatchCoreDNSConfig(deployment *appsv1.Deployment) (*corev1.ConfigMap, error) { - customConfigMap, err := c.getConfigMap(deployment.Namespace, "coredns-custom") + customConfigMap, err := c.getConfigMap(deployment, "coredns-custom") // For AKS the CoreDNS config have to be removed from the coredns-custom ConfigMap. // See https://docs.microsoft.com/en-us/azure/aks/coredns-custom @@ -397,11 +365,7 @@ func (c *Client) unpatchCoreDNSConfig(deployment *appsv1.Deployment) (*corev1.Co return customConfigMap, nil } - if !kerrors.IsNotFound(err) { - return nil, fmt.Errorf("unable to get coredns-custom configmap: %w", err) - } - - coreDNSConfigMap, err := c.getCorefileConfigMap(deployment) + coreDNSConfigMap, err := c.getConfigMap(deployment, "coredns") if err != nil { return nil, err } @@ -427,78 +391,89 @@ func (c *Client) unpatchCoreDNSConfig(deployment *appsv1.Deployment) (*corev1.Co // RestoreKubeDNS restores the KubeDNS configuration to pre-install state. func (c *Client) RestoreKubeDNS() error { - deployment, err := c.kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Get("kube-dns", metav1.GetOptions{}) + kubeDNSDeployment, err := c.kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Get("kube-dns", metav1.GetOptions{}) if err != nil { return err } // Get the currently loaded KubeDNS ConfigMap. - configMap, err := c.getKubeDNSConfigMap(deployment) + configMap, err := c.getConfigMap(kubeDNSDeployment, "kube-dns") if err != nil { return err } // Check if stubDomains are still defined. - originalBlock, exist := configMap.Data["stubDomains"] - if !exist { + stubDomainsStr := configMap.Data["stubDomains"] + if stubDomainsStr == "" { return nil } stubDomains := make(map[string][]string) - if err = json.Unmarshal([]byte(originalBlock), &stubDomains); err != nil { - return fmt.Errorf("could not unmarshal stubdomains: %w", err) + if err = json.Unmarshal([]byte(stubDomainsStr), &stubDomains); err != nil { + return fmt.Errorf("unable to unmarshal stubdomains: %w", err) } // Delete our stubDomain. delete(stubDomains, "maesh") - newData, err := json.Marshal(stubDomains) + configMapData, err := json.Marshal(stubDomains) if err != nil { return err } - // If there are no stubDomains left, delete the field. - if string(newData) == "{}" { - delete(configMap.Data, "stubDomains") - } else { - configMap.Data["stubDomains"] = string(newData) - } + configMap.Data["stubDomains"] = string(configMapData) - // Update the KubeDNS configmap to the backup. if _, err := c.kubeClient.CoreV1().ConfigMaps(configMap.Namespace).Update(configMap); err != nil { return err } - if err := c.restartPods(deployment); err != nil { + if err := c.restartPods(kubeDNSDeployment); err != nil { return err } return nil } -func (c *Client) getCorefileConfigMap(deployment *appsv1.Deployment) (*corev1.ConfigMap, error) { - for _, volume := range deployment.Spec.Template.Spec.Volumes { - if volume.ConfigMap == nil { - continue - } +// getOrCreateConfigMap parses the deployment and returns the ConfigMap with the given name. This method will create the +// corresponding ConfigMap if the associated volume is marked as optional and the ConfigMap is not found. +func (c *Client) getOrCreateConfigMap(deployment *appsv1.Deployment, name string) (*corev1.ConfigMap, error) { + volumeSrc, err := getConfigMapVolumeSource(deployment, name) + if err != nil { + return nil, err + } - configMap, err := c.getConfigMap(deployment.Namespace, volume.ConfigMap.Name) - if err != nil { - return nil, err - } + configMap, err := c.kubeClient.CoreV1().ConfigMaps(deployment.Namespace).Get(volumeSrc.Name, metav1.GetOptions{}) - if _, exists := configMap.Data["Corefile"]; !exists { - continue + if kerrors.IsNotFound(err) && volumeSrc.Optional != nil && *volumeSrc.Optional { + configMap = &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: deployment.Namespace, + }, } - return configMap, nil + configMap, err = c.kubeClient.CoreV1().ConfigMaps(deployment.Namespace).Create(configMap) + } + + if err != nil { + return nil, err + } + + if configMap.Data == nil { + configMap.Data = make(map[string]string) } - return nil, errors.New("corefile configmap not found") + return configMap, err } -func (c *Client) getConfigMap(namespace, name string) (*corev1.ConfigMap, error) { - configMap, err := c.kubeClient.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{}) +// getConfigMap parses the deployment and returns the ConfigMap with the given name. +func (c *Client) getConfigMap(deployment *appsv1.Deployment, name string) (*corev1.ConfigMap, error) { + volumeSrc, err := getConfigMapVolumeSource(deployment, name) + if err != nil { + return nil, err + } + + configMap, err := c.kubeClient.CoreV1().ConfigMaps(deployment.Namespace).Get(volumeSrc.Name, metav1.GetOptions{}) if err != nil { return nil, err } @@ -509,3 +484,20 @@ func (c *Client) getConfigMap(namespace, name string) (*corev1.ConfigMap, error) return configMap, nil } + +// getConfigMapVolumeSource returns the ConfigMapVolumeSource corresponding to the ConfigMap with the given name. +func getConfigMapVolumeSource(deployment *appsv1.Deployment, name string) (*corev1.ConfigMapVolumeSource, error) { + for _, volume := range deployment.Spec.Template.Spec.Volumes { + if volume.ConfigMap == nil { + continue + } + + if volume.ConfigMap.Name != name { + continue + } + + return volume.ConfigMap, nil + } + + return nil, fmt.Errorf("configmap %q cannot be found", name) +} diff --git a/pkg/dns/dns_test.go b/pkg/dns/dns_test.go index c65a247ef..276be9b35 100644 --- a/pkg/dns/dns_test.go +++ b/pkg/dns/dns_test.go @@ -139,7 +139,7 @@ func TestConfigureCoreDNS(t *testing.T) { require.NoError(t, err) - cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("coredns-cfgmap", metav1.GetOptions{}) + cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("coredns", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, test.expectedCorefile, cfgMap.Data["Corefile"]) @@ -162,20 +162,24 @@ func TestConfigureKubeDNS(t *testing.T) { expectedErr bool }{ { - desc: "First time config of KubeDNS", + desc: "should return an error if kube-dns deployment does not exist", + mockFile: "configurekubedns_missing_deployment.yaml", + expectedErr: true, + }, + { + desc: "should add maesh stubdomain config in kube-dns configmap", mockFile: "configurekubedns_not_patched.yaml", - expectedErr: false, expectedStubDomains: `{"maesh":["1.2.3.4"]}`, }, { - desc: "Already patched", + desc: "should replace maesh stubdomain config in kube-dns configmap", mockFile: "configurekubedns_already_patched.yaml", expectedStubDomains: `{"maesh":["1.2.3.4"]}`, }, { - desc: "Missing KubeDNS deployment", - mockFile: "configurekubedns_missing_deployment.yaml", - expectedErr: true, + desc: "should create optional kube-dns configmap and add maesh stubdomain config", + mockFile: "configurekubedns_optional_configmap.yaml", + expectedStubDomains: `{"maesh":["1.2.3.4"]}`, }, } @@ -201,7 +205,7 @@ func TestConfigureKubeDNS(t *testing.T) { require.NoError(t, err) - cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("kubedns-cfgmap", metav1.GetOptions{}) + cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("kube-dns", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, test.expectedStubDomains, cfgMap.Data["stubDomains"]) @@ -257,7 +261,7 @@ func TestRestoreCoreDNS(t *testing.T) { err := client.RestoreCoreDNS() require.NoError(t, err) - cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("coredns-cfgmap", metav1.GetOptions{}) + cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("coredns", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, test.expectedCorefile, cfgMap.Data["Corefile"]) @@ -311,7 +315,7 @@ func TestRestoreKubeDNS(t *testing.T) { err := client.RestoreKubeDNS() require.NoError(t, err) - cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("kubedns-cfgmap", metav1.GetOptions{}) + cfgMap, err := k8sClient.KubernetesClient().CoreV1().ConfigMaps("kube-system").Get("kube-dns", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, test.expectedStubDomains, cfgMap.Data["stubDomains"]) diff --git a/pkg/dns/testdata/configurecoredns_already_patched.yaml b/pkg/dns/testdata/configurecoredns_already_patched.yaml index ce07a4eec..65755912f 100644 --- a/pkg/dns/testdata/configurecoredns_already_patched.yaml +++ b/pkg/dns/testdata/configurecoredns_already_patched.yaml @@ -10,7 +10,7 @@ spec: - configMap: name: "other-cfgmap" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -21,7 +21,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/configurecoredns_custom_already_patched.yaml b/pkg/dns/testdata/configurecoredns_custom_already_patched.yaml index fb7f0a12d..3c4c750df 100644 --- a/pkg/dns/testdata/configurecoredns_custom_already_patched.yaml +++ b/pkg/dns/testdata/configurecoredns_custom_already_patched.yaml @@ -8,7 +8,7 @@ spec: spec: volumes: - configMap: - name: "coredns-cfgmap" + name: "coredns" - configMap: name: "coredns-custom" --- @@ -42,7 +42,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/configurecoredns_custom_not_patched.yaml b/pkg/dns/testdata/configurecoredns_custom_not_patched.yaml index 912c52f68..2d92699c9 100644 --- a/pkg/dns/testdata/configurecoredns_custom_not_patched.yaml +++ b/pkg/dns/testdata/configurecoredns_custom_not_patched.yaml @@ -8,7 +8,7 @@ spec: spec: volumes: - configMap: - name: "coredns-cfgmap" + name: "coredns" - configMap: name: "coredns-custom" --- @@ -21,7 +21,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/configurecoredns_not_patched.yaml b/pkg/dns/testdata/configurecoredns_not_patched.yaml index 0ea6c1b83..85ce27c64 100644 --- a/pkg/dns/testdata/configurecoredns_not_patched.yaml +++ b/pkg/dns/testdata/configurecoredns_not_patched.yaml @@ -10,7 +10,7 @@ spec: - configMap: name: "other-cfgmap" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -21,7 +21,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/configurekubedns_already_patched.yaml b/pkg/dns/testdata/configurekubedns_already_patched.yaml index 19250719e..a525f3c77 100644 --- a/pkg/dns/testdata/configurekubedns_already_patched.yaml +++ b/pkg/dns/testdata/configurekubedns_already_patched.yaml @@ -8,12 +8,12 @@ spec: spec: volumes: - configMap: - name: "kubedns-cfgmap" + name: "kube-dns" --- apiVersion: v1 kind: ConfigMap metadata: - name: kubedns-cfgmap + name: kube-dns namespace: kube-system --- apiVersion: v1 @@ -36,7 +36,7 @@ spec: - configMap: name: "other-cfgmap" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -47,7 +47,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: maesh data: Corefile: | @@ -69,4 +69,3 @@ data: reload loadbalance } - \ No newline at end of file diff --git a/pkg/dns/testdata/configurekubedns_not_patched.yaml b/pkg/dns/testdata/configurekubedns_not_patched.yaml index 918d735fe..a525f3c77 100644 --- a/pkg/dns/testdata/configurekubedns_not_patched.yaml +++ b/pkg/dns/testdata/configurekubedns_not_patched.yaml @@ -8,12 +8,12 @@ spec: spec: volumes: - configMap: - name: "kubedns-cfgmap" + name: "kube-dns" --- apiVersion: v1 kind: ConfigMap metadata: - name: kubedns-cfgmap + name: kube-dns namespace: kube-system --- apiVersion: v1 @@ -36,7 +36,7 @@ spec: - configMap: name: "other-cfgmap" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -47,7 +47,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: maesh data: Corefile: | diff --git a/pkg/dns/testdata/configurekubedns_optional_configmap.yaml b/pkg/dns/testdata/configurekubedns_optional_configmap.yaml new file mode 100644 index 000000000..9c5ac7a35 --- /dev/null +++ b/pkg/dns/testdata/configurekubedns_optional_configmap.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kube-dns + namespace: kube-system +spec: + template: + spec: + volumes: + - configMap: + name: "kube-dns" + optional: true +--- +apiVersion: v1 +kind: Service +metadata: + name: coredns + namespace: maesh +spec: + clusterIP: "1.2.3.4" +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: coredns + namespace: maesh +spec: + template: + spec: + volumes: + - configMap: + name: "other-cfgmap" + - configMap: + name: "coredns" +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: other-cfgmap + namespace: maesh +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: coredns + namespace: maesh +data: + Corefile: | + .:53 { + errors + health { + lameduck 5s + } + ready + kubernetes {{ pillar['dns_domain'] }} in-addr.arpa ip6.arpa { + pods insecure + fallthrough in-addr.arpa ip6.arpa + ttl 30 + } + prometheus :9153 + forward . /etc/resolv.conf + cache 30 + loop + reload + loadbalance + } diff --git a/pkg/dns/testdata/restorecoredns_custom_not_patched.yaml b/pkg/dns/testdata/restorecoredns_custom_not_patched.yaml index ee74c5998..f290967ff 100644 --- a/pkg/dns/testdata/restorecoredns_custom_not_patched.yaml +++ b/pkg/dns/testdata/restorecoredns_custom_not_patched.yaml @@ -10,7 +10,7 @@ spec: - configMap: name: "coredns-custom" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -23,7 +23,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/restorecoredns_custom_patched.yaml b/pkg/dns/testdata/restorecoredns_custom_patched.yaml index 134d2affe..24423bcb1 100644 --- a/pkg/dns/testdata/restorecoredns_custom_patched.yaml +++ b/pkg/dns/testdata/restorecoredns_custom_patched.yaml @@ -10,7 +10,7 @@ spec: - configMap: name: "coredns-custom" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -43,7 +43,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/restorecoredns_not_patched.yaml b/pkg/dns/testdata/restorecoredns_not_patched.yaml index 0ea6c1b83..85ce27c64 100644 --- a/pkg/dns/testdata/restorecoredns_not_patched.yaml +++ b/pkg/dns/testdata/restorecoredns_not_patched.yaml @@ -10,7 +10,7 @@ spec: - configMap: name: "other-cfgmap" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -21,7 +21,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/restorecoredns_patched.yaml b/pkg/dns/testdata/restorecoredns_patched.yaml index b32e7ac68..29eb36171 100644 --- a/pkg/dns/testdata/restorecoredns_patched.yaml +++ b/pkg/dns/testdata/restorecoredns_patched.yaml @@ -10,7 +10,7 @@ spec: - configMap: name: "other-cfgmap" - configMap: - name: "coredns-cfgmap" + name: "coredns" --- apiVersion: v1 kind: ConfigMap @@ -21,7 +21,7 @@ metadata: apiVersion: v1 kind: ConfigMap metadata: - name: coredns-cfgmap + name: coredns namespace: kube-system data: Corefile: | diff --git a/pkg/dns/testdata/restorekubedns_already_patched.yaml b/pkg/dns/testdata/restorekubedns_already_patched.yaml index cfa64e722..d7c151a34 100644 --- a/pkg/dns/testdata/restorekubedns_already_patched.yaml +++ b/pkg/dns/testdata/restorekubedns_already_patched.yaml @@ -8,12 +8,12 @@ spec: spec: volumes: - configMap: - name: "kubedns-cfgmap" + name: "kube-dns" --- apiVersion: v1 kind: ConfigMap metadata: - name: kubedns-cfgmap + name: kube-dns namespace: kube-system data: stubDomains: | diff --git a/pkg/dns/testdata/restorekubedns_not_patched.yaml b/pkg/dns/testdata/restorekubedns_not_patched.yaml index da97728e5..d2023de22 100644 --- a/pkg/dns/testdata/restorekubedns_not_patched.yaml +++ b/pkg/dns/testdata/restorekubedns_not_patched.yaml @@ -8,12 +8,12 @@ spec: spec: volumes: - configMap: - name: "kubedns-cfgmap" + name: "kube-dns" --- apiVersion: v1 kind: ConfigMap metadata: - name: kubedns-cfgmap + name: kube-dns namespace: kube-system --- apiVersion: v1