@@ -11,11 +11,17 @@ import (
11
11
"encoding/base64"
12
12
"encoding/gob"
13
13
"flag"
14
+ "fmt"
15
+ corev1 "k8s.io/api/core/v1"
16
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17
+ "k8s.io/apimachinery/pkg/types"
18
+ "k8s.io/apimachinery/pkg/util/yaml"
14
19
"os"
15
20
"path/filepath"
16
21
"slices"
17
22
"strings"
18
23
"testing"
24
+ "time"
19
25
20
26
. "github.com/onsi/ginkgo/v2"
21
27
. "github.com/onsi/gomega"
@@ -111,6 +117,28 @@ var _ = SynchronizedBeforeSuite(func() []byte {
111
117
useExistingCluster ,
112
118
)
113
119
120
+ By ("Overriding coreDNS resolver" )
121
+ // override coredns resolver to 8.8.8.8 and restart coredns deployment
122
+ // read the dns-override.yaml file
123
+ filePath , _ := filepath .Abs ("../../hack/kind/dns-override.yaml" )
124
+ yamlFile , err := os .ReadFile (filePath )
125
+ Expect (err ).To (BeNil (), "Failed to read the dns-override.yaml file" )
126
+
127
+ // decode the yaml file into a Kubernetes object
128
+ decode := yaml .NewYAMLOrJSONDecoder (bytes .NewReader (yamlFile ), 4096 )
129
+ configMap := & corev1.ConfigMap {}
130
+ err = decode .Decode (& configMap )
131
+ Expect (err ).To (BeNil (), "Failed to decode the yaml file into a Kubernetes object" )
132
+
133
+ _ , err = bootstrapClusterProxy .GetClientSet ().CoreV1 ().ConfigMaps (configMap .GetNamespace ()).Update (context .Background (), configMap , metav1.UpdateOptions {})
134
+ Expect (err ).To (BeNil (), "Failed to update the coredns deployment with the dns-override.yaml file" )
135
+
136
+ timeNow := time .Now ().Format (time .RFC3339 )
137
+ patch := fmt .Sprintf (`{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubernetes.io/restartedAt":"%s"}}}}}` , timeNow )
138
+
139
+ _ , err = bootstrapClusterProxy .GetClientSet ().AppsV1 ().Deployments ("kube-system" ).Patch (context .Background (), "coredns" , types .StrategicMergePatchType , []byte (patch ), metav1.PatchOptions {})
140
+ Expect (err ).To (BeNil (), "Failed to restart the coredns deployment" )
141
+
114
142
By ("Initializing the bootstrap cluster" )
115
143
initBootstrapCluster (bootstrapClusterProxy , e2eConfig , clusterctlConfigPath , artifactFolder )
116
144
@@ -240,6 +268,7 @@ func setupBootstrapCluster(
240
268
Expect (
241
269
kubeconfigPath ,
242
270
).To (BeAnExistingFile (), "Failed to get the kubeconfig file for the bootstrap cluster" )
271
+
243
272
} else {
244
273
// Loading image for already created cluster
245
274
imagesInput := capibootstrap.LoadImagesToKindClusterInput {
0 commit comments