[go: nahoru, domu]

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

genpolicy: Add optional toggle to pull images using containerd #9185

Conversation

Redent0r
Copy link
Contributor
@Redent0r Redent0r commented Feb 28, 2024

Fixes: #9144

Add an optional flag that allows you to use existing containerd installation to pull and manage images.

This improvement will:

  • Add support to images with v1 manifest, such as bprashanth/nginxhttps:1.0
  • Support images with any layer media type that is supported by containerd, such as application/vnd.docker.distribution.manifest.v1+prettyjws from image registry.k8s.io/galera-install:0.1
  • Fix issue with current method where sometimes you get API throttled when pulling layers individually

@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch from a4dbfb2 to 77651e6 Compare February 28, 2024 22:36
@katacontainersbot katacontainersbot added the size/huge Largest and most complex task (probably needs breaking into small pieces) label Feb 28, 2024
@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch 6 times, most recently from 0720ab5 to 2831777 Compare February 29, 2024 22:53
@Redent0r
Copy link
Contributor Author

Able to pass tests locally using AUTO_GENERATE_POLICY=yes ./run_kubernetes_tests.sh

@Redent0r Redent0r marked this pull request as ready for review February 29, 2024 23:05
@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch 2 times, most recently from 50f253c to 95e326a Compare March 4, 2024 20:13
Copy link
Contributor
@sprt sprt left a comment

Choose a reason for hiding this comment

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

@Redent0r
Copy link
Contributor Author
Redent0r commented Mar 4, 2024

Could you fix your commits according to this? https://github.com/kata-containers/community/blob/main/CONTRIBUTING.md#patch-format

Yep! I'm iterating and trying changes to pass the ci tests. I'll squash those changes into a commit with correct format when I'm done

@sprt sprt marked this pull request as draft March 5, 2024 16:55
@sprt
Copy link
Contributor
sprt commented Mar 5, 2024

Gotcha, I just converted this to a draft while you work on it then. Feel free to take it out of draft when it's ready!

@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch 7 times, most recently from 08c7e87 to 0c33538 Compare March 7, 2024 17:17
@Redent0r Redent0r marked this pull request as ready for review March 7, 2024 19:34
@Redent0r Redent0r requested a review from sprt March 7, 2024 22:06
Copy link
Member
@danmihai1 danmihai1 left a comment

Choose a reason for hiding this comment

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

Generally, looks good and useful to me, thanks @Redent0r !

Please squash into a single commit.

src/tools/genpolicy/src/registry_containerd.rs Outdated Show resolved Hide resolved
tests/integration/kubernetes/k8s-pod-v1.bats Outdated Show resolved Hide resolved
tests/integration/kubernetes/k8s-pod-v1.bats Outdated Show resolved Hide resolved
tests/integration/kubernetes/tests_common.sh Outdated Show resolved Hide resolved
src/tools/genpolicy/src/utils.rs Show resolved Hide resolved
Copy link
Contributor
@sprt sprt left a comment

Choose a reason for hiding this comment

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

Thank you Saul! 🙂 We may have an issue with the workflow change, see my comments.

Also a few tips for this and upcoming PRs:

  • Keep in mind that people will review your PRs commit by commit so keep each commit atomic: avoid adding code that is removed in a later commit.
  • Add a short description to each of your commit. Not a continuation of your commit title, but something that explains the commit title. Focus on the why if it's not obvious.
  • When you're applying automatted formatting changes, do that in a separate commit from an actual code change. Otherwise reviewers spend time getting distracted by purely cosmetic diff lines.

src/tools/genpolicy/src/registry.rs Outdated Show resolved Hide resolved
src/tools/genpolicy/Cargo.toml Show resolved Hide resolved
src/tools/genpolicy/src/registry_containerd.rs Outdated Show resolved Hide resolved
src/tools/genpolicy/src/registry_containerd.rs Outdated Show resolved Hide resolved
tests/integration/kubernetes/k8s-pod-v1.bats Outdated Show resolved Hide resolved
tests/integration/kubernetes/k8s-pod-v1.bats Outdated Show resolved Hide resolved
tests/integration/kubernetes/k8s-pod-v1.bats Outdated Show resolved Hide resolved
tests/integration/kubernetes/gha-run.sh Outdated Show resolved Hide resolved
.github/workflows/build-checks.yaml Show resolved Hide resolved
terminationGracePeriodSeconds: 0
containers:
- name: nginxhttps
image: "docker.io/ymqytw/nginxhttps:1.5"
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure docker.io is acceptable for CI testing. Let's see if more experienced reviewers have better ideas here - I will ping them after we agree on the rest of the changes.

Looks like pod-file-volume.yaml is using docker too - so maybe it is acceptable.

Copy link
Member

Choose a reason for hiding this comment

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

@GabyCT @fidencio , do have to avoid CI testing using a container from docker.io?

The only similar test seems to be pod-file-volume.yaml (a.k.a. k8s-file-volume.bats). I noticed that most other tests are using images from quay.io.

Thanks!

tests/integration/kubernetes/run_kubernetes_tests.sh Outdated Show resolved Hide resolved
Redent0r added a commit to microsoft/kata-containers that referenced this pull request Apr 1, 2024
… host_os

Also adds new test matrix entry. This improves test coverage for PR kata-containers#9185.

Fixes: kata-containers#9384

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch 4 times, most recently from 30811aa to b73998f Compare April 5, 2024 07:36

export AUTO_GENERATE_POLICY="yes"

# set default containerd config
Copy link
Member

Choose a reason for hiding this comment

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

@GabyCT @fidencio , this looks reasonable to me - but pointing it out to you just in case I am missing something important.

@@ -131,6 +131,9 @@ create_common_genpolicy_settings() {

# Set the default namespace of Kata CI tests in the genpolicy settings.
set_namespace_to_policy_settings "${genpolicy_settings_dir}" "${TEST_CLUSTER_NAMESPACE}"

# allow genpolicy to access containerd without sudo
sudo chmod a+rw /var/run/containerd/containerd.sock
Copy link
Member

Choose a reason for hiding this comment

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

@GabyCT @fidencio this looks reasonable to me - please speak up in case you disagree.

@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch from b73998f to 2cafed4 Compare April 5, 2024 20:10
@Redent0r
Copy link
Contributor Author
Redent0r commented Apr 5, 2024

Force pushed to fix typo: GENPOLICT -> GENPOLICY

Add optional toggle to use existing containerd installation to pull and manage container images.
This adds support to a wider set of images that are currently not supported by standard pull method,
such as those that use v1 manifest.

Fixes: kata-containers#9144

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch 4 times, most recently from bbbed96 to cfe6986 Compare April 8, 2024 20:02
@danmihai1
Copy link
Member

/test

- Add v1 image test case
- Install protobuf-compiler in build check
- Reset containerd config to default in kubernetes test if we are testing genpolicy
- Update docker_credential crate
- Add test that uses default pull method
- Use GENPOLICY_PULL_METHOD in test

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
@Redent0r Redent0r force-pushed the saulparedes/genpolicy_add_containerd_pull branch from cfe6986 to 51498ba Compare April 9, 2024 02:28
@danmihai1
Copy link
Member

/test

@danmihai1 danmihai1 merged commit ea31df8 into kata-containers:main Apr 9, 2024
291 of 300 checks passed
@Redent0r Redent0r deleted the saulparedes/genpolicy_add_containerd_pull branch April 9, 2024 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test size/huge Largest and most complex task (probably needs breaking into small pieces)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

genpolicy: add optional toggle to pull images using containerd
5 participants