first iteration to add standalone mode

This commit is contained in:
Sergey Kanzhelev
2023-03-13 20:54:50 +00:00
parent 1cb334960c
commit 1e6281e4a2
6 changed files with 236 additions and 17 deletions

View File

@@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
"k8s.io/kubernetes/pkg/cluster/ports"
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
kubeletconfigscheme "k8s.io/kubernetes/pkg/kubelet/apis/config/scheme"
@@ -37,8 +38,8 @@ import (
)
// GetCurrentKubeletConfig fetches the current Kubelet Config for the given node
func GetCurrentKubeletConfig(ctx context.Context, nodeName, namespace string, useProxy bool) (*kubeletconfig.KubeletConfiguration, error) {
resp := pollConfigz(ctx, 5*time.Minute, 5*time.Second, nodeName, namespace, useProxy)
func GetCurrentKubeletConfig(ctx context.Context, nodeName, namespace string, useProxy bool, standaloneMode bool) (*kubeletconfig.KubeletConfiguration, error) {
resp := pollConfigz(ctx, 5*time.Minute, 5*time.Second, nodeName, namespace, useProxy, standaloneMode)
if len(resp) == 0 {
return nil, fmt.Errorf("failed to fetch /configz from %q", nodeName)
}
@@ -50,7 +51,7 @@ func GetCurrentKubeletConfig(ctx context.Context, nodeName, namespace string, us
}
// returns a status 200 response from the /configz endpoint or nil if fails
func pollConfigz(ctx context.Context, timeout time.Duration, pollInterval time.Duration, nodeName, namespace string, useProxy bool) []byte {
func pollConfigz(ctx context.Context, timeout time.Duration, pollInterval time.Duration, nodeName, namespace string, useProxy bool, standaloneMode bool) []byte {
endpoint := ""
if useProxy {
// start local proxy, so we can send graceful deletion over query string, rather than body parameter
@@ -75,8 +76,10 @@ func pollConfigz(ctx context.Context, timeout time.Duration, pollInterval time.D
framework.ExpectNoError(err)
framework.Logf("http requesting node kubelet /configz")
endpoint = fmt.Sprintf("http://127.0.0.1:%d/api/v1/nodes/%s/proxy/configz", port, nodeName)
} else {
} else if !standaloneMode {
endpoint = fmt.Sprintf("%s/api/v1/nodes/%s/proxy/configz", framework.TestContext.Host, framework.TestContext.NodeName)
} else {
endpoint = fmt.Sprintf("https://127.0.0.1:%d/configz", ports.KubeletPort)
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},

View File

@@ -258,6 +258,8 @@ type NodeTestContextType struct {
RestartKubelet bool
// ExtraEnvs is a map of environment names to values.
ExtraEnvs map[string]string
// StandaloneMode indicates whether the test is running kubelet in a standalone mode.
StandaloneMode bool
}
// CloudConfig holds the cloud configuration for e2e test suites.