Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(e2e): Add back Kind DNS resolver override #966

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions hack/kind/dns-override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Nutanix. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
data:
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . 8.8.8.8
cache 30
loop
reload
loadbalance
}
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
39 changes: 39 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ import (
"encoding/base64"
"encoding/gob"
"flag"
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/klog/v2"
capie2e "sigs.k8s.io/cluster-api/test/e2e"
capie2eframework "sigs.k8s.io/cluster-api/test/framework"
Expand Down Expand Up @@ -110,6 +116,39 @@ var _ = SynchronizedBeforeSuite(func() []byte {
useExistingCluster,
)

By("Overriding coreDNS resolver")
// override coredns resolver to 8.8.8.8 and restart coredns deployment
// read the dns-override.yaml file
filePath, _ := filepath.Abs("../../hack/kind/dns-override.yaml")
yamlFile, err := os.ReadFile(filePath)
Expect(err).To(BeNil(), "Failed to read the dns-override.yaml file")

// decode the yaml file into a Kubernetes object
decode := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(yamlFile), 4096)
configMap := &corev1.ConfigMap{}
err = decode.Decode(&configMap)
Expect(err).To(BeNil(), "Failed to decode the yaml file into a Kubernetes object")

_, err = bootstrapClusterProxy.GetClientSet().
CoreV1().
ConfigMaps(configMap.GetNamespace()).
Update(context.Background(), configMap, metav1.UpdateOptions{})
Expect(
err,
).To(BeNil(), "Failed to update the coredns deployment with the dns-override.yaml file")

timeNow := time.Now().Format(time.RFC3339)
patch := fmt.Sprintf(
`{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubernetes.io/restartedAt":%q}}}}}`,
timeNow,
)

_, err = bootstrapClusterProxy.GetClientSet().
AppsV1().
Deployments("kube-system").
Patch(context.Background(), "coredns", types.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{})
Expect(err).To(BeNil(), "Failed to restart the coredns deployment")

By("Initializing the bootstrap cluster")
initBootstrapCluster(bootstrapClusterProxy, e2eConfig, clusterctlConfigPath, artifactFolder)

Expand Down
Loading