Repository navigation
feat(helm)!: camelCase keys and NetworkPolicies - #128
Conversation
Rename the chart's values keys that did not follow Helm's naming conventions (camelCase, as in the other keys of the chart): `host_name` is now `hostName`, `cloud_registry` is now `cloudRegistry`. Templates, helpers, the values schema, the CI values, tests and docs use the new keys. Old keys would be ignored silently, so rendering fails while one is set, naming the new key. The legacy `appName` is rejected under both keys. The chart version is derived from the release tag, so it needs no bump. BREAKING CHANGE: values files must rename `host_name` to `hostName` and `cloud_registry` to `cloudRegistry`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Restrict connections to the chart's pods (ingress only) with NetworkPolicies, for clusters whose network plugin enforces them (others ignore them): - MongoDB (`mongodb.networkPolicy.enabled`, default `true`): only the app's pods of the same release may connect, on MongoDB's port, selected by the chart's labels. - App (`cloudRegistry.networkPolicy.enabled`, default `false`): only the peers in `cloudRegistry.networkPolicy.ingressFrom` may connect, on the app's port; the default allows the namespace `ingress-nginx`. It is opt-in, as the peers must match the cluster's ingress controller. Rendering fails without peers, which would allow all sources. Egress is not restricted: the app connects to MongoDB and to the token issuers (OpenID Connect discovery, JWKS). The probes need no rule, as connections from the pod's node are always allowed. The deployment docs and the release notes describe the policies and how to set `ingressFrom` or disable them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe chart migrates its public values interface to Sequence diagram for Helm rendering validationsequenceDiagram
participant Operator
participant Helm
participant Validate as cloud-registry.validate
participant Templates
Operator->>Helm: helm template or helm upgrade
Helm->>Validate: render validation
alt obsolete host_name or cloud_registry exists
Validate-->>Helm: fail with renamed key message
Helm-->>Operator: rendering fails
else legacy appName exists
Validate-->>Helm: fail with appName message
Helm-->>Operator: rendering fails
else values use hostName and cloudRegistry
Validate->>Templates: continue rendering
Templates-->>Helm: Kubernetes manifests
Helm-->>Operator: rendered chart
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #128 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 9 -1
Lines 775 704 -71
=========================================
- Hits 775 704 -71 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="deployment/templates/cloud-registry-networkpolicy.yaml" line_range="25-27" />
<code_context>
```yaml
-cloud_registry:
+cloudRegistry:
ingress:
annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
</code_context>
<issue_to_address>
**Existing policies broaden app access**
When another NetworkPolicy selects the app pods and allows additional ingress sources, kubernetes unions ingress permissions from every NetworkPolicy selecting these pods, so this rule does not block sources allowed by another policy; clients outside `ingressFrom` can still reach the app.
Clarify that NetworkPolicies are additive and advise checking all policies that select the app pods when relying on this restriction.
</issue_to_address>
### Comment 2
<location path="deployment/values.yaml" line_range="91" />
<code_context>
+ # than the default, which allows all pods of that namespace)
+ - namespaceSelector:
+ matchLabels:
+ kubernetes.io/metadata.name: ingress-nginx
+ podSelector:
+ matchLabels:
</code_context>
<issue_to_address>
**Ingress is blocked on older clusters**
When the app NetworkPolicy is enabled on a Kubernetes cluster older than v1.21 and its ingress namespace lacks the `kubernetes.io/metadata.name` label, the default `namespaceSelector` matches no namespace when the cluster does not automatically label namespaces with `kubernetes.io/metadata.name`; enabling the app policy then isolates the app from ingress-nginx and makes it unreachable through the Ingress.
Document and validate the minimum Kubernetes version for enabling this default, or provide a supported ingress namespace selector for clusters without the automatic label.
</issue_to_address>
### Comment 3
<location path="deployment/templates/cloud-registry-networkpolicy.yaml" line_range="27" />
<code_context>
+ - Ingress
+ ingress:
+ - from:
+ {{- toYaml $from | nindent 4 }}
+ ports:
+ - port: 8080
</code_context>
<issue_to_address>
**Malformed peers fail installation**
When the app policy is enabled and an `ingressFrom` entry has an invalid `NetworkPolicyPeer`, such as an `ipBlock` without `cidr` or combined with a selector, `toYaml` emits the peer unchanged, so Kubernetes rejects the NetworkPolicy and the Helm install or upgrade fails.
Validate `ingressFrom` entries as valid Kubernetes `NetworkPolicyPeer` values before rendering.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and on clusters that enforce NetworkPolicies, MongoDB will accept connections only from this release’s app pods, which can interrupt backup jobs or other clients; enabling the app policy with peers that don’t match the cluster’s ingress controller can also make the app unreachable. Reverting restores the prior connectivity, but cannot undo downtime that occurred while the policies were active.
Blocking findings: deployment/templates/cloud-registry-networkpolicy.yaml:27, deployment/values.yaml:91, deployment/templates/cloud-registry-networkpolicy.yaml:27
Address the review of the NetworkPolicies: - The schema rejects `ipBlock` peers without `cidr`, with unknown fields or combined with selectors, which Kubernetes would reject at install time. - The docs note that NetworkPolicies add up (other policies selecting the chart's pods can widen access) and that the default `ingressFrom` relies on the `kubernetes.io/metadata.name` label, set on all namespaces from Kubernetes 1.21. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reject empty `except` entries and unknown `ipBlock` fields (tested), and say exactly what the schema checks of `ingressFrom` peers instead of claiming it catches all peers Kubernetes would reject. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Two chart changes decided for 0.3.0:
feat(helm)!: use camelCase values keys: renames the values keyshost_nametohostNameandcloud_registrytocloudRegistry(Helm conventions) in the values, schema, templates, helpers, CI values, tests and docs. Rendering fails while an old key is set, naming the new key (incloud-registry.validate); the legacyappNameis rejected under both keys. The chart version needs no bump: it is derived from the release tag (version: 0.0.0placeholder, release workflowchart_version).feat(helm): add NetworkPolicies(ingress only, no egress policy, as the app must reach MongoDB and the OIDC issuers/JWKS):mongodb.networkPolicy.enabled: true(default): only the app's pods of the same release (chart selector labels) may connect to MongoDB on 27017.cloudRegistry.networkPolicy.enabled: false(default, opt-in),cloudRegistry.networkPolicy.ingressFrom(NetworkPolicy peers, defaultnamespaceSelectorkubernetes.io/metadata.name: ingress-nginx): only those peers may connect to the app on 8080. Rendering fails without peers (an emptyfromwould allow all sources); the schema only allowspodSelector,namespaceSelectorandipBlockin peers.deployment/README.mdgets a "Network policies" section (what's protected, clusters without enforcement ignore the policies,kubectl execis unaffected, how to enable the app policy and matchingressFromto the ingress controller or OpenShift router, host-network controllers);docs/releases/0.3.0.mdgets upgrade notes and breaking-change entries for the rename and the policies. The feat: grant roles on services to groups #105 TODO is unchanged.Verification
coverage run --source cloud_registry -m pytest -W ignore::DeprecationWarning(Python 3.10): 696 passed;coverage report: 100 %pytest(Python 3.12): 696 passedhelm lint deployment --strict -f deployment/ci/test-values.yaml, also with--set mongodb.auth.enabled=false --set mongodb.auth.existingSecret=: 0 charts failed (Helm 3.18.6)helm templatewith the app policy enabled, withingressFrom=nulland[]: renders / fails as expectedruff check .,ruff format --check .,mypy,ast-grep scan,ast-grep test,semgrep --config .semgrep --error: no findingsDeclined review findings
--reset-then-reuse-valuesnext to--reuse-valuesin the rename message and docs (low, cosmetic): rendering still fails safely with the rename message; the docs already explain why stored values bring the old keys back.except: null(or selectors set tonull) iningressFrompeers is rejected by the schema, although Kubernetes treats null as unset (low): the error is clear and the fix is trivial for users.Open questions
None.
🤖 Generated with Claude Code