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

gVisor: initial support for gVisor container runtime #7661

Merged
merged 2 commits into from
Jun 21, 2021

Conversation

cristicalin
Copy link
Contributor

@cristicalin cristicalin commented May 29, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:
This PR adds support to use gVisor as a container runtime. According to the related issue, docker is missing the capability to change the RuntimeClass, so only containerd and cri-o are viable option.

This PR add support for both containerd and cri-o to configure the gVisor runtime but I have yet to be able to get cri-o to successfully launch gVisor workloads and, as per the linked issue it seems gVisor is also not fully support it either as such the validation step only allows gVisor to be enabled with containerd.

Which issue(s) this PR fixes:

Fixes #7650

Special notes for your reviewer:
I implemented molecule testing for ubuntu 20.04 and centos 8, in order to cover centos 8 I also had to move some stuff around between the docker and containerd-common roles so I can reliably test with containerd on centos.

Does this PR introduce a user-facing change?:

gVisor: add initial support for gVisor container runtime

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 29, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @cristicalin. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@cristicalin cristicalin marked this pull request as draft May 29, 2021 19:00
@k8s-ci-robot k8s-ci-robot requested review from EppO and holmsten May 29, 2021 19:00
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 29, 2021
@cristicalin cristicalin force-pushed the gvisor branch 8 times, most recently from 784b35d to 8169002 Compare May 31, 2021 14:57
@cristicalin cristicalin marked this pull request as ready for review May 31, 2021 14:59
@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 May 31, 2021
@cristicalin cristicalin force-pushed the gvisor branch 2 times, most recently from a39a4c8 to e1e1690 Compare May 31, 2021 15:44
Comment on lines +296 to +320
- name: Stop if gvisor_enabled is enabled when container_manager is not containerd
assert:
that: container_manager == 'containerd'
msg: "gvisor_enabled support only compatible with containerd. See https://github.com/kubernetes-sigs/kubespray/issues/7650 for details"
when: gvisor_enabled

Copy link
Contributor

Choose a reason for hiding this comment

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

The doc mentions cri-o too. Which one is correct?

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 updated the docs. As per @ianlewis' comment, cri-o is not currently usable though it does support setting the RuntimeClass; because of this I restricted the validation to containerd. Once gVisor adds support for cri-o, we can change this validation and the code to support it is already in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @cristicalin for this PR!

@oomichi
Copy link
Contributor

oomichi commented Jun 1, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 1, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 2, 2021
@@ -293,6 +293,12 @@
msg: "kata_containers_enabled support only for containerd and crio-o. See https://github.com/kata-containers/documentation/blob/1.11.4/how-to/run-kata-with-k8s.md#install-a-cri-implementation for details"
when: kata_containers_enabled

- name: Stop if gvisor_enabled is enabled when container_manager is not containerd
assert:
that: container_manager == 'containerd'
Copy link
Contributor

Choose a reason for hiding this comment

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

The additional lines of roles/container-engine/meta/main.yml

  - role: container-engine/gvisor
    when:
      - gvisor_enabled
      - container_manager in ['docker', 'containerd']

seem docker also can be container_manager.
I guess I am missing some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@oomichi see the discussion on #7650, initially I wanted to support all 3 of our runtimes but it turns out only containerd is well supported by gVisor today. docker is actually not able to select the RuntimeClass and cri-o support is stil not mature enough, though I'm actually hoping that might evolve in gVisor itself.

Comment on lines 58 to 62
- name: Build a list of crio runtimes with gVisor runtime
set_fact:
crio_runtimes: "{{ crio_runtimes + [gvisor_runtime] }}"
when:
- gvisor_enabled
Copy link

Choose a reason for hiding this comment

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

I assume you wouldn't need this if you aren't going to support cri-o with runsc?

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 left this part here because I'm actually hoping gVisor will eventually support cri-o when google/gvisor#193 is fixed.

Is there any intention to properly support cri-o in gVisor? If not then I will remove this part from the PR.

Copy link

Choose a reason for hiding this comment

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

