Skip to content

[DONOTMERGE] (Pending 5169) OpenShift Volume Security Integration - #5079

Closed
pweil- wants to merge 10 commits into
openshift:masterfrom
pweil-:supplemental-groups
Closed

pweil- wants to merge 10 commits into
openshift:masterfrom
pweil-:supplemental-groups

Conversation

@pweil-

@pweil- pweil- commented Oct 12, 2015

Copy link
Copy Markdown

This is based on @pmorie 's WIP branch #5169. The last two commits are what I'm working on.

Contains:

  1. SecurityContextConstraints api support
  2. Includes a defaulter for SCCs without FSGroup/SupplementalGroups strategies so no upgrade is necessary
  3. Defaulting is based on the value of the RunAsUser strategy
  4. Strategies for groups (fsgroup and sup groups use the same underlying strategy code but have their own definitions/types)
  5. Both strategies allow namespace configuration by using MustRunAs with no ranges set
  6. Both strategies will provide a default value of the first value in the first range configured
  7. When using namespace configuration for the FSGroup strategy it will create a single range with a min/max of the first value in the supplemental group annotation.
  8. When using namespace configuration for the SupGroup strategy it will parse the entire annotation into ranges.
  9. provider implementation
  10. new interface methods introduced to generate and validate a PSC
  11. support for fsgroup/sup group strategies
  12. reuse of the selinux strategy validation on the PSC by mocking up a container to validate (generation never uses the container so no mock is necessary)
  13. admission control for PSC
  14. generates and validates the PSC
  15. uses the SecurityContext provider to determine the effective SC for the container prior to container generation/validation (provides us initial value defaulting and allows container overrides)
  16. retrieval of the supplemental group annotation has fallback code to use the uid annotation if necessary for a better upgrade experience

@pmorie @swagiaal @liggitt @smarterclayton


Remaining Work:

  • blacklisting v1beta3 PodSpecs has rippled into a lot of objects now not getting fuzzed. At the very least, we need an issue find a way to test v1beta3 -> internal -> v1beta3 with fidelity. See the ripples here: https://github.com/openshift/origin/pull/5079/files#diff-394377845c8dfd9eec363c059cdde354R379
  • UPSTREAM commit names need fixing.
  • issue to allow admission based on a union of available SCCs. With multiple ranges and options, its really annoying to have an SCC that combines all of them.
  • issue to convert code to a DeepCopy of the pod. This would help readability and its only going to happen on pod creation. I'm not convinced that an in-memory copy of data we already have, just for creates of pods, will show up on profiling, but it be a big improvement for inspectability of this code.
  • issue for reconcile-sccs to help admins update correctly.

@pmorie

pmorie commented Oct 12, 2015

Copy link
Copy Markdown
Contributor

@pweil- I think we should make ginkgo tests for origin that test the knobs for docker in conjunction with the policy. Long-term we need to have that for everything, we can start with just the scenarios being added (IE, SupplementalGroups and FSGroup). Thoughts?

@pweil-

pweil- commented Oct 12, 2015

Copy link
Copy Markdown
Author

are you proposing carrying upstream ginko tests that work with our carried scc or just adding them to security policy when it goes in the exp api?

@pmorie

pmorie commented Oct 12, 2015

Copy link
Copy Markdown
Contributor

@pweil- Short term, i'm proposing e2es for origin that are probably similar to the ones for the knobs we make upstream that work in concert w/ the origin policy but don't share code with the upstream E2Es. Ideally we would be able to intercept and decorate namespace creation in origin to set up policy but I don't want to have to work through that to solve the problem of just adding E2E for this feature in origin.

@pweil-
pweil- force-pushed the supplemental-groups branch 4 times, most recently from 6b70c77 to 92f5e78 Compare October 13, 2015 15:40
@pweil-

pweil- commented Oct 13, 2015

Copy link
Copy Markdown
Author

latest update has supplemental groups in providers and strategies along with tests (still just the last two commits)

@pweil-
pweil- force-pushed the supplemental-groups branch from 92f5e78 to 1b20829 Compare October 13, 2015 17:48
@pweil-

pweil- commented Oct 13, 2015

Copy link
Copy Markdown
Author

provider using restricted scc to default the supplemental group to the first value of the allowable range

"securityContext": {
            "supplementalGroups": [
                1000010000
            ]
        },

