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

Enable gvisor addon in minikube #3399

Merged
merged 27 commits into from
Dec 7, 2018
Merged

Conversation

priyawadhwa
Copy link

@priyawadhwa priyawadhwa commented Dec 4, 2018

This PR adds the code for enabling gvisor in minikube. It adds the pod
that will run when the addon is enabled, and the code for the image
which will run when this happens.

When gvisor is enabled, the pod will download runsc and the
gvisor-containerd-shim. It will replace the containerd config.toml and
restart containerd.

When gvisor is disabled, the pod will be deleted by the addon manager.
This will trigger a pre-stop hook which will revert the config.toml to
it's original state and restart containerd.

TODO:

  • Add integration test
  • Add docs
  • Fail sanely when using a runtime that isn't containerd

Priya Wadhwa added 6 commits December 3, 2018 12:10
This PR adds the code for enabling gvisor in minikube. It adds the pod
that will run when the addon is enabled, and the code for the image
which will run when this happens.

When gvisor is enabled, the pod will download runsc and the
gvisor-containerd-shim. It will replace the containerd config.toml and
restart containerd.

When gvisor is disabled, the pod will be deleted by the addon manager.
This will trigger a pre-stop hook which will revert the config.toml to
it's original state and restart containerd.
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 4, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: priyawadhwa
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: dlorenc

If they are not already assigned, you can assign the PR to them by writing /assign @dlorenc in a comment when ready.

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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 4, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 4, 2018
@tstromberg
Copy link
Contributor

@minikube-bot OK to test

hyperkit issue seems interesting, but more likely due to the recently merged #3332

deploy/addons/gvisor/gvisor-containerd-shim.toml Outdated Show resolved Hide resolved
pkg/gvisor/enable.go Outdated Show resolved Hide resolved
pkg/gvisor/enable.go Outdated Show resolved Hide resolved
docs/gvisor.md Outdated Show resolved Hide resolved
docs/gvisor.md Outdated
To run a pod in gVisor, add this annotation to the Kubernetes yaml:

```
io.kubernetes.cri.untrusted-workload: "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is because we are still using containerd 1.1 right?

deploy/addons/gvisor/gvisor-config.toml Outdated Show resolved Hide resolved
deploy/addons/gvisor/config.toml Outdated Show resolved Hide resolved
docs/gvisor.md Outdated Show resolved Hide resolved
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: Reconcile
spec:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Consider setting terminationGracePeriodSeconds to something sane but less than 30s (an upper bound for what the preStop hook should take to run). AFAICT deleting the pod will take the full 30s since we are just sleeping for 1y

Copy link
Author

Choose a reason for hiding this comment

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

I ended up removing the prestop hook because it wasn't consistently running without errors; I've changed the code to intercept the SIGTERM kill signal and disable gvisor then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. that should work

Instead of checking in default config.toml, save it at /tmp/config.toml
on the node upon enable and copy it back upon disable.

Also, instead of using the prestop hook, intercept the SIGTERM kill signal upon pod
termination, disable gvisor, and then exit with code 0. This should work
better because now we will be able to see the logs from disabling, and
because the prestop hook wouldn't consistenly run the disable command
and clean up the pod correctly.
@balopat
Copy link
Contributor

balopat commented Dec 4, 2018

@minikube-bot OK to test

Priya Wadhwa added 4 commits December 4, 2018 14:09
When enabling gvisor, first validate that the container runtime is
containerd.
Added integration test which follows these steps:

1. enable gvisor
2. make sure untrusted workload runs correctly
3. disable gvisor
4. make sure untrusted workload results in FailedCreateSandboxEvent
event

I also added a link to the iso url for starting containerd until the
integration tests start using the new version of the iso.
@priyawadhwa priyawadhwa changed the title [WIP] Enable gvisor addon in minikube Enable gvisor addon in minikube Dec 5, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2018
deploy/addons/gvisor/README.md Show resolved Hide resolved
deploy/addons/gvisor/README.md Show resolved Hide resolved
pkg/gvisor/enable.go Outdated Show resolved Hide resolved
@tstromberg
Copy link
Contributor

@minikube-bot OK to test

@balopat balopat dismissed their stale review December 6, 2018 16:42

We have to fix the test failures first

@priyawadhwa priyawadhwa force-pushed the gvisoraddon branch 2 times, most recently from 022122a to adf2b61 Compare December 6, 2018 19:52
@balopat
Copy link
Contributor

balopat commented Dec 7, 2018

@minikube-bot OK to test

@priyawadhwa
Copy link
Author

@minikube-bot OK to test

@priyawadhwa
Copy link
Author

@minikube-bot OK to test

@balopat
Copy link
Contributor

balopat commented Dec 7, 2018

Known flakes: #3381
#3421
Merging.

@balopat balopat self-requested a review December 7, 2018 23:26
@balopat balopat merged commit 8f128a7 into kubernetes:master Dec 7, 2018
@priyawadhwa priyawadhwa deleted the gvisoraddon branch December 7, 2018 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants