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
cabd2bb6
Commit
cabd2bb6
authored
Jan 30, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add experimental hyperv containers support on Windows
parent
8d9a9dca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
3 deletions
+47
-3
docker_sandbox.go
pkg/kubelet/dockershim/docker_sandbox.go
+2
-0
helpers_linux.go
pkg/kubelet/dockershim/helpers_linux.go
+4
-0
helpers_unsupported.go
pkg/kubelet/dockershim/helpers_unsupported.go
+4
-0
helpers_windows.go
pkg/kubelet/dockershim/helpers_windows.go
+37
-3
No files found.
pkg/kubelet/dockershim/docker_sandbox.go
View file @
cabd2bb6
...
...
@@ -587,6 +587,8 @@ func (ds *dockerService) makeSandboxDockerConfig(c *runtimeapi.PodSandboxConfig,
return
nil
,
fmt
.
Errorf
(
"failed to generate sandbox security options for sandbox %q: %v"
,
c
.
Metadata
.
Name
,
err
)
}
hc
.
SecurityOpt
=
append
(
hc
.
SecurityOpt
,
securityOpts
...
)
applyExperimentalCreateConfig
(
createConfig
,
c
.
Annotations
)
return
createConfig
,
nil
}
...
...
pkg/kubelet/dockershim/helpers_linux.go
View file @
cabd2bb6
...
...
@@ -145,3 +145,7 @@ func getNetworkNamespace(c *dockertypes.ContainerJSON) (string, error) {
}
return
fmt
.
Sprintf
(
dockerNetNSFmt
,
c
.
State
.
Pid
),
nil
}
// applyExperimentalCreateConfig applys experimental configures from sandbox annotations.
func
applyExperimentalCreateConfig
(
createConfig
*
dockertypes
.
ContainerCreateConfig
,
annotations
map
[
string
]
string
)
{
}
pkg/kubelet/dockershim/helpers_unsupported.go
View file @
cabd2bb6
...
...
@@ -53,3 +53,7 @@ func (ds *dockerService) determinePodIPBySandboxID(uid string) string {
func
getNetworkNamespace
(
c
*
dockertypes
.
ContainerJSON
)
(
string
,
error
)
{
return
""
,
fmt
.
Errorf
(
"unsupported platform"
)
}
// applyExperimentalCreateConfig applys experimental configures from sandbox annotations.
func
applyExperimentalCreateConfig
(
createConfig
*
dockertypes
.
ContainerCreateConfig
,
annotations
map
[
string
]
string
)
{
}
pkg/kubelet/dockershim/helpers_windows.go
View file @
cabd2bb6
...
...
@@ -29,6 +29,13 @@ import (
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)
const
(
hypervIsolationAnnotationKey
=
"experimental.windows.kubernetes.io/isolation-type"
// Refer https://aka.ms/hyperv-container.
hypervIsolation
=
"hyperv"
)
func
DefaultMemorySwap
()
int64
{
return
0
}
...
...
@@ -40,6 +47,22 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
return
nil
,
nil
}
func
shouldIsolatedByHyperV
(
annotations
map
[
string
]
string
)
bool
{
v
,
ok
:=
annotations
[
hypervIsolationAnnotationKey
]
return
ok
&&
v
==
hypervIsolation
}
// applyExperimentalCreateConfig applys experimental configures from sandbox annotations.
func
applyExperimentalCreateConfig
(
createConfig
*
dockertypes
.
ContainerCreateConfig
,
annotations
map
[
string
]
string
)
{
if
shouldIsolatedByHyperV
(
annotations
)
{
createConfig
.
HostConfig
.
Isolation
=
hypervIsolation
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
==
""
{
createConfig
.
HostConfig
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
"none"
)
}
}
}
func
(
ds
*
dockerService
)
updateCreateConfig
(
createConfig
*
dockertypes
.
ContainerCreateConfig
,
config
*
runtimeapi
.
ContainerConfig
,
...
...
@@ -47,11 +70,13 @@ func (ds *dockerService) updateCreateConfig(
podSandboxID
string
,
securityOptSep
rune
,
apiVersion
*
semver
.
Version
)
error
{
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
!=
""
{
createConfig
.
HostConfig
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
networkMode
)
}
else
{
}
else
if
!
shouldIsolatedByHyperV
(
sandboxConfig
.
Annotations
)
{
// Todo: Refactor this call in future for calling methods directly in security_context.go
modifyHostNetworkOptionForContainer
(
false
,
podSandboxID
,
createConfig
.
HostConfig
)
}
applyExperimentalCreateConfig
(
createConfig
,
sandboxConfig
.
Annotations
)
return
nil
}
...
...
@@ -87,8 +112,17 @@ func (ds *dockerService) determinePodIPBySandboxID(sandboxID string) string {
// Todo: Add a kernel version check for more validation
if
networkMode
:=
os
.
Getenv
(
"CONTAINER_NETWORK"
);
networkMode
==
""
{
// Do not return any IP, so that we would continue and get the IP of the Sandbox
ds
.
getIP
(
sandboxID
,
r
)
if
r
.
HostConfig
.
Isolation
==
hypervIsolation
{
// 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.
// TODO(feiskyer): remove this workaround after Hyper-V supports multiple containers per Pod.
if
containerIP
:=
ds
.
getIP
(
c
.
ID
,
r
);
containerIP
!=
""
{
return
containerIP
}
}
else
{
// Do not return any IP, so that we would continue and get the IP of the Sandbox
ds
.
getIP
(
sandboxID
,
r
)
}
}
else
{
// On Windows, every container that is created in a Sandbox, needs to invoke CNI plugin again for adding the Network,
// with the shared container name as NetNS info,
...
...
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