I guess I'd remove it for now. cri-o will need some work in order to better support runtimes that aren't vanilla containers. It's not just a matter of supporting systemd-cgroups.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood, in this case I dropped the support for cri-o until gVisor project decides to support it.

Copy link
Contributor

@oomichi oomichi left a comment

Choose a reason for hiding this comment

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

The feature works fine for me, thanks for doing this.
/lgtm

Just a question: I'd like to know how to see OCI runtime (gvisor in this case) on kubectl. I can see containerd on kubectl describe node, but gvisor is not there.

## Usage

To enable gVisor you should be using a container manager that is compatible with selecting the [RuntimeClass](https://kubernetes.io/docs/concepts/containers/runtime-class/) such as `containerd`.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: After testing this pull request locally, I see etcd_deployment_type needs to be host to pass Stop if etcd deployment type is not host when container_manager != docker.
This thing is already written on docs/containerd.md, so I don't have strong opinion to write it here.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 18, 2021
@ianlewis
Copy link

ianlewis commented Jun 21, 2021

The feature works fine for me, thanks for doing this.
/lgtm

Just a question: I'd like to know how to see OCI runtime (gvisor in this case) on kubectl. I can see containerd on kubectl describe node, but gvisor is not there.

You can see it if you print the whole yaml via kubectl get pod x -o yaml | grep runtimeClassName or you can print it out via custom columns: kubectl get pods -o=custom-columns='NAME:.metadata.name,RUNTIME CLASS:.spec.runtimeClassName,STATUS:.status.phase'

However, I assume by OCI runtime you mean the the CRI runtime handler, and needs to be viewed on the RuntimeClass object as the RuntimeClass name and handler name can be different. So you can get the RuntimeClass from one of the kubectl get pod commands above and then look up the handler on the RuntimeClass via kubectl get runtimeclass gvisor

Copy link
Member

@floryut floryut left a comment

Choose a reason for hiding this comment

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

Nice work with that, great to see this implemented in the codebase

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cristicalin, floryut

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 Jun 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit 282a27a into kubernetes-sigs:master Jun 21, 2021
@oomichi
Copy link
Contributor

oomichi commented Jun 21, 2021

The feature works fine for me, thanks for doing this.
/lgtm
Just a question: I'd like to know how to see OCI runtime (gvisor in this case) on kubectl. I can see containerd on kubectl describe node, but gvisor is not there.

You can see it if you print the whole yaml via kubectl get pod x -o yaml | grep runtimeClassName or you can print it out via custom columns: kubectl get pods -o=custom-columns='NAME:.metadata.name,RUNTIME CLASS:.spec.runtimeClassName,STATUS:.status.phase'

However, I assume by OCI runtime you mean the the CRI runtime handler, and needs to be viewed on the RuntimeClass object as the RuntimeClass name and handler name can be different. So you can get the RuntimeClass from one of the kubectl get pod commands above and then look up the handler on the RuntimeClass via kubectl get runtimeclass gvisor

Thanks for your help, @ianlewis :-)

@sathieu
Copy link
Contributor

sathieu commented Jun 21, 2021

Thanks @cristicalin!

Quehenr added a commit to Quehenr/unstable-laboratory-infrastructure-kubespray that referenced this pull request Jun 25, 2021
* master:
  Update kubernetes-reliability.md (kubernetes-sigs#7724)
  Fix deployment without openstack cacert (kubernetes-sigs#7723)
  Clean up residual files (kubernetes-sigs#7722)
  gVisor: initial support for gVisor container runtime (kubernetes-sigs#7661)
@floryut floryut mentioned this pull request Sep 8, 2021
LuckySB pushed a commit to southbridgeio/kubespray that referenced this pull request Oct 23, 2021
…#7661)

* Docker/Containerd: move downloads urls to containerd-common

* gVisor: initial support for gVisor container runtime
sakuraiyuta pushed a commit to sakuraiyuta/kubespray that referenced this pull request Apr 16, 2022
…#7661)

* Docker/Containerd: move downloads urls to containerd-common

* gVisor: initial support for gVisor container runtime
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/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Add support for gVisor within containerd
6 participants