Skip to content

Commit d459426

Browse files
stubbiclaude
andauthored
feat: egressPolicy passthrough (#104)
feat: egressPolicy passthrough for tenant sandbox egress posture Adds spec.adapters.execution.kubernetes.egressPolicy (allowlist|open-internet, default allowlist), emitted as PAPERCLIP_K8S_EGRESS_POLICY on the app StatefulSet, mirroring the existing egressMode passthrough. Consumed by the product's kubernetes sandbox provider (paperclipai/paperclip#9944). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0879418 commit d459426

5 files changed

Lines changed: 36 additions & 0 deletions

File tree

api/v1alpha1/paperclipinstance_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,15 @@ type K8sExecutionSpec struct {
647647
// +optional
648648
EgressMode string `json:"egressMode,omitempty"`
649649

650+
// EgressPolicy selects the overall egress posture for tenant sandboxes.
651+
// "allowlist" (default) restricts egress to EgressAllowFQDNs/EgressAllowCIDRs.
652+
// "open-internet" allows public internet on ports 80/443 while blocking
653+
// private ranges, link-local metadata, and CGNAT.
654+
// +kubebuilder:default="allowlist"
655+
// +kubebuilder:validation:Enum=allowlist;open-internet
656+
// +optional
657+
EgressPolicy string `json:"egressPolicy,omitempty"`
658+
650659
// EgressAllowFQDNs is the list of fully-qualified domain names tenant agent
651660
// pods may reach (e.g. the LLM gateway and required APIs). Enforced exactly
652661
// only under EgressMode "cilium". Maps to PAPERCLIP_K8S_EGRESS_ALLOW_FQDNS

charts/paperclip-operator/templates/crds/paperclip.inc_instances.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,17 @@ spec:
360360
- standard
361361
- cilium
362362
type: string
363+
egressPolicy:
364+
default: allowlist
365+
description: |-
366+
EgressPolicy selects the overall egress posture for tenant sandboxes.
367+
"allowlist" (default) restricts egress to EgressAllowFQDNs/EgressAllowCIDRs.
368+
"open-internet" allows public internet on ports 80/443 while blocking
369+
private ranges, link-local metadata, and CGNAT.
370+
enum:
371+
- allowlist
372+
- open-internet
373+
type: string
363374
namespacePrefix:
364375
description: |-
365376
NamespacePrefix is prepended to each derived per-tenant namespace name,

config/crd/bases/paperclip.inc_instances.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,17 @@ spec:
354354
- standard
355355
- cilium
356356
type: string
357+
egressPolicy:
358+
default: allowlist
359+
description: |-
360+
EgressPolicy selects the overall egress posture for tenant sandboxes.
361+
"allowlist" (default) restricts egress to EgressAllowFQDNs/EgressAllowCIDRs.
362+
"open-internet" allows public internet on ports 80/443 while blocking
363+
private ranges, link-local metadata, and CGNAT.
364+
enum:
365+
- allowlist
366+
- open-internet
367+
type: string
357368
namespacePrefix:
358369
description: |-
359370
NamespacePrefix is prepended to each derived per-tenant namespace name,

internal/resources/resources_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@ func k8sExecutionInstance(name string) *paperclipv1alpha1.Instance {
14551455
Backend: "job",
14561456
RuntimeClassName: "gvisor",
14571457
EgressMode: "cilium",
1458+
EgressPolicy: "open-internet",
14581459
EgressAllowFQDNs: []string{"api.anthropic.com", "gateway.example.com"},
14591460
EgressAllowCIDRs: []string{"10.0.0.0/8"},
14601461
NamespacePrefix: "pc-tenant",
@@ -1481,6 +1482,7 @@ func TestBuildExecutionEnvVars(t *testing.T) {
14811482
"PAPERCLIP_K8S_BACKEND": "job",
14821483
"PAPERCLIP_K8S_RUNTIME_CLASS_NAME": "gvisor",
14831484
"PAPERCLIP_K8S_EGRESS_MODE": "cilium",
1485+
"PAPERCLIP_K8S_EGRESS_POLICY": "open-internet",
14841486
"PAPERCLIP_K8S_EGRESS_ALLOW_FQDNS": "api.anthropic.com,gateway.example.com",
14851487
"PAPERCLIP_K8S_EGRESS_ALLOW_CIDRS": "10.0.0.0/8",
14861488
"PAPERCLIP_K8S_NAMESPACE_PREFIX": "pc-tenant",

internal/resources/statefulset.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ func buildExecutionEnvVars(instance *paperclipv1alpha1.Instance) []corev1.EnvVar
641641
if k.EgressMode != "" {
642642
vars = append(vars, corev1.EnvVar{Name: "PAPERCLIP_K8S_EGRESS_MODE", Value: k.EgressMode})
643643
}
644+
if k.EgressPolicy != "" {
645+
vars = append(vars, corev1.EnvVar{Name: "PAPERCLIP_K8S_EGRESS_POLICY", Value: k.EgressPolicy})
646+
}
644647
if len(k.EgressAllowFQDNs) > 0 {
645648
vars = append(vars, corev1.EnvVar{
646649
Name: "PAPERCLIP_K8S_EGRESS_ALLOW_FQDNS",

0 commit comments

Comments
 (0)