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

Add option to use containerd snapshotter to generate SBOMs #1290

Merged
merged 7 commits into from
Jan 12, 2024

Conversation

lebauce
Copy link
Contributor

@lebauce lebauce commented Jan 11, 2024

What this PR does / why we need it:

This PR set up container image scanning using the containerd snapshotter.
To do so, it bind mounts the containerd folder and adds the required
capability to mount container images. This is intended to be used when
facing the discard_uncompress_layers issue with containerd.

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

  • fixes #

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • Chart Version bumped
  • Documentation has been updated with helm-docs (run: .github/helm-docs.sh)
  • CHANGELOG.md has been updated
  • Variables are documented in the README.md
  • For Datadog Operator chart or value changes update the test baselines (run: make update-test-baselines)

@lebauce lebauce requested a review from a team as a code owner January 11, 2024 09:24
Comment on lines 6 to 9
{{- if .Values.datadog.sbom.containerImage.uncompressedLayersSupport -}}
{{- $capabilities := dict "capabilities" (dict "add" (list "SYS_ADMIN")) }}
{{ include "generate-security-context" (dict "securityContext" (merge $capabilities .Values.agents.containers.agent.securityContext) "targetSystem" "foobar" "seccomp" "" "kubeversion" .Capabilities.KubeVersion.Version) | indent 2 }}
{{- else }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

we already have a function generate-security-context that tune the securityContext. Can we add this logic to the function too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@clamoriniere clamoriniere left a comment

Choose a reason for hiding this comment

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

Hi @lebauce

I made some comments. Also could you add or CI example in https://github.com/DataDog/helm-charts/tree/main/charts/datadog/ci
to make sure that the securityContext capability merge function works as expected 🙇

Also I think if this new option in enabled and the customer is also using the appArmor option we should add the specific appArmor annotation to the agent container.

@lebauce lebauce force-pushed the lebauce/csm-vm-container-image-mount branch from e892634 to b9729af Compare January 11, 2024 17:33
@lebauce
Copy link
Contributor Author

lebauce commented Jan 11, 2024

@clamoriniere I have little knowledge regarding apparmor. Could you please provide the annotations that should be added ?

@lebauce lebauce requested a review from clamoriniere January 11, 2024 17:41
@lebauce lebauce force-pushed the lebauce/csm-vm-container-image-mount branch 2 times, most recently from 099d643 to e91e7c1 Compare January 11, 2024 19:57
Copy link
Collaborator

@clamoriniere clamoriniere left a comment

Choose a reason for hiding this comment

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

added a small suggestion for the annotation condition.
Also please add test case in the ci folder 🙇

@clamoriniere
Copy link
Collaborator

@clamoriniere I have little knowledge regarding apparmor. Could you please provide the annotations that should be added ?

Sorry, I just saw your message. I think you found it.

@clamoriniere clamoriniere added chart/datadog This issue or pull request is related to the datadog chart enhancement New feature or request labels Jan 11, 2024
@lebauce lebauce force-pushed the lebauce/csm-vm-container-image-mount branch from e91e7c1 to 3744e19 Compare January 11, 2024 21:00
@lebauce lebauce requested a review from clamoriniere January 11, 2024 21:07
Copy link
Collaborator

@clamoriniere clamoriniere left a comment

Choose a reason for hiding this comment

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

Thanks for all the updates

# This should be set to true when using EKS, GKE or if containerd is configured to
# discard uncompressed layers.
# This feature will cause the SYS_ADMIN capability to be added to the Agent container.
uncompressedLayersSupport: false
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the option name does not exactly represent what it does. Using mount has different facets (more performant, more permissions, etc.) and perhaps in the future we'll have another way to support uncompressed layers while still offering the mount option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intended: the idea of this flag is more to make the feature work in the case of discarded layers. This will allow us to more to a better solution in the future. Naming it mountImages would make the migration more complex as we wouldn't know if the feature was specifically request or if it's because it was used as a workaround.
Does it make sense ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense to have a dedicated uncompressedLayersSupport that activates useMount. What does not make sense is that useMount does not exist.

I know we did not advertise this option before, but I believe it should have its own existence and we could put in the docstring that uncompressedLayersSupport implies useMount, with the proper explanation on useMount

Copy link
Collaborator

@clamoriniere clamoriniere Jan 12, 2024

Choose a reason for hiding this comment

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

lets continue this discussion about the useMount option or equivalent for another PR, and merge this one. so we can provide an easy configuration for users already

@clamoriniere clamoriniere force-pushed the lebauce/csm-vm-container-image-mount branch from aae454f to 3ab20a4 Compare January 12, 2024 11:29
@clamoriniere clamoriniere merged commit 71ccb3c into main Jan 12, 2024
14 checks passed
@clamoriniere clamoriniere deleted the lebauce/csm-vm-container-image-mount branch January 12, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chart/datadog This issue or pull request is related to the datadog chart enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants