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

Ensure Akri's Helm templates use the most restrictive settings suggested by Snyk report #547

Merged
merged 19 commits into from Feb 23, 2023

Conversation

harrison-tin
Copy link
Collaborator

What this PR does / why we need it:
This PR explicitly sets more SecurityContext rather than using default in the helm templates, using Akri's Snyk report for guidance. The templates changed are:

  1. agent: added more securityContext
  2. controller: added more securityContext
  3. anomaly-detection-app: added more securityContext and resource limits
  4. video-streaming-app: added more securityContext and resource limits

Special notes for your reviewer:

If applicable:

  • this PR has an associated PR with documentation in akri-docs
  • this PR contains unit tests
  • added code adheres to standard Rust formatting (cargo fmt)
  • code builds properly (cargo build)
  • code is free of common mistakes (cargo clippy)
  • all Akri tests succeed (cargo test)
  • inline documentation builds (cargo doc)
  • all commits pass the DCO bot check by being signed off -- see the failing DCO check for instructions on how to retroactively sign commits

harrison-tin and others added 9 commits November 15, 2022 16:45
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

I think we need to open up the Agent as it needs privileged access. This requires running this workflow locally and inspecting kubelet logs for errors journalctl -fu kubelet

deployment/samples/akri-anomaly-detection-app.yaml Outdated Show resolved Hide resolved
deployment/helm/values.yaml Show resolved Hide resolved
# ensures container doesn't run with unnecessary priviledges
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests are failing because tests are writing a file in the agent pod:

os.system('sudo {} exec -i {} -- /bin/sh -c "echo "OFFLINE" > /tmp/debug-echo-availability.txt"'.format(kubectl_cmd, shared_test_code.agent_pod_name))

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point! Maybe we add that file as a volume mount for the Pod during the test

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the securityContext and removed readOnlyRootFilesystem

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure i understand how this was resolved. Looks like readOnlyRootFilesystem: true still exists which is ideal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the above highlight is outdated? Here shows the updated security context for akri agent. I removed setting readOnlyRootFilesystem to true (followed what nvidia gpu device plugin did)

Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: Harrison Tin <harrisontin@microsoft.com>
Signed-off-by: harrison <harrisontin@microsoft.com>
Signed-off-by: harrison <harrisontin@microsoft.com>
Signed-off-by: harrisontin <harrisontin@microsoft.com>
Signed-off-by: harrisontin <harrisontin@microsoft.com>
Copy link
Contributor

@kate-goldenring kate-goldenring 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 putting this together! We may want to do a round two at some point with the discovery handlers. If you pull in the latest from main, tests should pass. We may need to bump version depending on whether this goes in before #556

@harrison-tin harrison-tin merged commit c423c6e into project-akri:main Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants