e2e_node: support passing kubelet-config-file to local runs

This commit is contained in:
Danielle Lancashire 2021-10-08 13:45:37 +02:00
parent 6e9e436026
commit a4cf3a90a2
3 changed files with 11 additions and 6 deletions

View File

@ -213,6 +213,7 @@ else
--ginkgo-flags="${ginkgoflags}" --test-flags="--container-runtime=${runtime} \ --ginkgo-flags="${ginkgoflags}" --test-flags="--container-runtime=${runtime} \
--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \ --alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
${test_args}" --runtime-config="${runtime_config}" \ ${test_args}" --runtime-config="${runtime_config}" \
--kubelet-config-file="${kubelet_config_file}" \
--build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
exit $? exit $?
fi fi

View File

@ -37,6 +37,7 @@ var testFlags = flag.String("test-flags", "", "Space-separated list of arguments
var systemSpecName = flag.String("system-spec-name", "", fmt.Sprintf("The name of the system spec used for validating the image in the node conformance test. The specs are at %s. If unspecified, the default built-in spec (system.DefaultSpec) will be used.", system.SystemSpecPath)) var systemSpecName = flag.String("system-spec-name", "", fmt.Sprintf("The name of the system spec used for validating the image in the node conformance test. The specs are at %s. If unspecified, the default built-in spec (system.DefaultSpec) will be used.", system.SystemSpecPath))
var extraEnvs = flag.String("extra-envs", "", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2") var extraEnvs = flag.String("extra-envs", "", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
var runtimeConfig = flag.String("runtime-config", "", "The runtime configuration for the API server on the node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2") var runtimeConfig = flag.String("runtime-config", "", "The runtime configuration for the API server on the node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
var kubeletConfigFile = flag.String("kubelet-config-file", "", "The KubeletConfiguration file that should be applied to the kubelet")
func main() { func main() {
klog.InitFlags(nil) klog.InitFlags(nil)
@ -67,6 +68,9 @@ func main() {
systemSpecFile := filepath.Join(rootDir, system.SystemSpecPath, *systemSpecName+".yaml") systemSpecFile := filepath.Join(rootDir, system.SystemSpecPath, *systemSpecName+".yaml")
args = append(args, fmt.Sprintf("--system-spec-name=%s --system-spec-file=%s --extra-envs=%s", *systemSpecName, systemSpecFile, *extraEnvs)) args = append(args, fmt.Sprintf("--system-spec-name=%s --system-spec-file=%s --extra-envs=%s", *systemSpecName, systemSpecFile, *extraEnvs))
} }
if *kubeletConfigFile != "" {
args = append(args, fmt.Sprintf("--kubelet-config-file=\"%s\"", *kubeletConfigFile))
}
if err := runCommand(ginkgo, args...); err != nil { if err := runCommand(ginkgo, args...); err != nil {
klog.Exitf("Test failed: %v", err) klog.Exitf("Test failed: %v", err)
} }

View File

@ -62,9 +62,11 @@ func (a *args) Set(value string) error {
// kubeletArgs is the override kubelet args specified by the test runner. // kubeletArgs is the override kubelet args specified by the test runner.
var kubeletArgs args var kubeletArgs args
var kubeletConfigFile string
func init() { func init() {
flag.Var(&kubeletArgs, "kubelet-flags", "Kubelet flags passed to kubelet, this will override default kubelet flags in the test. Flags specified in multiple kubelet-flags will be concatenate.") flag.Var(&kubeletArgs, "kubelet-flags", "Kubelet flags passed to kubelet, this will override default kubelet flags in the test. Flags specified in multiple kubelet-flags will be concatenate. Deprecated, see: --kubelet-config-file.")
flag.StringVar(&kubeletConfigFile, "kubelet-config-file", "./kubeletconfig.yaml", "The base KubeletConfiguration to use when setting up the kubelet. This configuration will then be minimially modified to support requirements from the test suite.")
} }
// RunKubelet starts kubelet and waits for termination signal. Once receives the // RunKubelet starts kubelet and waits for termination signal. Once receives the
@ -92,10 +94,8 @@ const (
kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz" kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz"
) )
// TODO(endocrimes): Refactor to take a path to the kubeletconfig func baseKubeConfiguration(cfgPath string) (*kubeletconfig.KubeletConfiguration, error) {
func baseKubeConfiguration() (*kubeletconfig.KubeletConfiguration, error) { cfgPath, err := filepath.Abs(cfgPath)
cwd, _ := os.Getwd()
cfgPath, err := filepath.Abs(filepath.Join(cwd, "kubeletconfig.yaml"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -154,7 +154,7 @@ func (e *E2EServices) startKubelet() (*server, error) {
return nil, err return nil, err
} }
kc, err := baseKubeConfiguration() kc, err := baseKubeConfiguration(kubeletConfigFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to load base kubelet configuration: %v", err) return nil, fmt.Errorf("failed to load base kubelet configuration: %v", err)
} }