mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 23:03:40 +00:00
Allow configuring the rkt binary in a kubelet with a flag.
This is necessary because coreos comes with rkt installed, and if we want to use a different version we need some way to avoid the default one.
This commit is contained in:
parent
a68e819e60
commit
80e799fc0c
@ -151,7 +151,8 @@ coreos:
|
||||
--cluster-dns=10.0.0.10 \
|
||||
--cluster-domain=cluster.local \
|
||||
--logtostderr=true \
|
||||
--container-runtime=${KUBERNETES_CONTAINER_RUNTIME}
|
||||
--container-runtime=${KUBERNETES_CONTAINER_RUNTIME} \
|
||||
--rkt-path=/opt/rkt/rkt/rkt
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
|
@ -116,6 +116,7 @@ type KubeletServer struct {
|
||||
ResourceContainer string
|
||||
CgroupRoot string
|
||||
ContainerRuntime string
|
||||
RktPath string
|
||||
DockerDaemonContainer string
|
||||
SystemContainer string
|
||||
ConfigureCBR0 bool
|
||||
@ -182,6 +183,7 @@ func NewKubeletServer() *KubeletServer {
|
||||
ResourceContainer: "/kubelet",
|
||||
CgroupRoot: "",
|
||||
ContainerRuntime: "docker",
|
||||
RktPath: "",
|
||||
DockerDaemonContainer: "/docker-daemon",
|
||||
SystemContainer: "",
|
||||
ConfigureCBR0: false,
|
||||
@ -245,6 +247,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
||||
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', 'rkt'. Default: 'docker'.")
|
||||
fs.StringVar(&s.RktPath, "rkt-path", s.RktPath, "Path of rkt binary. Leave empty to use the first rkt in $PATH. Only used if --container-runtime='rkt'")
|
||||
fs.StringVar(&s.SystemContainer, "system-container", s.SystemContainer, "Optional resource-only container in which to place all non-kernel processes that are not already in a container. Empty for no container. Rolling back the flag requires a reboot. (Default: \"\").")
|
||||
fs.BoolVar(&s.ConfigureCBR0, "configure-cbr0", s.ConfigureCBR0, "If true, kubelet will configure cbr0 based on Node.Spec.PodCIDR.")
|
||||
fs.IntVar(&s.MaxPods, "max-pods", 40, "Number of Pods that can run on this Kubelet.")
|
||||
@ -348,6 +351,7 @@ func (s *KubeletServer) KubeletConfig() (*KubeletConfig, error) {
|
||||
ResourceContainer: s.ResourceContainer,
|
||||
CgroupRoot: s.CgroupRoot,
|
||||
ContainerRuntime: s.ContainerRuntime,
|
||||
RktPath: s.RktPath,
|
||||
Mounter: mounter,
|
||||
DockerDaemonContainer: s.DockerDaemonContainer,
|
||||
SystemContainer: s.SystemContainer,
|
||||
@ -753,6 +757,7 @@ type KubeletConfig struct {
|
||||
OSInterface kubecontainer.OSInterface
|
||||
CgroupRoot string
|
||||
ContainerRuntime string
|
||||
RktPath string
|
||||
Mounter mount.Interface
|
||||
DockerDaemonContainer string
|
||||
SystemContainer string
|
||||
@ -811,6 +816,7 @@ func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
|
||||
kc.OSInterface,
|
||||
kc.CgroupRoot,
|
||||
kc.ContainerRuntime,
|
||||
kc.RktPath,
|
||||
kc.Mounter,
|
||||
kc.DockerDaemonContainer,
|
||||
kc.SystemContainer,
|
||||
|
@ -346,6 +346,7 @@ func (ks *KubeletExecutorServer) createAndInitKubelet(
|
||||
kc.OSInterface,
|
||||
kc.CgroupRoot,
|
||||
kc.ContainerRuntime,
|
||||
kc.RktPath,
|
||||
kc.Mounter,
|
||||
kc.DockerDaemonContainer,
|
||||
kc.SystemContainer,
|
||||
|
@ -198,6 +198,7 @@ required-contexts
|
||||
resource-container
|
||||
resource-quota-sync-period
|
||||
resource-version
|
||||
rkt-path
|
||||
root-ca-file
|
||||
root-dir
|
||||
run-proxy
|
||||
|
@ -144,6 +144,7 @@ func NewMainKubelet(
|
||||
osInterface kubecontainer.OSInterface,
|
||||
cgroupRoot string,
|
||||
containerRuntime string,
|
||||
rktPath string,
|
||||
mounter mount.Interface,
|
||||
dockerDaemonContainer string,
|
||||
systemContainer string,
|
||||
@ -304,7 +305,10 @@ func NewMainKubelet(
|
||||
oomAdjuster,
|
||||
procFs)
|
||||
case "rkt":
|
||||
conf := &rkt.Config{InsecureSkipVerify: true}
|
||||
conf := &rkt.Config{
|
||||
Path: rktPath,
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
rktRuntime, err := rkt.New(
|
||||
conf,
|
||||
klet,
|
||||
|
@ -21,6 +21,8 @@ import "fmt"
|
||||
// Config stores the global configuration for the rkt runtime.
|
||||
// Run 'rkt' for more details.
|
||||
type Config struct {
|
||||
// The absolute path to the binary, or leave empty to find it in $PATH.
|
||||
Path string
|
||||
// The debug flag for rkt.
|
||||
Debug bool
|
||||
// The rkt data directory.
|
||||
|
@ -128,11 +128,14 @@ func New(config *Config,
|
||||
return nil, fmt.Errorf("cannot connect to dbus: %v", err)
|
||||
}
|
||||
|
||||
// Test if rkt binary is in $PATH.
|
||||
// TODO(yifan): Use a kubelet flag to read the path.
|
||||
rktBinAbsPath, err := exec.LookPath("rkt")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
|
||||
rktBinAbsPath := config.Path
|
||||
if rktBinAbsPath == "" {
|
||||
// No default rkt path was set, so try to find one in $PATH.
|
||||
var err error
|
||||
rktBinAbsPath, err = exec.LookPath("rkt")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
rkt := &runtime{
|
||||
|
Loading…
Reference in New Issue
Block a user