mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #39005 from brendandburns/windows
Automatic merge from submit-queue (batch tested with PRs 38212, 38792, 39641, 36390, 39005) Set MemorySwap to zero on Windows Fixes https://github.com/kubernetes/kubernetes/issues/39003 @dchen1107 @michmike @kubernetes/sig-node-misc
This commit is contained in:
commit
d3c0914a14
@ -133,7 +133,7 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeapi
|
|||||||
if rOpts != nil {
|
if rOpts != nil {
|
||||||
hc.Resources = dockercontainer.Resources{
|
hc.Resources = dockercontainer.Resources{
|
||||||
Memory: rOpts.GetMemoryLimitInBytes(),
|
Memory: rOpts.GetMemoryLimitInBytes(),
|
||||||
MemorySwap: -1,
|
MemorySwap: dockertools.DefaultMemorySwap(),
|
||||||
CPUShares: rOpts.GetCpuShares(),
|
CPUShares: rOpts.GetCpuShares(),
|
||||||
CPUQuota: rOpts.GetCpuQuota(),
|
CPUQuota: rOpts.GetCpuQuota(),
|
||||||
CPUPeriod: rOpts.GetCpuPeriod(),
|
CPUPeriod: rOpts.GetCpuPeriod(),
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
|
|
||||||
runtimeapi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
runtimeapi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
|
"k8s.io/kubernetes/pkg/kubelet/dockertools"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/qos"
|
"k8s.io/kubernetes/pkg/kubelet/qos"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/types"
|
"k8s.io/kubernetes/pkg/kubelet/types"
|
||||||
)
|
)
|
||||||
@ -373,7 +374,7 @@ func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
|||||||
|
|
||||||
func setSandboxResources(hc *dockercontainer.HostConfig) {
|
func setSandboxResources(hc *dockercontainer.HostConfig) {
|
||||||
hc.Resources = dockercontainer.Resources{
|
hc.Resources = dockercontainer.Resources{
|
||||||
MemorySwap: -1,
|
MemorySwap: dockertools.DefaultMemorySwap(),
|
||||||
CPUShares: defaultSandboxCPUshares,
|
CPUShares: defaultSandboxCPUshares,
|
||||||
// Use docker's default cpu quota/period.
|
// Use docker's default cpu quota/period.
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -710,11 +709,7 @@ func (dm *DockerManager) runContainer(
|
|||||||
SecurityOpt: fmtSecurityOpts,
|
SecurityOpt: fmtSecurityOpts,
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is no /etc/resolv.conf in Windows, DNS and DNSSearch options would have to be passed to Docker runtime instead
|
updateHostConfig(hc)
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
hc.DNS = opts.DNS
|
|
||||||
hc.DNSSearch = opts.DNSSearch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sysctls if requested
|
// Set sysctls if requested
|
||||||
if container.Name == PodInfraContainerName {
|
if container.Name == PodInfraContainerName {
|
||||||
|
@ -20,9 +20,20 @@ package dockertools
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
dockertypes "github.com/docker/engine-api/types"
|
dockertypes "github.com/docker/engine-api/types"
|
||||||
|
dockercontainer "github.com/docker/engine-api/types/container"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// These two functions are OS specific (for now at least)
|
||||||
|
func updateHostConfig(config *dockercontainer.HostConfig) {
|
||||||
|
// no-op, there is a windows implementation that is different.
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultMemorySwap() int64 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
func getContainerIP(container *dockertypes.ContainerJSON) string {
|
func getContainerIP(container *dockertypes.ContainerJSON) string {
|
||||||
result := ""
|
result := ""
|
||||||
if container.NetworkSettings != nil {
|
if container.NetworkSettings != nil {
|
||||||
|
@ -24,6 +24,14 @@ import (
|
|||||||
dockertypes "github.com/docker/engine-api/types"
|
dockertypes "github.com/docker/engine-api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// These two functions are OS specific (for now at least)
|
||||||
|
func updateHostConfig(config *dockercontainer.HostConfig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultMemorySwap() int64 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
func getContainerIP(container *dockertypes.ContainerJSON) string {
|
func getContainerIP(container *dockertypes.ContainerJSON) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,24 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
|
|
||||||
dockertypes "github.com/docker/engine-api/types"
|
dockertypes "github.com/docker/engine-api/types"
|
||||||
|
dockercontainer "github.com/docker/engine-api/types/container"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// These two functions are OS specific (for now at least)
|
||||||
|
func updateHostConfig(config *dockercontainer.HostConfig) {
|
||||||
|
// There is no /etc/resolv.conf in Windows, DNS and DNSSearch options would have to be passed to Docker runtime instead
|
||||||
|
hc.DNS = opts.DNS
|
||||||
|
hc.DNSSearch = opts.DNSSearch
|
||||||
|
|
||||||
|
// MemorySwap == -1 is not currently supported in Docker 1.14 on Windows
|
||||||
|
// https://github.com/docker/docker/blob/master/daemon/daemon_windows.go#L175
|
||||||
|
hc.Resources.MemorySwap = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultMemorySwap() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func getContainerIP(container *dockertypes.ContainerJSON) string {
|
func getContainerIP(container *dockertypes.ContainerJSON) string {
|
||||||
if container.NetworkSettings != nil {
|
if container.NetworkSettings != nil {
|
||||||
for _, network := range container.NetworkSettings.Networks {
|
for _, network := range container.NetworkSettings.Networks {
|
||||||
|
Loading…
Reference in New Issue
Block a user