"GroupAdd": [
            "1000010000"
        ],

@pweil-
pweil- force-pushed the supplemental-groups branch from d198bb8 to 8263e00 Compare October 13, 2015 20:16
@pweil-

pweil- commented Oct 13, 2015

Copy link
Copy Markdown
Author

@smarterclayton @pmorie @swagiaal @liggitt - fsgroup integration is in for SCC. The last two commits in this branch are what needs eyes, the rest are changes from @pmorie and @swagiaal that will be reviewed and submitted separately.

"securityContext": {
            "supplementalGroups": [
                1000010000
            ],
            "fsGroup": 1000010000
        },

@pweil-
pweil- force-pushed the supplemental-groups branch from 8263e00 to 3521175 Compare October 14, 2015 13:38
@pweil-
pweil- force-pushed the supplemental-groups branch 5 times, most recently from d98da45 to 3892ede Compare October 14, 2015 18:08
@pweil-

pweil- commented Oct 14, 2015

Copy link
Copy Markdown
Author

@swagiaal @pmorie - a couple of things I'm noticing:

  1. There is nothing accounting for the new PodSecurityContext in the OpenShift v1beta3 code so round tripping a v1beta3 object would lose the PSC (make check is failing because the new fields aren't retained)
  2. swagger needs to be updated, when I verify on my branch it's showing changes for some of these commits
  3. gofmt on the commits is failing

@pweil-
pweil- force-pushed the supplemental-groups branch from 3892ede to 3f4f092 Compare October 15, 2015 13:04
@pweil-

pweil- commented Oct 15, 2015

Copy link
Copy Markdown
Author

took care of the feedback for making constant field names in the provider. Awaiting other reviews.

reviewers: please pay attention to the conversions. Since the upstream has diverged (it is now PSC) there is not a nice way to auto generate these so a double check would be good.

@smarterclayton

Copy link
Copy Markdown
Contributor

Add one integration test that validates that the default behavior is to allocate the group id into the container

@pweil-
pweil- force-pushed the supplemental-groups branch from 3f4f092 to 4944fc5 Compare October 19, 2015 19:51
@pweil-

pweil- commented Oct 19, 2015

Copy link
Copy Markdown
Author

added v1/v1beta3 defaults if new group strategy types are empty. Defaults will be for a restricted, namespace allocated strategy (mustRunAs with no ranges set).

added integration test that submits pods with and without requested groups and ensures the groups are allocated if necessary and that they end up on the docker host config.

@pweil-
pweil- force-pushed the supplemental-groups branch from 4944fc5 to 85dd7e7 Compare October 20, 2015 15:01
@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 22, 2015
@pweil-
pweil- force-pushed the supplemental-groups branch from 85dd7e7 to edfaecd Compare October 23, 2015 00:03
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 23, 2015
@liggitt

liggitt commented Oct 27, 2015

Copy link
Copy Markdown
Contributor

you can't run pods in integration... it doesn't start with sudo, so it can't use tmpfs

@pweil-

pweil- commented Oct 27, 2015

Copy link
Copy Markdown
Author

you can't run pods in integration... it doesn't start with sudo, so it can't use tmpfs

is the router test somehow excluded then? It starts a router pod. I thought we used the docker build flag specifically to run things with docker.

@pweil-

pweil- commented Oct 27, 2015

Copy link
Copy Markdown
Author

never mind, it starts it itself I think

edit: yup, it starts the container directly, not as a pod :-(

@pweil-
pweil- force-pushed the supplemental-groups branch from 7f93957 to 89a4f77 Compare October 27, 2015 15:01
@pweil-

pweil- commented Oct 27, 2015

Copy link
Copy Markdown
Author

modified the int test to launch the pod but then not check for the docker host config. It will now simulate what the kubelet does to craft the host config using the sc provider and checks the modified host config.

@deads2k

deads2k commented Oct 27, 2015

Copy link
Copy Markdown
Contributor

you can't run pods in integration... it doesn't start with sudo, so it can't use tmpfs

This should be fixable on jenkins, right?

@pweil-
pweil- force-pushed the supplemental-groups branch from 89a4f77 to 4eeee70 Compare October 27, 2015 17:19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This leaves me unsatisfied. I'd rather see an extended test get its pod created or fix the integration test invocation to allow running pods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if tmpfs for the SA token is the issue, you can create a volume mount at the expected SA token mount path and the SA token won't get added.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll give that a shot. Worse comes to worse I can move this to an extended test.

@pweil-
pweil- force-pushed the supplemental-groups branch from 4eeee70 to f7aa7a5 Compare October 27, 2015 20:57
@pweil-

pweil- commented Oct 27, 2015

Copy link
Copy Markdown
Author

edit: removing bad extended tag

@pweil-

pweil- commented Oct 27, 2015

Copy link
Copy Markdown
Author

@deads2k

test/extended/core.sh --focus="security" -v

=== RUN "test/extended/security/supplemental_groups.go":
... snip ...
STEP: creating a pod that requests supplemental groups
STEP: retrieving the pod and ensuring groups are set
STEP: waiting for the pod to become running
STEP: finding the docker container id on the pod
STEP: creating a docker client and inspecting the container
STEP: ensuring the groups are set
STEP: Destroying namespace "e2e-tests-security-supgroups-qzl16" for this suite.
    ok       security: supplemental groups Ensure supplemental groups propagate to docker should propagate reques ... (9.17716644s)

@pweil-

pweil- commented Oct 28, 2015

Copy link
Copy Markdown
Author

re[test][extended:core]

@pweil-

pweil- commented Oct 28, 2015

Copy link
Copy Markdown
Author

let's try this again without the bad tag....re[test]

@pweil- pweil- closed this Oct 28, 2015
@pweil- pweil- reopened this Oct 28, 2015
@pweil-

pweil- commented Oct 28, 2015

Copy link
Copy Markdown
Author

@pmorie @deads2k @swagiaal - this didn't seem to work in jenkins although it worked fine locally. I'm going to add a bit more logging to the test to try and work it out. Does anyone know the docker version that jenkins runs?

@swagiaal I recall you saying previously that if the version was too low it would just ignore the parameters.

@pweil-
pweil- force-pushed the supplemental-groups branch from cbbafe9 to 78f821d Compare October 28, 2015 17:27
@deads2k

deads2k commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

Does anyone know the docker version that jenkins runs?

@danmcp Do you know offhand?

@pweil-
pweil- force-pushed the supplemental-groups branch from 78f821d to 712d4c8 Compare October 28, 2015 17:35
@danmcp

danmcp commented Oct 28, 2015

Copy link
Copy Markdown

@pweil-
pweil- force-pushed the supplemental-groups branch from 712d4c8 to 131fe33 Compare October 28, 2015 19:12
@pweil-

pweil- commented Oct 28, 2015

Copy link
Copy Markdown
Author

@pmorie @deads2k I added a check on the extended test to check the version before running or skip. Please take a glance. New local output is showing the step for ensuring the feature is supported: https://gist.github.com/pweil-/9a783b6f4946e54e4933

quick testing for the supported method: https://play.golang.org/p/qsNpcRVnkm

@pweil-

pweil- commented Oct 28, 2015

Copy link
Copy Markdown
Author

flake timeout on jenkins in unrelated tests. re[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 131fe33

@ghost

ghost commented Oct 28, 2015

Copy link
Copy Markdown

@swagiaal I recall you saying previously that if the version was too low it would just ignore the parameters.

@pweil- that is correct

@pweil-

pweil- commented Oct 28, 2015

Copy link
Copy Markdown
Author

it is correctly skipping the test now by checking the docker version:

=== RUN "test/extended/security/supplemental_groups.go":
>>> testContext.KubeConfig: /tmp/openshift-extended-tests/core/openshift.local.config/master/admin.kubeconfig
    skip    security: supplemental groups Ensure supplemental groups propagate to docker should propagate reques ... (7.086870098s)

It failed on unrelated extended tests.

@pmorie if you want to double check the last three commits to make sure you have the latest I'm fine with closing this out in favor of your updated PR.

Final status here:

  1. LGTM from @deads2k and @soltysh on the last 3 commits
  2. New extended test will skip unsupported docker versions (clean run output above)
  3. Checklist on the top comment should migrate to @pmorie's PR. I will create follow ups and he will address other items

@soltysh

soltysh commented Oct 29, 2015

Copy link
Copy Markdown
Contributor

Add to that my LGTM 👍

@pweil-

pweil- commented Oct 29, 2015

Copy link
Copy Markdown
Author

Closing in favor of #5169 🎂

@pweil- pweil- closed this Oct 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants