Skip to content

Conversation

@vicentefb
Copy link
Contributor

@vicentefb vicentefb commented Oct 20, 2025

Related to #32

This PR introduces an opinionated security for sandboxes by integrating the automated creation of K8s NetworkPolicy resources. The change is introduced in the extensions folder.

This is achieved by extending the SandboxTemplate API and implementing the corresponding lifecycle management logic within the sandboxclaim-controller. These changes ensure that all sandboxes are secure by default with a "deny-all" network posture.

Key Changes

NetworkPolicy Integration:

  • The SandboxTemplate CRD has been extended with a spec.networkPolicy section, allowing administrators to define a secure "blueprint" for sandbox networking.

  • The sandboxclaim-controller now reconciles these settings, creating a unique, "default-deny" NetworkPolicy for each SandboxClaim.

This implementation directly fulfills key security requirements:
  • Restricts pod-to-pod communication: Each sandbox gets an individual policy, ensuring it is isolated from other sandboxes.

  • Controls ingress: The policy only allows traffic from trusted sources defined in the template (e.g., an L7XLB).

  • Restricts egress: All outgoing traffic is blocked by default, except for essential DNS lookups.

  • Blocks API server access: This is a direct result of the default-deny egress posture.

Controller RBAC Updates:

  • The ClusterRole for the sandboxclaim-controller has been updated to include the necessary permissions to manage networkpolicies across the cluster.

Unit Tests:

  • Added unit tests for the NetworkPolicy translation logic, covering various ingress and egress rule configurations.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 20, 2025
@k8s-ci-robot k8s-ci-robot requested a review from justinsb October 20, 2025 22:01
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vicentefb
Once this PR has been reviewed and has the lgtm label, please assign soltysh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 requested a review from soltysh October 20, 2025 22:01
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 20, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @vicentefb. Thanks for your PR.

I'm waiting for a github.com 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 20, 2025
@netlify
Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit c437102
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/68f6d9dc6c9dc300083b7eef

@barney-s
Copy link
Contributor

Thanks for this. Looks like a good approach.

updated logging to avoid error
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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

3 participants