mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Support pods with containers using host ipc
Add a HostIPC field to the Pod Spec to create containers sharing the same ipc of the host. This feature must be explicitly enabled in apiserver using the option host-ipc-sources. Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
@@ -95,6 +95,7 @@ type KubeletServer struct {
|
||||
HostnameOverride string
|
||||
HostNetworkSources string
|
||||
HostPIDSources string
|
||||
HostIPCSources string
|
||||
HTTPCheckFrequency time.Duration
|
||||
ImageGCHighThresholdPercent int
|
||||
ImageGCLowThresholdPercent int
|
||||
@@ -173,6 +174,7 @@ func NewKubeletServer() *KubeletServer {
|
||||
HealthzPort: 10248,
|
||||
HostNetworkSources: kubelet.FileSource,
|
||||
HostPIDSources: kubelet.FileSource,
|
||||
HostIPCSources: kubelet.FileSource,
|
||||
HTTPCheckFrequency: 20 * time.Second,
|
||||
ImageGCHighThresholdPercent: 90,
|
||||
ImageGCLowThresholdPercent: 80,
|
||||
@@ -226,6 +228,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.BoolVar(&s.AllowPrivileged, "allow-privileged", s.AllowPrivileged, "If true, allow containers to request privileged mode. [default=false]")
|
||||
fs.StringVar(&s.HostNetworkSources, "host-network-sources", s.HostNetworkSources, "Comma-separated list of sources from which the Kubelet allows pods to use of host network. For all sources use \"*\" [default=\"file\"]")
|
||||
fs.StringVar(&s.HostPIDSources, "host-pid-sources", s.HostPIDSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host pid namespace. For all sources use \"*\" [default=\"file\"]")
|
||||
fs.StringVar(&s.HostIPCSources, "host-ipc-sources", s.HostIPCSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host ipc namespace. For all sources use \"*\" [default=\"file\"]")
|
||||
fs.Float64Var(&s.RegistryPullQPS, "registry-qps", s.RegistryPullQPS, "If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0]")
|
||||
fs.IntVar(&s.RegistryBurst, "registry-burst", s.RegistryBurst, "Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry-qps. Only used if --registry-qps > 0")
|
||||
fs.Float32Var(&s.EventRecordQPS, "event-qps", s.EventRecordQPS, "If > 0, limit event creations per second to this value. If 0, unlimited. [default=0.0]")
|
||||
@@ -287,6 +290,11 @@ func (s *KubeletServer) KubeletConfig() (*KubeletConfig, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hostIPCSources, err := kubelet.GetValidatedSources(strings.Split(s.HostIPCSources, ","))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mounter := mount.New()
|
||||
var writer io.Writer = &io.StdWriter{}
|
||||
if s.Containerized {
|
||||
@@ -354,6 +362,7 @@ func (s *KubeletServer) KubeletConfig() (*KubeletConfig, error) {
|
||||
HostnameOverride: s.HostnameOverride,
|
||||
HostNetworkSources: hostNetworkSources,
|
||||
HostPIDSources: hostPIDSources,
|
||||
HostIPCSources: hostIPCSources,
|
||||
HTTPCheckFrequency: s.HTTPCheckFrequency,
|
||||
ImageGCPolicy: imageGCPolicy,
|
||||
KubeClient: nil,
|
||||
@@ -689,6 +698,7 @@ func RunKubelet(kcfg *KubeletConfig, builder KubeletBuilder) error {
|
||||
privilegedSources := capabilities.PrivilegedSources{
|
||||
HostNetworkSources: kcfg.HostNetworkSources,
|
||||
HostPIDSources: kcfg.HostPIDSources,
|
||||
HostIPCSources: kcfg.HostIPCSources,
|
||||
}
|
||||
capabilities.Setup(kcfg.AllowPrivileged, privilegedSources, 0)
|
||||
|
||||
@@ -783,6 +793,7 @@ type KubeletConfig struct {
|
||||
HostnameOverride string
|
||||
HostNetworkSources []string
|
||||
HostPIDSources []string
|
||||
HostIPCSources []string
|
||||
HTTPCheckFrequency time.Duration
|
||||
ImageGCPolicy kubelet.ImageGCPolicy
|
||||
KubeClient *client.Client
|
||||
|
||||
Reference in New Issue
Block a user