mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #7772 from pmorie/containerized
Add containerized option to kubelet binary
This commit is contained in:
commit
ba438a808b
@ -109,6 +109,8 @@ type KubeletServer struct {
|
|||||||
ReallyCrashForTesting bool
|
ReallyCrashForTesting bool
|
||||||
// Insert a probability of random errors during calls to the master.
|
// Insert a probability of random errors during calls to the master.
|
||||||
ChaosChance float64
|
ChaosChance float64
|
||||||
|
// Is the kubelet containerized?
|
||||||
|
Containerized bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// bootstrapping interface for kubelet, targets the initialization protocol
|
// bootstrapping interface for kubelet, targets the initialization protocol
|
||||||
@ -213,6 +215,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
|||||||
// Flags intended for testing, not recommended used in production environments.
|
// 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.")
|
fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
|
||||||
fs.Float64Var(&s.ChaosChance, "chaos-chance", s.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing. [default=0.0]")
|
fs.Float64Var(&s.ChaosChance, "chaos-chance", s.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing. [default=0.0]")
|
||||||
|
fs.BoolVar(&s.Containerized, "containerized", s.Containerized, "Experimental support for running kubelet in a container. Intended for testing. [default=false]")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the specified KubeletServer. This should never exit.
|
// Run runs the specified KubeletServer. This should never exit.
|
||||||
@ -271,6 +274,12 @@ func (s *KubeletServer) Run(_ []string) error {
|
|||||||
KeyFile: s.TLSPrivateKeyFile,
|
KeyFile: s.TLSPrivateKeyFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mounter := mount.New()
|
||||||
|
if s.Containerized {
|
||||||
|
glog.Info("Running kubelet in containerized mode (experimental)")
|
||||||
|
mounter = &mount.NsenterMounter{}
|
||||||
|
}
|
||||||
|
|
||||||
kcfg := KubeletConfig{
|
kcfg := KubeletConfig{
|
||||||
Address: s.Address,
|
Address: s.Address,
|
||||||
AllowPrivileged: s.AllowPrivileged,
|
AllowPrivileged: s.AllowPrivileged,
|
||||||
@ -310,7 +319,7 @@ func (s *KubeletServer) Run(_ []string) error {
|
|||||||
ResourceContainer: s.ResourceContainer,
|
ResourceContainer: s.ResourceContainer,
|
||||||
CgroupRoot: s.CgroupRoot,
|
CgroupRoot: s.CgroupRoot,
|
||||||
ContainerRuntime: s.ContainerRuntime,
|
ContainerRuntime: s.ContainerRuntime,
|
||||||
Mounter: mount.New(),
|
Mounter: mounter,
|
||||||
}
|
}
|
||||||
|
|
||||||
RunKubelet(&kcfg, nil)
|
RunKubelet(&kcfg, nil)
|
||||||
|
39
pkg/util/mount/nsenter_mount_unsupported.go
Normal file
39
pkg/util/mount/nsenter_mount_unsupported.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// +build !linux
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2014 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package mount
|
||||||
|
|
||||||
|
type NsenterMounter struct{}
|
||||||
|
|
||||||
|
var _ = Interface(&NsenterMounter{})
|
||||||
|
|
||||||
|
func (*NsenterMounter) Mount(source string, target string, fstype string, options []string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*NsenterMounter) Unmount(target string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*NsenterMounter) List() ([]MountPoint, error) {
|
||||||
|
return []MountPoint{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*NsenterMounter) IsMountPoint(file string) (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user