Skip to content

Commit

Permalink
Merge pull request #7743 from vmarmol/runtime-switch
Browse files Browse the repository at this point in the history
Kubelet: Add rkt as a runtime option
  • Loading branch information
yujuhong committed May 5, 2015
2 parents 1625e23 + 22297d3 commit b2c0ea3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/kubelet/app/server.go
Expand Up @@ -210,7 +210,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
fs.StringVar(&s.ResourceContainer, "resource-container", s.ResourceContainer, "Absolute name of the resource-only container to create and run the Kubelet in (Default: /kubelet).")
fs.StringVar(&s.CgroupRoot, "cgroup_root", s.CgroupRoot, "Optional root cgroup to use for pods. This is handled by the container runtime on a best effort basis. Default: '', which means use the container runtime default.")
fs.StringVar(&s.ContainerRuntime, "container_runtime", s.ContainerRuntime, "The container runtime to use. Possible values: 'docker'. Default: 'docker'.")
fs.StringVar(&s.ContainerRuntime, "container_runtime", s.ContainerRuntime, "The container runtime to use. Possible values: 'docker', 'rkt'. Default: 'docker'.")

// Flags intended for testing, not recommended used in production environments.
fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
Expand Down
10 changes: 10 additions & 0 deletions pkg/kubelet/kubelet.go
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/metrics"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/prober"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/rkt"
kubeletTypes "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
Expand Down Expand Up @@ -261,6 +262,15 @@ func NewMainKubelet(
klet,
klet.httpClient,
newKubeletRuntimeHooks(recorder))
case "rkt":
conf := &rkt.Config{
InsecureSkipVerify: true,
}
rktRuntime, err := rkt.New(conf, klet, recorder, containerRefManager, readinessManager)
if err != nil {
return nil, err
}
klet.containerRuntime = rktRuntime
default:
return nil, fmt.Errorf("unsupported container runtime %q specified", containerRuntime)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/kubelet/rkt/gc.go
Expand Up @@ -18,11 +18,10 @@ package rkt

// ImageManager manages and garbage collects the container images for rkt.
type ImageManager struct {
runtime *runtime
}

func NewImageManager(r *runtime) *ImageManager {
return &ImageManager{runtime: r}
func NewImageManager() *ImageManager {
return &ImageManager{}
}

// GarbageCollect collects the images. It is not implemented by rkt yet.
Expand Down
20 changes: 14 additions & 6 deletions pkg/kubelet/rkt/rkt_linux.go
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/prober"
Expand Down Expand Up @@ -105,7 +106,11 @@ var _ kubecontainer.Runtime = &runtime{}
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config) (kubecontainer.Runtime, error) {
func New(config *Config,
generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
readinessManager *kubecontainer.ReadinessManager) (kubecontainer.Runtime, error) {
systemdVersion, err := getSystemdVersion()
if err != nil {
return nil, err
Expand All @@ -130,11 +135,14 @@ func New(config *Config) (kubecontainer.Runtime, error) {
}

rkt := &runtime{
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
}
generator: generator,
readinessManager: readinessManager,
systemd: systemd,
rktBinAbsPath: rktBinAbsPath,
config: config,
dockerKeyring: credentialprovider.NewDockerKeyring(),
}
rkt.prober = prober.New(rkt, readinessManager, containerRefManager, recorder)

// Test the rkt version.
version, err := rkt.Version()
Expand Down
9 changes: 9 additions & 0 deletions pkg/kubelet/rkt/rkt_unsupported.go
Expand Up @@ -23,6 +23,7 @@ import (
"io"

"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
)

Expand All @@ -32,6 +33,14 @@ type unsupportedRuntime struct {

var _ kubecontainer.Runtime = &unsupportedRuntime{}

func New(config *Config,
generator kubecontainer.RunContainerOptionsGenerator,
recorder record.EventRecorder,
containerRefManager *kubecontainer.RefManager,
readinessManager *kubecontainer.ReadinessManager) (kubecontainer.Runtime, error) {
return nil, unsupportedError
}

var unsupportedError = fmt.Errorf("rkt runtime is unsupported in this platform")

func (ur *unsupportedRuntime) Version() (kubecontainer.Version, error) {
Expand Down

0 comments on commit b2c0ea3

Please sign in to comment.