mirror of https://github.com/k3s-io/k3s
Add getCRIClient and set default values for CRI related flags
parent
ea2fbd4de4
commit
f64c508e2e
|
@ -60,6 +60,16 @@ if [ ! -d "${artifacts}" ]; then
|
||||||
fi
|
fi
|
||||||
echo "Test artifacts will be written to ${artifacts}"
|
echo "Test artifacts will be written to ${artifacts}"
|
||||||
|
|
||||||
|
if [[ $runtime == "remote" ]] ; then
|
||||||
|
if [[ ! -z $container_runtime_endpoint ]] ; then
|
||||||
|
test_args="--container-runtime-endpoint=${container_runtime_endpoint} $test_args"
|
||||||
|
fi
|
||||||
|
if [[ ! -z $image_service_endpoint ]] ; then
|
||||||
|
test_args="--image-service-endpoint=$image_service_endpoint $test_args"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ $remote = true ] ; then
|
if [ $remote = true ] ; then
|
||||||
# The following options are only valid in remote run.
|
# The following options are only valid in remote run.
|
||||||
images=${IMAGES:-""}
|
images=${IMAGES:-""}
|
||||||
|
@ -153,22 +163,12 @@ else
|
||||||
|
|
||||||
# Runtime flags
|
# Runtime flags
|
||||||
test_args='--kubelet-flags="--container-runtime='$runtime'" '$test_args
|
test_args='--kubelet-flags="--container-runtime='$runtime'" '$test_args
|
||||||
if [[ $runtime == "remote" ]] ; then
|
|
||||||
if [[ ! -z $container_runtime_endpoint ]] ; then
|
|
||||||
test_args='--kubelet-flags="--container-runtime-endpoint='$container_runtime_endpoint'" '$test_args
|
|
||||||
fi
|
|
||||||
if [[ ! -z $image_service_endpoint ]] ; then
|
|
||||||
test_args='--kubelet-flags="--image-service-endpoint='$image_service_endpoint'" '$test_args
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Test using the host the script was run on
|
# Test using the host the script was run on
|
||||||
# Provided for backwards compatibility
|
# Provided for backwards compatibility
|
||||||
go run test/e2e_node/runner/local/run_local.go \
|
go run test/e2e_node/runner/local/run_local.go \
|
||||||
--system-spec-name="$system_spec_name" --ginkgo-flags="$ginkgoflags" \
|
--system-spec-name="$system_spec_name" --ginkgo-flags="$ginkgoflags" \
|
||||||
--test-flags="--container-runtime=${runtime} \
|
--test-flags="--container-runtime=${runtime} \
|
||||||
--container-runtime-endpoint=${container_runtime_endpoint} \
|
|
||||||
--image-service-endpoint=${image_service_endpoint} \
|
|
||||||
--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
|
--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
|
||||||
$test_args" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
|
$test_args" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
|
||||||
exit $?
|
exit $?
|
||||||
|
|
|
@ -57,14 +57,16 @@ type TestContextType struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
MinStartupPods int
|
MinStartupPods int
|
||||||
// Timeout for waiting for system pods to be running
|
// Timeout for waiting for system pods to be running
|
||||||
SystemPodsStartupTimeout time.Duration
|
SystemPodsStartupTimeout time.Duration
|
||||||
UpgradeTarget string
|
UpgradeTarget string
|
||||||
EtcdUpgradeStorage string
|
EtcdUpgradeStorage string
|
||||||
EtcdUpgradeVersion string
|
EtcdUpgradeVersion string
|
||||||
UpgradeImage string
|
UpgradeImage string
|
||||||
GCEUpgradeScript string
|
GCEUpgradeScript string
|
||||||
ContainerRuntime string
|
ContainerRuntime string
|
||||||
ContainerRuntimeEndpoint string
|
ContainerRuntimeEndpoint string
|
||||||
|
ContainerRuntimeProcessName string
|
||||||
|
ContainerRuntimePidFile string
|
||||||
// SystemdServices are comma separated list of systemd services the test framework
|
// SystemdServices are comma separated list of systemd services the test framework
|
||||||
// will dump logs for.
|
// will dump logs for.
|
||||||
SystemdServices string
|
SystemdServices string
|
||||||
|
@ -203,7 +205,9 @@ func RegisterCommonFlags() {
|
||||||
flag.StringVar(&TestContext.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
|
flag.StringVar(&TestContext.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
|
||||||
flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.")
|
flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.")
|
||||||
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
|
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
|
||||||
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "", "The container runtime endpoint of cluster VM instances.")
|
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "unix:///var/run/dockershim.sock", "The container runtime endpoint of cluster VM instances.")
|
||||||
|
flag.StringVar(&TestContext.ContainerRuntimeProcessName, "container-runtime-process-name", "dockerd", "The name of the container runtime process.")
|
||||||
|
flag.StringVar(&TestContext.ContainerRuntimePidFile, "container-runtime-pid-file", "/var/run/docker.pid", "The pid file of the container runtime.")
|
||||||
flag.StringVar(&TestContext.SystemdServices, "systemd-services", "docker", "The comma separated list of systemd services the framework will dump logs for.")
|
flag.StringVar(&TestContext.SystemdServices, "systemd-services", "docker", "The comma separated list of systemd services the framework will dump logs for.")
|
||||||
flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.")
|
flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.")
|
||||||
flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.")
|
flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.")
|
||||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||||
package e2e_node
|
package e2e_node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
@ -28,7 +27,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
|
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
|
||||||
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/remote"
|
|
||||||
commontest "k8s.io/kubernetes/test/e2e/common"
|
commontest "k8s.io/kubernetes/test/e2e/common"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
@ -39,8 +37,6 @@ const (
|
||||||
maxImagePullRetries = 5
|
maxImagePullRetries = 5
|
||||||
// Sleep duration between image pull retry attempts.
|
// Sleep duration between image pull retry attempts.
|
||||||
imagePullRetryDelay = time.Second
|
imagePullRetryDelay = time.Second
|
||||||
// connection timeout for gRPC image service connection
|
|
||||||
imageServiceConnectionTimeout = 15 * time.Minute
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeImageWhiteList is a list of images used in node e2e test. These images will be prepulled
|
// NodeImageWhiteList is a list of images used in node e2e test. These images will be prepulled
|
||||||
|
@ -107,17 +103,7 @@ func getPuller() (puller, error) {
|
||||||
case "docker":
|
case "docker":
|
||||||
return &dockerPuller{}, nil
|
return &dockerPuller{}, nil
|
||||||
case "remote":
|
case "remote":
|
||||||
endpoint := framework.TestContext.ContainerRuntimeEndpoint
|
_, is, err := getCRIClient()
|
||||||
if framework.TestContext.ImageServiceEndpoint != "" {
|
|
||||||
//ImageServiceEndpoint is the same as ContainerRuntimeEndpoint if not
|
|
||||||
//explicitly specified
|
|
||||||
//https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet.go#L517
|
|
||||||
endpoint = framework.TestContext.ImageServiceEndpoint
|
|
||||||
}
|
|
||||||
if endpoint == "" {
|
|
||||||
return nil, errors.New("can't prepull images, no remote endpoint provided")
|
|
||||||
}
|
|
||||||
is, err := remote.NewRemoteImageService(endpoint, imageServiceConnectionTimeout)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,6 +303,18 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
||||||
cmdArgs = append(cmdArgs, "--hostname-override", framework.TestContext.NodeName)
|
cmdArgs = append(cmdArgs, "--hostname-override", framework.TestContext.NodeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if framework.TestContext.ContainerRuntime != "" {
|
||||||
|
cmdArgs = append(cmdArgs, "--container-runtime", framework.TestContext.ContainerRuntime)
|
||||||
|
}
|
||||||
|
|
||||||
|
if framework.TestContext.ContainerRuntimeEndpoint != "" {
|
||||||
|
cmdArgs = append(cmdArgs, "--container-runtime-endpoint", framework.TestContext.ContainerRuntimeEndpoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
if framework.TestContext.ImageServiceEndpoint != "" {
|
||||||
|
cmdArgs = append(cmdArgs, "--image-service-endpoint", framework.TestContext.ImageServiceEndpoint)
|
||||||
|
}
|
||||||
|
|
||||||
// Write config file or flags, depending on whether --generate-kubelet-config-file was provided
|
// Write config file or flags, depending on whether --generate-kubelet-config-file was provided
|
||||||
if genKubeletConfigFile {
|
if genKubeletConfigFile {
|
||||||
if err := writeKubeletConfigFile(kc, kubeletConfigPath); err != nil {
|
if err := writeKubeletConfigFile(kc, kubeletConfigPath); err != nil {
|
||||||
|
|
|
@ -35,11 +35,13 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
|
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||||
kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
|
kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
|
||||||
kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
||||||
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
||||||
kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics"
|
kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics"
|
||||||
|
"k8s.io/kubernetes/pkg/kubelet/remote"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
"k8s.io/kubernetes/test/e2e/framework/metrics"
|
"k8s.io/kubernetes/test/e2e/framework/metrics"
|
||||||
|
|
||||||
|
@ -365,3 +367,25 @@ func runCommand(cmd ...string) (string, error) {
|
||||||
}
|
}
|
||||||
return string(output), nil
|
return string(output), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getCRIClient connects CRI and returns CRI runtime service clients and image service client.
|
||||||
|
func getCRIClient() (internalapi.RuntimeService, internalapi.ImageManagerService, error) {
|
||||||
|
// connection timeout for CRI service connection
|
||||||
|
const connectionTimeout = 2 * time.Minute
|
||||||
|
runtimeEndpoint := framework.TestContext.ContainerRuntimeEndpoint
|
||||||
|
r, err := remote.NewRemoteRuntimeService(runtimeEndpoint, connectionTimeout)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
imageManagerEndpoint := runtimeEndpoint
|
||||||
|
if framework.TestContext.ImageServiceEndpoint != "" {
|
||||||
|
//ImageServiceEndpoint is the same as ContainerRuntimeEndpoint if not
|
||||||
|
//explicitly specified
|
||||||
|
imageManagerEndpoint = framework.TestContext.ImageServiceEndpoint
|
||||||
|
}
|
||||||
|
i, err := remote.NewRemoteImageService(imageManagerEndpoint, connectionTimeout)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return r, i, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue