feat(netpols): ship the Harbor database allow-rule - #3474
Conversation
Under default-deny the CloudNativePG operator can't poll the Harbor Postgres instances for status (8000) or metrics (9187) across namespaces, so the replica never starts and the stack stalls: Instance Status Extraction Error → ClusterIsNotReady → Degraded. As with the other gaps, nothing in that symptom points at a NetworkPolicy. Adds `netpols.harborDb`, driven by `apps.harbor.networkPolicies.enabled` (default false) and only rendered when harbor is enabled. The policy is scoped to the harbor-otomi-db instances rather than the whole harbor namespace. Harbor's component surface is wide — core, jobservice, registry, trivy, exporter, redis — and a namespace-wide Ingress policy would have to enumerate all of it correctly or take the registry down. The database is where the documented gap is, so that is what this selects. Alongside the operator it allows the harbor namespace itself (components reaching Postgres, instances replicating to each other) and prometheus on 9187, so enabling the policy doesn't trade one silent breakage for another. Refs linode#3387
There was a problem hiding this comment.
🟡 Not ready to approve
The new Harbor DB NetworkPolicy currently allows all ports from some sources due to missing ports fields, which broadens access beyond what the comments describe and should be tightened or clarified before merge.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds an opt-in NetworkPolicy allow-rule to unblock CloudNativePG’s cross-namespace access to Harbor’s Postgres instances when clusters run default-deny policies, aligning with the ongoing effort to close known default-deny gaps.
Changes:
- Introduces
netpols.harborDbtoggle, driven byapps.harbor.networkPolicies.enabledand gated on Harbor being enabled. - Extends the values schema and defaults to include
apps.harbor.networkPolicies. - Adds a Harbor DB–scoped NetworkPolicy template allowing CNPG operator polling and Prometheus metrics scraping.
File summaries
| File | Description |
|---|---|
| values/apl-network-policies/apl-network-policies.gotmpl | Adds netpols.harborDb flag derived from Harbor enablement + networkPolicies toggle. |
| values-schema.yaml | Allows apps.harbor.networkPolicies via appNetworkPolicyConfig. |
| helmfile.d/snippets/defaults.yaml | Sets Harbor networkPolicies.enabled: false by default. |
| charts/apl-network-policies/values.yaml | Documents the new Harbor DB allow-rule behavior and gating. |
| charts/apl-network-policies/templates/networkpolicies/harbor-db.yaml | New NetworkPolicy scoped to CNPG Harbor DB pods to permit operator/metrics access under default-deny. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| - from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| name: cnpg-system | ||
| # Allow the Harbor components (core, jobservice, registry, exporter, trivy) to reach Postgres, | ||
| # and the instances to reach each other for replication. | ||
| - from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| name: harbor |
There was a problem hiding this comment.
🟢 Ready to approve
The changes are small, consistent with existing apl-network-policies patterns (namespace label selectors, per-app toggles), and implement the described allow-rule without expanding policy scope beyond the Harbor DB pods.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
📌 Summary
Third of #3387, after #3470 (ESO webhook) and #3473 (cert-manager-webhook-linode).
Under default-deny the CloudNativePG operator can't poll the Harbor Postgres instances for status (8000) or metrics (9187) across namespaces, so the replica never starts and the stack stalls:
Instance Status Extraction Error→ClusterIsNotReady→Degraded. As with the other gaps, nothing in that symptom points at a NetworkPolicy.Adds
netpols.harborDb, driven byapps.harbor.networkPolicies.enabled(default false), rendered only when harbor is enabled.🔍 Reviewer Notes
podSelector: {}for its whole namespace, and I did not copy that here. Harbor's component surface is wide (core, jobservice, registry, trivy, exporter, redis) and a namespace-wideIngresspolicy would have to enumerate every legitimate flow correctly or take the registry down. The documented gap is the database, socnpg.io/cluster: harbor-otomi-dbis what this selects.harbor-otomi-dbin namespaceharbor(helmfile-03.databases.yaml.gotmpl), consumed asharbor-otomi-db-rw.harbor.svc.cluster.local(values/harbor/harbor.gotmpl); operator namespacecnpg-system(helmfile-02.init.yaml.gotmpl).helm lintclean both ways.Remaining #3387 gaps after this
kubernetesService maps 443→targetPort 6443 and Cilium evaluates policy after kube-proxy-replacement DNAT, so a rule allowing only 443 is silently dropped. Probably its own issue rather than part of this series.🧹 Checklist
helm lint/helm template