Skip to content

fix(helm): use the container ports in the NetworkPolicy ingress rule - #2096

Open
lbarrosby wants to merge 1 commit into
bitnami:mainfrom
lbarrosby:fix/chart-netpol-container-ports
Open

lbarrosby wants to merge 1 commit into
bitnami:mainfrom
lbarrosby:fix/chart-netpol-container-ports

Conversation

@lbarrosby

Copy link
Copy Markdown

Description of the change

The NetworkPolicy ingress rule used service.port and metrics.service.port. NetworkPolicy ports are matched against the port on the pod (after the Service translates it), so they need to be the container ports. This switches the rule to containerPorts.http and containerPorts.metrics, with the same 8080/8081 fallbacks the Deployment uses.

Benefits

With networkPolicy.enabled: true:

  • service.port: 80 (or any Service port other than 8080) rendered port: 80 in the policy, so traffic to the controller on 8080 was dropped and kubeseal could not reach it.
  • Changing containerPorts.http/containerPorts.metrics was never reflected in the policy.

Possible drawbacks

None expected. With default values the rendered policy is identical (8080/8081 either way).

Applicable issues

Additional information

Checked with helm template:

  • defaults, egress enabled, and policy disabled render identically before and after
  • service.port=80,metrics.service.port=9000: policy had 80/9000, now 8080/8081 (matching the Deployment's containerPorts)
  • containerPorts.http=9090,containerPorts.metrics=9091: policy now has 9090/9091

helm lint and kubeconform -strict pass.

NetworkPolicy ports match the port on the pod, not the Service port.
The rule used service.port and metrics.service.port, so changing either
Service port (or containerPorts) left the controller's real ports
blocked.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant