Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of hyperv isolation for windows containers #58751

Merged
merged 2 commits into from
Feb 1, 2018

Conversation

feiskyer
Copy link
Member

@feiskyer feiskyer commented Jan 24, 2018

What this PR does / why we need it:

Add support of hyperv isolation for windows containers.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #58750

Special notes for your reviewer:

Only one container per pod is supported yet.

Release note:

Windows containers now support experimental Hyper-V isolation by setting annotation `experimental.windows.kubernetes.io/isolation-type=hyperv` and feature gates HyperVContainer. Only one container per pod is supported yet.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 24, 2018
@feiskyer
Copy link
Member Author

/sig windows

@k8s-ci-robot k8s-ci-robot added the sig/windows Categorizes an issue or PR as relevant to SIG Windows. label Jan 24, 2018
@feiskyer
Copy link
Member Author

/cc @PatrickLang @JiangtianLi @michmike

@k8s-ci-robot
Copy link
Contributor

@feiskyer: GitHub didn't allow me to request PR reviews from the following users: PatrickLang, JiangtianLi.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @PatrickLang @JiangtianLi @michmike

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot requested a review from michmike January 24, 2018 14:26
@feiskyer
Copy link
Member Author

/sig node

/cc @yujuhong

@k8s-ci-robot k8s-ci-robot requested a review from yujuhong January 24, 2018 14:27
@k8s-ci-robot k8s-ci-robot added the sig/node Categorizes an issue or PR as relevant to SIG Node. label Jan 24, 2018
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need apply the isolation specific config to sandbox? For Windows Hyper-V container, the POD infra container is not used and needs to be minimal, and therefore process container is sufficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used now, but not future. I think we'd better keep sandbox same with containers, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine with me. We can reserve it as place holder.

@@ -52,6 +70,8 @@ func (ds *dockerService) updateCreateConfig(
modifyHostNetworkOptionForContainer(false, podSandboxID, createConfig.HostConfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Hyper-V container, no need to call modifyHostNetworkOptionForContainer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, will fix

// 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 == hypervIsolationAnnotationValue {
if containerIP := ds.getIP(c.ID, r); containerIP != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment here saying "Return the first non-sandbox container IP as POD IP for Hyper-V container"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@JiangtianLi
Copy link
Contributor

/cc @madhanrm

@k8s-ci-robot
Copy link
Contributor

@JiangtianLi: GitHub didn't allow me to request PR reviews from the following users: madhanrm.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @madhanrm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -29,6 +29,11 @@ import (
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)

const (
hypervIsolationAnnotationKey = "windows.kubernetes.io/isolation-type"
hypervIsolationAnnotationValue = "hyperv"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to const in https://github.com/moby/moby/blob/master/api/types/container/host_config.go or add a comment with link to where this string comes from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, will add a refer link

Copy link
Contributor

@JiangtianLi JiangtianLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tallclair tallclair self-assigned this Jan 26, 2018
@@ -40,18 +47,41 @@ func (ds *dockerService) getSecurityOpts(seccompProfile string, separator rune)
return nil, nil
}

func shouldIsolatedByHyperV(annotations map[string]string) bool {
if v, ok := annotations[hypervIsolationAnnotationKey]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer

v, ok := annotations[hypervIsolationAnnotationKey]
return ok && v == hypervIsolation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@@ -29,6 +29,13 @@ import (
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)

const (
hypervIsolationAnnotationKey = "windows.kubernetes.io/isolation-type"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include experimental in the key. I want to make it clear that this is not an official API, and won't be supported long term -- eventually we will have a native secure container concept that this should move to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

createConfig.HostConfig.Isolation = hypervIsolation

if networkMode := os.Getenv("CONTAINER_NETWORK"); networkMode == "" {
createConfig.HostConfig.NetworkMode = dockercontainer.NetworkMode("none")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that hyperV isolated containers will not have any networking by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, hyperV container's network will be set by CNI plugins

// 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 {
// Return the first non-sandbox container IP as POD IP for Hyper-V container.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this to me?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noticed here, HyperV only support one container per Pod yet. And container will receive a different IP from sandbox. So we need to get the real container's IP.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you include information that in the comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@feiskyer
Copy link
Member Author

@tallclair Addressed comments. PTAL

@feiskyer
Copy link
Member Author

@yujuhong Addressed comments and squashed. PTAL

@tallclair
Copy link
Member

Should this be behind a feature gate? I'm on the fence...

@feiskyer
Copy link
Member Author

feiskyer commented Jan 30, 2018

Should this be behind a feature gate? I'm on the fence...

@tallclair I'm thinking only API changes requires feature gates, while the PR doesn't change any API. WDYT?

@feiskyer
Copy link
Member Author

/retest

@tallclair
Copy link
Member

I'm thinking only API changes requires feature gates, while the PR doesn't change any API. WDYT?

No, we require feature gates for changed functionality too. Besides, you are changing the API by adding the annotation (just not the "official" API).

What is the status of windows support? Are there users using it in production? If the answer is yes, this should be feature gated. Otherwise, I'm OK leaving it ungated.

@feiskyer
Copy link
Member Author

What is the status of windows support? Are there users using it in production? If the answer is yes, this should be feature gated. Otherwise, I'm OK leaving it ungated.

Yep, there are. OK, let me add a feature gate in kubelet.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2018
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2018
@feiskyer
Copy link
Member Author

@tallclair Feature gates added. PTAL

@michmike
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 30, 2018
@tallclair
Copy link
Member

/lgtm

@feiskyer
Copy link
Member Author

/assign @brendandburns

@feiskyer
Copy link
Member Author

@brendandburns could you help to take a look?

@brendandburns
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, feiskyer, michmike, tallclair

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 31, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@yuwei1chen
Copy link

@feiskyer Hi, we wanted to use this feature gate in v1.20 k8s, met the same issue in https://stackoverflow.com/questions/51634469/kubernetes-windows-hyper-v-no-network-in-pod.
Hyperv containers started do not have network configured. It even do not have a pod ip. Do you have any clues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/windows Categorizes an issue or PR as relevant to SIG Windows. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support of hyperv isolation for windows containers
10 participants