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 ShareProcessNamespace to PodSpec #58716

Merged
merged 2 commits into from Feb 21, 2018
Merged

Conversation

verb
Copy link
Contributor

@verb verb commented Jan 23, 2018

What this PR does / why we need it: This adds an option to the Kubernetes API to configure sharing a process (PID) namespace between the containers in a pod, as described in the shared pid proposal.

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

Special notes for your reviewer:
Questions for API reviewer:

  • Is the documentation sufficient to describe the new option?
  • Does the new field better belong in the security context?
  • is prepending "alpha" to json/proto fields the right thing to do?

Release note:

v1.Pod now has a field to configure whether a single process namespace should be shared between all containers in a pod. This feature is in alpha preview.

@k8s-ci-robot k8s-ci-robot added 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. 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 23, 2018
@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jan 23, 2018
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 24, 2018
@verb
Copy link
Contributor Author

verb commented Jan 24, 2018

/retest

@verb
Copy link
Contributor Author

verb commented Jan 26, 2018

@smarterclayton I think you have the most context/preference on this change, but if you don't have time to review let me know and I'll try to find another API reviewer. Thanks!

@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 26, 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 27, 2018
// HostPID and ShareProcessNamespace cannot both be set.
// Optional: Default to false.
// +optional
ShareProcessNamespace *bool
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the argument for or against putting this into PodSecurityContext (alongside HostPID)?

Copy link
Contributor

Choose a reason for hiding this comment

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

If there's an argument against, should we be creating a new nested struct that contains process or namespace settings?

How much stuff should be at the top level of PodSpec, vs more properly isolated?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we put it in PodSecurityContext, is there a reason to call this SharedPID instead of SharedProcessNamespace? Or should it be ProcessNamespace string with constant values Host, Shared, ... for future extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think putting it in PodSecurityContext is reasonable, but I'm lacking context on its intended use so I wanted to discuss it with you prior to writing custom conversion to the flattened v1.PodSpec. In my mind, this isn't really a security setting, but based on community response to this feature I think many disagree.

I started with SharedPID as the name, but now I agree with your initial assessment that it isn't worth keeping a nondescriptive name just for the sake of consistency.

An enum is the approach we took in the CRI, but that API is still in alpha. It actually didn't occur to me to do something similar in the core API but keep the bools in v1, is that what you mean? That seems reasonable to me, but I haven't fully grokked how the versioned/nonversioned interfaces are used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton I went ahead and moved ShareProcessNamespace to PodSecurityContext, but I'll hold off on changing field types until you get a chance to respond.

@verb
Copy link
Contributor Author

verb commented Jan 30, 2018

Oh, I should point out that I put some questions for reviewers in the PR description.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 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 Feb 4, 2018
@verb
Copy link
Contributor Author

verb commented Feb 5, 2018

/retest

priorityEnabled := utilfeature.DefaultFeatureGate.Enabled("PodPriority")
defer func() {
var err error
defer func(podPriority, shareProcessNamespace bool) {
Copy link
Member

@liggitt liggitt Feb 8, 2018

Choose a reason for hiding this comment

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

defer utilfeaturetesting.SetFeatureGateDuringTest(...)() will do this for you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

egad, I've been wanting that for like a year. I wish I had sent you a PR sooner. Fixed.

err = utilfeature.DefaultFeatureGate.Set("PodPriority=false")
if err != nil {
t.Errorf("Failed to disable feature gate for PodPriority: %v", err)
if err := utilfeature.DefaultFeatureGate.Set("PodPriority=false,PodShareProcessNamespace=false"); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

here, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I discarded the return function rather than having a redundant defer.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 8, 2018
@liggitt
Copy link
Member

liggitt commented Feb 8, 2018

handling of alpha field and test bits LGTM. will defer to other reviewers more involved with the original proposal

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 8, 2018
t.Errorf("Failed to enable feature gate for PodPriority: %v", err)
return
}
defer utilfeaturetesting.SetFeatureGateDuringTesting(t, utilfeature.DefaultFeatureGate, features.PodPriority, true)()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be SetFeatureGateDuringTest(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eeep, thanks. not sure how I managed that.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 13, 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 Feb 15, 2018
// HostPID and ShareProcessNamespace cannot both be set.
// Optional: Default to false.
// This field is alpha-level and is honored only by servers that enable the PodShareProcessNamespace feature.
// +k8s:conversion-gen=false
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you have conversion-gen=false on here? Just because the predecessors have it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it would be necessary because the Spec.ShareProcessNamespace vs Spec.SecurityContext.ShareProcessNamespace path difference needed manual conversion.

@smarterclayton
Copy link
Contributor

Other than the existing concern about how this tears down walls between containers prior to us resolving the shared pod sidecar use case, this is fine. It has legitimate value and is still alpha.

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 19, 2018
@smarterclayton
Copy link
Contributor

One question.

@dchen1107
Copy link
Member

/test pull-kubernetes-e2e-kops-aws

@dchen1107
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 21, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dchen1107, smarterclayton, verb, yujuhong

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

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

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Feb 21, 2018

@verb: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce a41de1b link /test pull-kubernetes-e2e-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 58716, 59977, 59316, 59884, 60117). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 97297dc into kubernetes:master Feb 21, 2018
k8s-github-robot pushed a commit that referenced this pull request Feb 22, 2018
Automatic merge from submit-queue (batch tested with PRs 60148, 60022, 59125, 60068, 60154). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Adding support for per-pod process namespace sharing in kubelet

**What this PR does / why we need it**: This enables process namespace sharing between containers in a pod as described in the [Shared PID Namespace](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/node/pod-pid-namespace.md#container-runtime-interface-changes) proposal but leaves it disconnected pending merge of #58716.

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

**Special notes for your reviewer**: 

**Release note**:

```release-note
NONE
```
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants