Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

wawa0210
Copy link
Contributor

@wawa0210 wawa0210 commented Jul 19, 2020

What type of PR is this?

/kind bug

What this PR does / why we need it:

AppArmor is a Linux kernel security module.and It does not support windows

At present, the startup logic of kubelet does not deal with this logic, which causes apparmor to be running on windows, causing an exception

Which issue(s) this PR fixes:

Fixes #93165

Special notes for your reviewer:

AppArmor is a linux kernel security module and it does not support other operating systems.

Does this PR introduce a user-facing change?:

Ignore apparmor for non-linux operating systems

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


/sig windows

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 19, 2020
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 19, 2020
@dims
Copy link
Member

dims commented Jul 19, 2020

/sig node

@wawa0210
Copy link
Contributor Author

wawa0210 commented Jul 19, 2020

/sig windows

@k8s-ci-robot k8s-ci-robot added the sig/windows Categorizes an issue or PR as relevant to SIG Windows. label Jul 19, 2020
@k8s-ci-robot
Copy link
Contributor

@wawa0210: The label(s) priority/ cannot be applied, because the repository doesn't have them

In response to this:

/sig windows
/priority backlog

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 added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 19, 2020
@wawa0210
Copy link
Contributor Author

/retest

Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this issue @wawa0210 !

To start, could we talk through some of the diff options for solving this issue?

One option, which you've already implemented, definitely seems to be gating the appArmorValidator on the runtime, and not starting if its windows. However, I'm curious about how this will work on non-Windows/non-Linux operating systems (i.e. FreeBSD and Darwin), which I imagine also doesn't support app armor.

However, I think there may be other options as well - off the top of my head, I think there are at least three.

  1. Do some kind of runtime check around whether the system running the kubelet supports app armor, and only add the admit handler if it does.

  2. Make it so that, if the app armor validator is attempting to run on a non-supported platform, the validator itself is smart enough to fail gracefully.

  3. As you mentioned, break out this runtime specific component into a separate file using build tags.

We may find that, after exploring all options, the initially proposed one is the best. Still, I think it would be useful to think through the pros and cons of this option :)

@wawa0210
Copy link
Contributor Author

wawa0210 commented Jul 19, 2020

Thank you so much for such a detailed comment

Before I start, I also thought about different ways to implement it, as you said

  1. Make it so that, if the app armor validator is attempting to run on a non-supported platform, the validator itself is smart enough to fail gracefully.

I don't recommend using this method,it will judge it like an armor validator at the specific logic level, and then to fail gracefully. But in the future, there will be many features like this, so that the same judgment will be written and executed

  1. As you mentioned, break out this runtime specific component into a separate file using build tags.

I also want to implement it in this way, but it seems that the current logic is only here. Therefore, I tried to use the first relatively simple way. If there are such features later, maybe it is a better choice to split and refactor.

@liggitt
Copy link
Member

liggitt commented Jul 20, 2020

@wawa0210 wawa0210 force-pushed the fix-93165 branch 2 times, most recently from 98b0dd9 to 8dc5528 Compare July 24, 2020 11:54
@wawa0210
Copy link
Contributor Author

/retest

@dashpole
Copy link
Contributor

This needs guidance from sig-windows. @benmoss @ddebroy

@marosset
Copy link
Contributor

/milestone v1.20

@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Aug 13, 2020
@wawa0210
Copy link
Contributor Author

/test pull-kubernetes-e2e-kind-ipv6

@justaugustus justaugustus removed this from the v1.20 milestone Aug 27, 2020
@dims
Copy link
Member

dims commented Sep 15, 2020

/assign @dashpole @sjenning

Quick easy one David and Seth. adds a if condition around the admit handler for apparmor

/approve
/lgtm

@dashpole
Copy link
Contributor

It feels odd to me that this behavior differs from the behavior we get when trying to run a pod on a linux node without apparmor. What do users do today when they have clusters with some nodes that do/don't support AppArmor? Or do we currently assume AppArmor is either enabled or disabled on all nodes? What makes windows special in this regard?

I have the same discomfort with this as I had with #92355 (comment). The current behavior is that if you ask for AppArmor on your pod, and the node cannot satisfy it, we don't run your pod. That seems like the most secure behavior, so a misconfigured node or being scheduled to a node you didn't intend doesn't silently result in a security incident. A warning when creating the object is better, but it sounds like multi-arch images mean we can't do validation at that point.

Why isn't the right answer here: "Don't apply an AppArmor SP to your pod if you want to run without AppArmor"?

@tallclair @mikedanese

@jsturtevant
Copy link
Contributor

Or do we currently assume AppArmor is either enabled or disabled on all nodes? What makes windows special in this regard?

specifically for AppArmor, it would never be enabled on Windows as it is a Linux kernel component. I don't think there is a misconfigured node scenario in the case where goos == windows

Why isn't the right answer here: "Don't apply an AppArmor SP to your pod if you want to run without AppArmor"?

Important question. It might not be the ccorrect answer but from the other discussions there was a an expectation from windows users that since it is not valid for Windows it wouldn't come into play.

For comparison, I ran a pod with SecurityContext.WindowsOptions and SecurityContext.seLinuxOptions set on a linux node (which didn't have seLinux enabled) and it was scheduled. Maybe there needs to be another look at this more holistically?

@jsturtevant
Copy link
Contributor

thinking on it some more, the multi-arch use case might be the scenario that was the impetus for #93475.

@ravisantoshgudimetla could you share more info on your expectations?

@benmoss
Copy link
Member

benmoss commented Sep 16, 2020

This discussion reminds me of #75215

@liggitt: we have existing fields that get ignored in environments where they don't apply (selinux, apparmor/seccomp annotations, etc), and the windows GA behavior in 1.14 is to ignore linux-specific fields, correct? don't the changes in this PR mean that pod specs that could run correctly in 1.14 will now fail?

@benmoss
Copy link
Member

benmoss commented Sep 16, 2020

/lgtm

@pacoxu
Copy link
Member

pacoxu commented Sep 18, 2020

/cc

@k8s-ci-robot k8s-ci-robot requested a review from pacoxu September 18, 2020 08:44
@ravisantoshgudimetla
Copy link
Contributor

thinking on it some more, the multi-arch use case might be the scenario that was the impetus for #93475.

@ravisantoshgudimetla could you share more info on your expectations?

To me, ignoring the linux specific security constructs on kubelet side makes sense for now. There are distributions of Kube like OpenShift that apply SELinux options to the pods at the admission and this was the reason for starting #93475. I think, the fundamental problem is we want to distinguish Linux from Windows pods at the scheduling time using nodeSelector and tolerations but we have some api within the pod Spec that can be defaulted at the admission time. Unless we enforce runtime class and have reserved label which says I am Windows pod and have that applied to the pod Spec at the admission time, it becomes so hard for us to distinguish and we might have to end up special casing on the kubelet or runtime side as these security specific fields are passed down to them.

@wawa0210
Copy link
Contributor Author

@liggitt

Looking forward to your comments, thanks

@liggitt
Copy link
Member

liggitt commented Oct 20, 2020

@liggitt

Looking forward to your comments, thanks

sorry, didn't realize this was pending my comments... what section specifically?

@wawa0210
Copy link
Contributor Author

wawa0210 commented Oct 21, 2020

sorry, didn't realize this was pending my comments... what section specifically?

sig-windows agrees that this pr can solve the current scenario where apparmor is not applicable to windows~ but @dashpole seems to have some different suggestions.Do you have any suggestions?

@liggitt
Copy link
Member

liggitt commented Oct 21, 2020

I have the same discomfort with this as I had with #92355 (comment). The current behavior is that if you ask for AppArmor on your pod, and the node cannot satisfy it, we don't run your pod. That seems like the most secure behavior, so a misconfigured node or being scheduled to a node you didn't intend doesn't silently result in a security incident.

That seems like a reasonable position for non-apparmor linux nodes which could happily unsafely run a linux container you would have thought would be protected by apparmor.

If the container is a multi-arch container that supports windows, I don't think there will be confusion that the windows container runs without apparmor

If we were structuring the pod spec today, we'd likely group things like apparmor, selinux, and seccomp options in a linuxOptions substanza of security context. Imagining those linux-only things grouped under a linuxOptions stanza, I don't find it strange for the windows kubelet to ignore them.

@dashpole
Copy link
Contributor

I guess it's just me then. I don't have any powers here anymore, though.
/approve

@wawa0210
Copy link
Contributor Author

/assign @sjenning

@dims dims removed their assignment Oct 22, 2020
@dims
Copy link
Member

dims commented Oct 22, 2020

/assign @sjenning @derekwaynecarr

easy PR, already approved by @dashpole :)

@sjenning
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dashpole, dims, michmike, sjenning, wawa0210

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-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2020
@wawa0210
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit c6f7fbc into kubernetes:master Oct 23, 2020
@wawa0210 wawa0210 deleted the fix-93165 branch October 23, 2020 06:25
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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. 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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A PSP with apparmor annotations does not allow windows pods to be scheduled