Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid network policy when using allUdp and allTcp #2176

Open
emagiz opened this issue Jul 4, 2024 · 0 comments
Open

Invalid network policy when using allUdp and allTcp #2176

emagiz opened this issue Jul 4, 2024 · 0 comments
Labels
bug Something isn't working @component/cdk8s-plus Issue related to cdk8s-plus effort/small 1 day tops priority/p1 Should be on near term plans

Comments

@emagiz
Copy link

emagiz commented Jul 4, 2024

Description of the bug:

When using ports: [kplus.NetworkPolicyPort.allTcp(), kplus.NetworkPolicyPort.allUdp()] when rendering a NetworkPolicy, it will generate a manifest like

[{\"endPort\":65535,\"port\":0,\"protocol\":\"TCP\"},{\"endPort\":65535,\"port\":0,\"protocol\":\"UDP\"}]

However, when applying this to AWS, the following error is generated
The NetworkPolicy "mynetworkpolicy" is invalid: \n* spec.egress[0].ports[0].port: Invalid value: 0: must be between 1 and 65535, inclusive\n* spec.egress[0].ports[1].port: Invalid value: 0: must be between 1 and 65535, inclusive

This seems to originate from: https://github.com/cdk8s-team/cdk8s-plus/blob/k8s-29/main/src/network-policy.ts#L60

Reproduction Steps:

const NetworkPolicy = new kplus.NetworkPolicy(
      scope,
      `allow-ns-np`,
      {
        metadata: {
          namespace: "mynamespace",
        },
        egress: {
          rules: [
            {
              peer: kplus.Namespaces.select(
                scope,
                `allow-ns-np-mynamespace-select`,
                { names: ["mynamespace"] }
              ),
              ports: [kplus.NetworkPolicyPort.allTcp(), kplus.NetworkPolicyPort.allUdp()],
            },
          ],
        },
      }
    );

Error Log:

The NetworkPolicy "mynetworkpolicy" is invalid: \n* spec.egress[0].ports[0].port: Invalid value: 0: must be between 1 and 65535, inclusive\n* spec.egress[0].ports[1].port: Invalid value: 0: must be between 1 and 65535, inclusive

Environment:

  • Framework Version:
    cdk8s: 2.198.138
  • OS:
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=22.04
    DISTRIB_CODENAME=jammy
    DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

Other:

We use Kubectl layer 1.29, and cluster version 1.29.


This is 🐛 Bug Report

@emagiz emagiz added bug Something isn't working needs-triage Priority and effort undetermined yet labels Jul 4, 2024
@iliapolo iliapolo added priority/p1 Should be on near term plans effort/small 1 day tops and removed needs-triage Priority and effort undetermined yet labels Jul 28, 2024
@iliapolo iliapolo added the @component/cdk8s-plus Issue related to cdk8s-plus label Sep 20, 2024
@iliapolo iliapolo transferred this issue from cdk8s-team/cdk8s-plus Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @component/cdk8s-plus Issue related to cdk8s-plus effort/small 1 day tops priority/p1 Should be on near term plans
Projects
None yet
Development

No branches or pull requests

2 participants