mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #105465 from marosset/remove-host-process-contianer-kubelet-annotations
Stop passing WindowsHostProcessContainer annotations for CRI calls in kubelet
This commit is contained in:
commit
1af8a8c026
@ -18,17 +18,13 @@ package kuberuntime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
kubetypes "k8s.io/apimachinery/pkg/types"
|
kubetypes "k8s.io/apimachinery/pkg/types"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/types"
|
"k8s.io/kubernetes/pkg/kubelet/types"
|
||||||
sc "k8s.io/kubernetes/pkg/securitycontext"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -42,12 +38,6 @@ const (
|
|||||||
containerTerminationMessagePolicyLabel = "io.kubernetes.container.terminationMessagePolicy"
|
containerTerminationMessagePolicyLabel = "io.kubernetes.container.terminationMessagePolicy"
|
||||||
containerPreStopHandlerLabel = "io.kubernetes.container.preStopHandler"
|
containerPreStopHandlerLabel = "io.kubernetes.container.preStopHandler"
|
||||||
containerPortsLabel = "io.kubernetes.container.ports"
|
containerPortsLabel = "io.kubernetes.container.ports"
|
||||||
|
|
||||||
// TODO: remove this annotation when moving to beta for Windows hostprocess containers
|
|
||||||
// xref: https://github.com/kubernetes/kubernetes/pull/99576/commits/42fb66073214eed6fe43fa8b1586f396e30e73e3#r635392090
|
|
||||||
// Currently, ContainerD on Windows does not yet fully support HostProcess containers
|
|
||||||
// but will pass annotations to hcsshim which does have support.
|
|
||||||
windowsHostProcessContainer = "microsoft.com/hostprocess-container"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type labeledPodSandboxInfo struct {
|
type labeledPodSandboxInfo struct {
|
||||||
@ -99,23 +89,7 @@ func newPodLabels(pod *v1.Pod) map[string]string {
|
|||||||
|
|
||||||
// newPodAnnotations creates pod annotations from v1.Pod.
|
// newPodAnnotations creates pod annotations from v1.Pod.
|
||||||
func newPodAnnotations(pod *v1.Pod) map[string]string {
|
func newPodAnnotations(pod *v1.Pod) map[string]string {
|
||||||
annotations := map[string]string{}
|
return pod.Annotations
|
||||||
|
|
||||||
// Get annotations from v1.Pod
|
|
||||||
for k, v := range pod.Annotations {
|
|
||||||
annotations[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
if runtime.GOOS == "windows" && utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers) {
|
|
||||||
if kubecontainer.HasWindowsHostProcessContainer(pod) {
|
|
||||||
// While WindowsHostProcessContainers is in alpha pass 'microsoft.com/hostprocess-container' annotation
|
|
||||||
// to pod sandbox creations request. ContainerD on Windows does not yet fully support HostProcess
|
|
||||||
// containers but will pass annotations to hcsshim which does have support.
|
|
||||||
annotations[windowsHostProcessContainer] = "true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return annotations
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newContainerLabels creates container labels from v1.Container and v1.Pod.
|
// newContainerLabels creates container labels from v1.Container and v1.Pod.
|
||||||
@ -169,15 +143,6 @@ func newContainerAnnotations(container *v1.Container, pod *v1.Pod, restartCount
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "windows" && utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers) {
|
|
||||||
if sc.HasWindowsHostProcessRequest(pod, container) {
|
|
||||||
// While WindowsHostProcessContainers is in alpha pass 'microsoft.com/hostprocess-container' annotation
|
|
||||||
// to create containers request. ContainerD on Windows does not yet fully support HostProcess containers
|
|
||||||
// but will pass annotations to hcsshim which does have support.
|
|
||||||
annotations[windowsHostProcessContainer] = "true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return annotations
|
return annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user