Skip to content

Since 1.2.0 NetworkPolicies are not rendered correctly (and not applied correctly) #2825

@mwoudstra

Description

@mwoudstra

Describe the bug
When using the library, the replace functionality does not correctly propragate to the cluster. Set fields are removed unexpectedly. Confirmed 1.1.2 does not have this behaviour, 1.2.0 (up to 1.4.0) starts to have it (most likely due to #2396)

Client Version
e.g. 1.4.0

Server Version
e.g. 1.33.0

To Reproduce
Apply

{
    "apiVersion": "networking.k8s.io/v1",
    "kind": "NetworkPolicy",
    "metadata": {
        "name": "np",
        "namespace": "default",
    },
    "spec": {
        "ingress": [
            {
                "from": [
                    {
                        "namespaceSelector": {
                            "matchLabels": {
                                "kubernetes.io/metadata.name": "nginx"
                            }
                        },
                        "podSelector": {
                            "matchLabels": {
                                "app.kubernetes.io/component": "controller"
                            }
                        }
                    }
                ],
                "ports": [
                    {
                        "port": 9000,
                        "protocol": "TCP"
                    }
                ]
            }
        ],
        "podSelector": {},
        "policyTypes": [
            "Ingress"
        ]
    }
}

Observe the applied is (output is different based on version). The NS selector is gone:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: np
  namespace: default
spec:
  ingress:
      ports:
        - port: 9000
          protocol: TCP
  podSelector: {}
  policyTypes:
    - Ingress

Expected behavior
The NS selector to be valid.

Example Code
Code snippet for what you are doing

Environment (please complete the following information):

AWS Lambda on Node 22.x

Additional context
1.1.2 works, 1.2.0 changes the output, 1.4.0 has even different output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions