Repository navigation
feat(worker): run instance namespace isolation from a dedicated controller - #779
Merged
Merged
Conversation
- add InstanceComponent to the shared pod-label contract in pod_labels.go - stamp ComponentLabelKey=instance on Instance Pods so one NetworkPolicy per namespace can select every Instance Pod Task 1 of instance-network-isolation. Signed-off-by: thxCode <thxcode0824@gmail.com>
- render one tenant-isolation NetworkPolicy per namespace holding Instances, selecting the stable instance component label - ingress/egress allow same-namespace pods and external (NodePort) traffic, block every pod CIDR learned from the Nodes; DNS stays open port-scoped Task 2 of instance-network-isolation. Signed-off-by: thxCode <thxcode0824@gmail.com>
The tenant-isolation NetworkPolicy becomes opt-in and configuration-driven: the new instance-tenant-isolation-pod-cidrs Setting (blank by default) is the one source of the pod address space, so a reconcile renders the desired spec without touching Nodes or CNI CRDs, compares with semantic DeepEqual, and collects the policy again - only its own rendering, guarded by the resource-type note - when the Setting empties. Instance Pods carry the operator's resource-type label instead of the generic recommended component label, whose collision space could sweep a third-party workload into the isolation rules. Signed-off-by: thxCode <thxcode0824@gmail.com>
Network isolation in the Instance guide now states the Setting contract, the CIDR discovery paths, and that emptying the Setting collects only the operator-rendered policy; the settings reference gains the new row. Signed-off-by: thxCode <thxcode0824@gmail.com>
…oller The namespace-isolation policy moves out of the Instance reconcile into its own controller, watching Namespaces - a namespace is covered from the moment it exists, before its first Instance - and the delegated settings Secret, whose content is the Setting an extension API shows. The Setting value rides an atomic cache primed at setup and refreshed only on a real content change, so a jittery read can never masquerade as an emptied Setting and collect the policies. Reserved namespaces are never isolated, the same rule the LocalQueue entrance applies, and the policy is named gpustack-instance-isolation. The pod-CIDR Setting renames to instance-isolation-pod-cidrs along with the chart value and environment variable, and its admission moves into the setting package as AllowIPv4CIDRList next to the tracking list's DisallowListWith. Signed-off-by: thxCode <thxcode0824@gmail.com>
The settings reference states the two effect windows - Immediate (pushed by the consuming controller through the delegated settings Secret) and next trigger (the next natural event named in each row) - marks the live-read rows Immediate, and moves node-management-manual under the instance-type rows to match the Setting registry's order. Signed-off-by: thxCode <thxcode0824@gmail.com>
|
✅ OpenCodeReview: Review skipped: no items were selected. Reviewed |
…d controller Signed-off-by: thxCode <thxcode0824@gmail.com>
Collaborator
Author
|
Addressing the review round — 5 findings (2 inline + 3 summary-routed):
All gates green after the fixes: |
…d controller Signed-off-by: thxCode <thxcode0824@gmail.com>
…d controller Signed-off-by: thxCode <thxcode0824@gmail.com>
…d controller Signed-off-by: thxCode <thxcode0824@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind enhancement
/area worker
What this PR does / why we need it:
Instance pods of different tenants must not reach each other while external clients keep NodePort access. This branch ships that isolation as an opt-in feature:
Namespace-isolation policy controller (
pkg/worker/controllers/worker/instance_isolation.go) — a dedicatedInstanceIsolationReconcilerwatches Namespaces (a namespace is covered from the moment it exists, before its first Instance) and the delegated settings Secret. The pod-CIDR value rides anatomic.Valuecache primed at setup and refreshed only on a real content change, so a jittery read can never masquerade as an emptied Setting and collect the policies. Reserved namespaces are never isolated (kuberess.IsReservedNamespace, the same rule the LocalQueue entrance applies).Opt-in Setting
instance-isolation-pod-cidrs(pkg/worker/settings/value.go) — the one source of the pod address space (chartworker.instanceIsolationPodCIDRs, envGPUSTACK_INSTANCE_ISOLATION_POD_CIDRS). Blank (default) renders no policy at all; emptying the list collects the operator-rendered policy, never a same-named one written by hand. New admissions inpkg/setting:AllowIPv4CIDRListandDisallowListWith.Instance pods carry
resource.gpustack.ai/type=instances(pkg/deviceplugin/pod_labels.go) — the operator's own resource-type label selects the guarded pods, so a third-party workload stamping a generic recommended label cannot walk into the isolation rules.The policy: same-namespace in/out, external in/out via an
ipBlock 0.0.0.0/0 except <pod CIDRs>rule (how NodePort traffic arrives), DNS port-scoped; fixed namegpustack-instance-isolation.Verified on a single-node rke2 + Calico cluster:
verify-matrix.shreports ALL CHECKS PASS (9/9) — cross-namespace probes blocked in both directions, same-namespace and external access intact, and the own-node hairpin residual is closed (stronger than the spec requires). The live opt-out cycle (blank the Setting, the policies are collected; restore, they are recreated and blocking again) is exercised too.Which issue(s) this PR links to:
Addresses #778
Special notes for your reviewer:
spec.podCIDRscan disagree with what the CNI actually allocates — the docs point atkubectl get ippools.crd.projectcalico.org.docs/reference/settings.mdstates the two effect windows (Immediate / next trigger) for settings; the new setting is Immediate.Does this PR introduce a user-facing change?