Skip to content

Commit 26e0a46

Browse files
committed
Revert "build(e2e): Remove Kind DNS resolver override (#837)"
This reverts commit 64e1ff8.
1 parent f0912e3 commit 26e0a46

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

hack/kind/dns-override.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
data:
6+
Corefile: |
7+
.:53 {
8+
errors
9+
health {
10+
lameduck 5s
11+
}
12+
ready
13+
kubernetes cluster.local in-addr.arpa ip6.arpa {
14+
pods insecure
15+
fallthrough in-addr.arpa ip6.arpa
16+
ttl 30
17+
}
18+
prometheus :9153
19+
forward . 8.8.8.8
20+
cache 30
21+
loop
22+
reload
23+
loadbalance
24+
}
25+
kind: ConfigMap
26+
metadata:
27+
name: coredns
28+
namespace: kube-system

test/e2e/e2e_suite_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@ import (
1111
"encoding/base64"
1212
"encoding/gob"
1313
"flag"
14+
"fmt"
1415
"os"
1516
"path/filepath"
1617
"slices"
1718
"strings"
1819
"testing"
20+
"time"
1921

2022
. "github.com/onsi/ginkgo/v2"
2123
. "github.com/onsi/gomega"
24+
corev1 "k8s.io/api/core/v1"
2225
storagev1 "k8s.io/api/storage/v1"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2327
"k8s.io/apimachinery/pkg/runtime"
28+
"k8s.io/apimachinery/pkg/types"
29+
"k8s.io/apimachinery/pkg/util/yaml"
2430
"k8s.io/klog/v2"
2531
capie2e "sigs.k8s.io/cluster-api/test/e2e"
2632
capie2eframework "sigs.k8s.io/cluster-api/test/framework"
@@ -110,6 +116,39 @@ var _ = SynchronizedBeforeSuite(func() []byte {
110116
useExistingCluster,
111117
)
112118

119+
By("Overriding coreDNS resolver")
120+
// override coredns resolver to 8.8.8.8 and restart coredns deployment
121+
// read the dns-override.yaml file
122+
filePath, _ := filepath.Abs("../../hack/kind/dns-override.yaml")
123+
yamlFile, err := os.ReadFile(filePath)
124+
Expect(err).To(BeNil(), "Failed to read the dns-override.yaml file")
125+
126+
// decode the yaml file into a Kubernetes object
127+
decode := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(yamlFile), 4096)
128+
configMap := &corev1.ConfigMap{}
129+
err = decode.Decode(&configMap)
130+
Expect(err).To(BeNil(), "Failed to decode the yaml file into a Kubernetes object")
131+
132+
_, err = bootstrapClusterProxy.GetClientSet().
133+
CoreV1().
134+
ConfigMaps(configMap.GetNamespace()).
135+
Update(context.Background(), configMap, metav1.UpdateOptions{})
136+
Expect(
137+
err,
138+
).To(BeNil(), "Failed to update the coredns deployment with the dns-override.yaml file")
139+
140+
timeNow := time.Now().Format(time.RFC3339)
141+
patch := fmt.Sprintf(
142+
`{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubernetes.io/restartedAt":%q}}}}}`,
143+
timeNow,
144+
)
145+
146+
_, err = bootstrapClusterProxy.GetClientSet().
147+
AppsV1().
148+
Deployments("kube-system").
149+
Patch(context.Background(), "coredns", types.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{})
150+
Expect(err).To(BeNil(), "Failed to restart the coredns deployment")
151+
113152
By("Initializing the bootstrap cluster")
114153
initBootstrapCluster(bootstrapClusterProxy, e2eConfig, clusterctlConfigPath, artifactFolder)
115154

0 commit comments

Comments
 (0)