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

Support seccomp profile from container's security context #49178

Merged
merged 4 commits into from
Aug 14, 2017

Conversation

feiskyer
Copy link
Member

@feiskyer feiskyer commented Jul 19, 2017

What this PR does / why we need it:

Support seccomp profile from container's security context, followup of #46332.

Which issue this PR fixes

fixes #46332.

Special notes for your reviewer:

Depends on #49179. (already merged)

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 19, 2017
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Jul 19, 2017
@k8s-github-robot k8s-github-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 Jul 19, 2017
@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 19, 2017
@feiskyer
Copy link
Member Author

/unassign

@feiskyer feiskyer changed the title WIP: Support seccomp profile from container's security context Support seccomp profile from container's security context Jul 19, 2017
@feiskyer
Copy link
Member Author

/assign @yujuhong

@feiskyer feiskyer force-pushed the seccomp-impl branch 2 times, most recently from 944ed1a to f0b8578 Compare July 20, 2017 01:30
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 20, 2017
@feiskyer
Copy link
Member Author

@yujuhong Rebased. PTAL.

@feiskyer
Copy link
Member Author

/test pull-kubernetes-e2e-gce-etcd3

@feiskyer
Copy link
Member Author

feiskyer commented Aug 9, 2017

ping @yujuhong @euank

@Random-Liu Random-Liu self-assigned this Aug 10, 2017
@@ -983,7 +983,7 @@ func RunDockershim(c *componentconfig.KubeletConfiguration, r *options.Container
SupportedPortForwardProtocols: streaming.DefaultConfig.SupportedPortForwardProtocols,
}

ds, err := dockershim.NewDockerService(dockerClient, c.SeccompProfileRoot, r.PodSandboxImage,
ds, err := dockershim.NewDockerService(dockerClient, r.PodSandboxImage,
Copy link
Member

Choose a reason for hiding this comment

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

nit: Could you rearrange this a little bit? Since this line get shorter now.

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

@@ -255,3 +256,30 @@ func getSysctlsFromAnnotations(annotations map[string]string) (map[string]string

return sysctls, nil
}

// getSeccompProfileFromAnnotations gets seccomp profile from annotations.
// It gets pod's profile if containerName is null.
Copy link
Member

Choose a reason for hiding this comment

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

s/null/empty.

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

@@ -572,7 +572,7 @@ func NewMainKubelet(kubeCfg *componentconfig.KubeletConfiguration, kubeDeps *Dep
case kubetypes.DockerContainerRuntime:
// Create and start the CRI shim running as a grpc server.
streamingConfig := getStreamingConfig(kubeCfg, kubeDeps)
ds, err := dockershim.NewDockerService(kubeDeps.DockerClient, kubeCfg.SeccompProfileRoot, crOptions.PodSandboxImage,
ds, err := dockershim.NewDockerService(kubeDeps.DockerClient, crOptions.PodSandboxImage,
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

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

expectedOpts: []string{`seccomp={"foo":"bar"}`},
expectErr: false,
msg: "Seccomp localhost/test profile",
seccompProfile: "localhost/fixtures/seccomp/test",
Copy link
Member

Choose a reason for hiding this comment

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

At least add comment to explain that we are abusing localhost/ for test now, because fixtures/seccomp/test is not an absolute path.

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


return []dockerOpt{{"seccomp", b.String(), msg}}, nil
}

// getSeccompSecurityOpts gets container seccomp options from container and sandbox
// config, currently from sandbox annotations.
// getSeccompSecurityOpts gets container seccomp options from container security context.
Copy link
Member

Choose a reason for hiding this comment

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

from container seccomp profile?

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


if strings.HasPrefix(profile, "localhost/") {
name := strings.TrimPrefix(profile, "localhost/")
fname := filepath.Join(m.seccompProfileRoot, filepath.FromSlash(name))
Copy link
Member

Choose a reason for hiding this comment

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

Should add localhost/.

@Random-Liu
Copy link
Member

Random-Liu commented Aug 10, 2017

@feiskyer Several questions:

  1. runtime/default is not passed to runtime. We are passing docker/default instead.
  2. It's not defined that what empty seccomp profile means in CRI, we should explicitly define that means unconfined.

As for 1), one option is to convert docker/default to runtime/default in kuberuntime.

However, I discussed this with @yujuhong today, we think that user may really be expecting "Docker" default. We should not silently convert docker/default to runtime/default, and let runtime apply its own default, which may be different from docker's.

Ideally, we should have kubelet default, and pass this default to runtime. However, that requires Kubernetes api change.

So for now, we can only keep passing docker/default, dockershim will implement it, other runtime should just return error to fail loudly.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

3 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2017
@feiskyer
Copy link
Member Author

Made a rebase to fix the pull-kubernetes-verify problem.

@feiskyer
Copy link
Member Author

/retest

@Random-Liu
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 Aug 14, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Random-Liu, feiskyer

Associated issue: 46332

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-github-robot
Copy link

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

@feiskyer
Copy link
Member Author

@Random-Liu Thanks.

@feiskyer
Copy link
Member Author

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit b32639f into kubernetes:master Aug 14, 2017
@feiskyer feiskyer deleted the seccomp-impl branch August 14, 2017 03:26
@runcom
Copy link
Contributor

runcom commented Sep 11, 2017

So for now, we can only keep passing docker/default, dockershim will implement it, other runtime should just return error to fail loudly.

@feiskyer @Random-Liu this is not correct btw, CRI-O has its own seccomp profile which can actually be used. CRI-O isn't going to error out, but calling docker/default in the CRI (which should be abstract) is totally wrong to me. Could you please revert this? or document "every runtime can decide to honor the profile passed"?

/cc @rhatdan @mrunalp @derekwaynecarr

@k8s-ci-robot
Copy link
Contributor

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

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

In response to this:

So for now, we can only keep passing docker/default, dockershim will implement it, other runtime should just return error to fail loudly.

@feiskyer @Random-Liu this is not correct btw, CRI-O has its own seccomp profile which can actually be used. CRI-O isn't going to error out, but calling docker/default in the CRI (which should be abstract) is totally wrong to me. Could you please revert this? or document "every runtime can decide to honor the profile passed"?

/cc @rhatdan @mrunalp @derekwaynecarr

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.

@yujuhong
Copy link
Contributor

@runcom, kubelet passes the seccomp profile name from the Kubernetes API to the runtime directly. The exact profile name used in the pod annotation is docker/default in this case. It should not be an arbitrary runtime default in IMO. Without changes to the kubernetes API, I think the feasible solutions for cri-o right now would be 1) support a docker/default profile or 2) returns error if container demands docker/default.

@yujuhong
Copy link
Contributor

BTW, there is ongoing work to define a default profile for kuberentes: kubernetes/community#660

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-none Denotes a PR that doesn't merit a release note. 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.

9 participants