mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 15:20:17 +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-dns=10.0.0.10 \
|
||||||
--cluster-domain=cluster.local \
|
--cluster-domain=cluster.local \
|
||||||
--logtostderr=true \
|
--logtostderr=true \
|
||||||
--container-runtime=${KUBERNETES_CONTAINER_RUNTIME}
|
--container-runtime=${KUBERNETES_CONTAINER_RUNTIME} \
|
||||||
|
--rkt-path=/opt/rkt/rkt/rkt
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ type KubeletServer struct {
|
|||||||
ResourceContainer string
|
ResourceContainer string
|
||||||
CgroupRoot string
|
CgroupRoot string
|
||||||
ContainerRuntime string
|
ContainerRuntime string
|
||||||
|
RktPath string
|
||||||
DockerDaemonContainer string
|
DockerDaemonContainer string
|
||||||
SystemContainer string
|
SystemContainer string
|
||||||
ConfigureCBR0 bool
|
ConfigureCBR0 bool
|
||||||
@ -182,6 +183,7 @@ func NewKubeletServer() *KubeletServer {
|
|||||||
ResourceContainer: "/kubelet",
|
ResourceContainer: "/kubelet",
|
||||||
CgroupRoot: "",
|
CgroupRoot: "",
|
||||||
ContainerRuntime: "docker",
|
ContainerRuntime: "docker",
|
||||||
|
RktPath: "",
|
||||||
DockerDaemonContainer: "/docker-daemon",
|
DockerDaemonContainer: "/docker-daemon",
|
||||||
SystemContainer: "",
|
SystemContainer: "",
|
||||||
ConfigureCBR0: false,
|
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.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.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.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.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.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.")
|
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,
|
ResourceContainer: s.ResourceContainer,
|
||||||
CgroupRoot: s.CgroupRoot,
|
CgroupRoot: s.CgroupRoot,
|
||||||
ContainerRuntime: s.ContainerRuntime,
|
ContainerRuntime: s.ContainerRuntime,
|
||||||
|
RktPath: s.RktPath,
|
||||||
Mounter: mounter,
|
Mounter: mounter,
|
||||||
DockerDaemonContainer: s.DockerDaemonContainer,
|
DockerDaemonContainer: s.DockerDaemonContainer,
|
||||||
SystemContainer: s.SystemContainer,
|
SystemContainer: s.SystemContainer,
|
||||||
@ -753,6 +757,7 @@ type KubeletConfig struct {
|
|||||||
OSInterface kubecontainer.OSInterface
|
OSInterface kubecontainer.OSInterface
|
||||||
CgroupRoot string
|
CgroupRoot string
|
||||||
ContainerRuntime string
|
ContainerRuntime string
|
||||||
|
RktPath string
|
||||||
Mounter mount.Interface
|
Mounter mount.Interface
|
||||||
DockerDaemonContainer string
|
DockerDaemonContainer string
|
||||||
SystemContainer string
|
SystemContainer string
|
||||||
@ -811,6 +816,7 @@ func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
|
|||||||
kc.OSInterface,
|
kc.OSInterface,
|
||||||
kc.CgroupRoot,
|
kc.CgroupRoot,
|
||||||
kc.ContainerRuntime,
|
kc.ContainerRuntime,
|
||||||
|
kc.RktPath,
|
||||||
kc.Mounter,
|
kc.Mounter,
|
||||||
kc.DockerDaemonContainer,
|
kc.DockerDaemonContainer,
|
||||||
kc.SystemContainer,
|
kc.SystemContainer,
|
||||||
|
@ -346,6 +346,7 @@ func (ks *KubeletExecutorServer) createAndInitKubelet(
|
|||||||
kc.OSInterface,
|
kc.OSInterface,
|
||||||
kc.CgroupRoot,
|
kc.CgroupRoot,
|
||||||
kc.ContainerRuntime,
|
kc.ContainerRuntime,
|
||||||
|
kc.RktPath,
|
||||||
kc.Mounter,
|
kc.Mounter,
|
||||||
kc.DockerDaemonContainer,
|
kc.DockerDaemonContainer,
|
||||||
kc.SystemContainer,
|
kc.SystemContainer,
|
||||||
|
@ -198,6 +198,7 @@ required-contexts
|
|||||||
resource-container
|
resource-container
|
||||||
resource-quota-sync-period
|
resource-quota-sync-period
|
||||||
resource-version
|
resource-version
|
||||||
|
rkt-path
|
||||||
root-ca-file
|
root-ca-file
|
||||||
root-dir
|
root-dir
|
||||||
run-proxy
|
run-proxy
|
||||||
|
@ -144,6 +144,7 @@ func NewMainKubelet(
|
|||||||
osInterface kubecontainer.OSInterface,
|
osInterface kubecontainer.OSInterface,
|
||||||
cgroupRoot string,
|
cgroupRoot string,
|
||||||
containerRuntime string,
|
containerRuntime string,
|
||||||
|
rktPath string,
|
||||||
mounter mount.Interface,
|
mounter mount.Interface,
|
||||||
dockerDaemonContainer string,
|
dockerDaemonContainer string,
|
||||||
systemContainer string,
|
systemContainer string,
|
||||||
@ -304,7 +305,10 @@ func NewMainKubelet(
|
|||||||
oomAdjuster,
|
oomAdjuster,
|
||||||
procFs)
|
procFs)
|
||||||
case "rkt":
|
case "rkt":
|
||||||
conf := &rkt.Config{InsecureSkipVerify: true}
|
conf := &rkt.Config{
|
||||||
|
Path: rktPath,
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}
|
||||||
rktRuntime, err := rkt.New(
|
rktRuntime, err := rkt.New(
|
||||||
conf,
|
conf,
|
||||||
klet,
|
klet,
|
||||||
|
@ -21,6 +21,8 @@ import "fmt"
|
|||||||
// Config stores the global configuration for the rkt runtime.
|
// Config stores the global configuration for the rkt runtime.
|
||||||
// Run 'rkt' for more details.
|
// Run 'rkt' for more details.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// The absolute path to the binary, or leave empty to find it in $PATH.
|
||||||
|
Path string
|
||||||
// The debug flag for rkt.
|
// The debug flag for rkt.
|
||||||
Debug bool
|
Debug bool
|
||||||
// The rkt data directory.
|
// The rkt data directory.
|
||||||
|
@ -128,11 +128,14 @@ func New(config *Config,
|
|||||||
return nil, fmt.Errorf("cannot connect to dbus: %v", err)
|
return nil, fmt.Errorf("cannot connect to dbus: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if rkt binary is in $PATH.
|
rktBinAbsPath := config.Path
|
||||||
// TODO(yifan): Use a kubelet flag to read the path.
|
if rktBinAbsPath == "" {
|
||||||
rktBinAbsPath, err := exec.LookPath("rkt")
|
// No default rkt path was set, so try to find one in $PATH.
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
|
rktBinAbsPath, err = exec.LookPath("rkt")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot find rkt binary: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rkt := &runtime{
|
rkt := &runtime{
|
||||||
|
Loading…
Reference in New Issue
Block a user