Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
18c55a1d
Commit
18c55a1d
authored
Feb 11, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup docker hostconfig for windows containers
parent
3c5e4934
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
helpers_windows.go
pkg/kubelet/dockershim/helpers_windows.go
+18
-22
No files found.
pkg/kubelet/dockershim/helpers_windows.go
View file @
18c55a1d
...
@@ -27,18 +27,10 @@ import (
...
@@ -27,18 +27,10 @@ import (
dockerfilters
"github.com/docker/docker/api/types/filters"
dockerfilters
"github.com/docker/docker/api/types/filters"
"github.com/golang/glog"
"github.com/golang/glog"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
"k8s.io/kubernetes/pkg/features"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
)
)
const
(
hypervIsolationAnnotationKey
=
"experimental.windows.kubernetes.io/isolation-type"
// Refer https://aka.ms/hyperv-container.
hypervIsolation
=
"hyperv"
)
func
DefaultMemorySwap
()
int64
{
func
DefaultMemorySwap
()
int64
{
return
0
return
0
}
}
...
@@ -50,19 +42,10 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
...
@@ -50,19 +42,10 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
return
nil
,
nil
return
nil
,
nil
}
}
func
shouldIsolatedByHyperV
(
annotations
map
[
string
]
string
)
bool
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
HyperVContainer
)
{
return
false
}
v
,
ok
:=
annotations
[
hypervIsolationAnnotationKey
]
return
ok
&&
v
==
hypervIsolation
}
// applyExperimentalCreateConfig applys experimental configures from sandbox annotations.
// applyExperimentalCreateConfig applys experimental configures from sandbox annotations.
func
applyExperimentalCreateConfig
(
createConfig
*
dockertypes
.
ContainerCreateConfig
,
annotations
map
[
string
]
string
)
{
func
applyExperimentalCreateConfig
(
createConfig
*
dockertypes
.
ContainerCreateConfig
,
annotations
map
[
string
]
string
)
{
if
s
houldIsolatedByHyperV
(
annotations
)
{
if
kubeletapis
.
S
houldIsolatedByHyperV
(
annotations
)
{
createConfig
.
HostConfig
.
Isolation
=
hypervIsolation
createConfig
.
HostConfig
.
Isolation
=
kubeletapis
.
HypervIsolationValue
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
==
""
{
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
==
""
{
createConfig
.
HostConfig
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
"none"
)
createConfig
.
HostConfig
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
"none"
)
...
@@ -77,11 +60,24 @@ func (ds *dockerService) updateCreateConfig(
...
@@ -77,11 +60,24 @@ func (ds *dockerService) updateCreateConfig(
podSandboxID
string
,
securityOptSep
rune
,
apiVersion
*
semver
.
Version
)
error
{
podSandboxID
string
,
securityOptSep
rune
,
apiVersion
*
semver
.
Version
)
error
{
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
!=
""
{
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
!=
""
{
createConfig
.
HostConfig
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
networkMode
)
createConfig
.
HostConfig
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
networkMode
)
}
else
if
!
s
houldIsolatedByHyperV
(
sandboxConfig
.
Annotations
)
{
}
else
if
!
kubeletapis
.
S
houldIsolatedByHyperV
(
sandboxConfig
.
Annotations
)
{
// Todo: Refactor this call in future for calling methods directly in security_context.go
// Todo: Refactor this call in future for calling methods directly in security_context.go
modifyHostOptionsForContainer
(
nil
,
podSandboxID
,
createConfig
.
HostConfig
)
modifyHostOptionsForContainer
(
nil
,
podSandboxID
,
createConfig
.
HostConfig
)
}
}
// Apply Windows-specific options if applicable.
if
wc
:=
config
.
GetWindows
();
wc
!=
nil
{
rOpts
:=
wc
.
GetResources
()
if
rOpts
!=
nil
{
createConfig
.
HostConfig
.
Resources
=
dockercontainer
.
Resources
{
Memory
:
rOpts
.
MemoryLimitInBytes
,
CPUShares
:
rOpts
.
CpuShares
,
CPUCount
:
rOpts
.
CpuCount
,
CPUPercent
:
rOpts
.
CpuMaximum
,
}
}
}
applyExperimentalCreateConfig
(
createConfig
,
sandboxConfig
.
Annotations
)
applyExperimentalCreateConfig
(
createConfig
,
sandboxConfig
.
Annotations
)
return
nil
return
nil
...
@@ -119,7 +115,7 @@ func (ds *dockerService) determinePodIPBySandboxID(sandboxID string) string {
...
@@ -119,7 +115,7 @@ func (ds *dockerService) determinePodIPBySandboxID(sandboxID string) string {
// Todo: Add a kernel version check for more validation
// Todo: Add a kernel version check for more validation
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
==
""
{
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
==
""
{
if
r
.
HostConfig
.
Isolation
==
hypervIsolation
{
if
r
.
HostConfig
.
Isolation
==
kubeletapis
.
HypervIsolationValue
{
// Hyper-V only supports one container per Pod yet and the container will have a different
// Hyper-V only supports one container per Pod yet and the container will have a different
// IP address from sandbox. Return the first non-sandbox container IP as POD IP.
// IP address from sandbox. Return the first non-sandbox container IP as POD IP.
// TODO(feiskyer): remove this workaround after Hyper-V supports multiple containers per Pod.
// TODO(feiskyer): remove this workaround after Hyper-V supports multiple containers per Pod.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment