kubernetes-client / kubernetes-client/javascript
Since 1.2.0 NetworkPolicies are not rendered correctly (and not applied correctly)
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 568
- Avg merge
- 17h 57m
- Merged PRs (30d)
- 41
Description
**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 https://github.com/kubernetes-client/javascript/issues/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.
Contributor guide
Research direction
Start by reproducing the NetworkPolicy replacement with the manifest in the issue across client versions 1.1.2, 1.2.0, and 1.4.0 on Kubernetes 1.33.0. Read the linked kubernetes-client/javascript issue #2396 and compare the applied resource, especially the namespaceSelector. Done means replacement preserves the namespace selector and related NetworkPolicy fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, kubernetes, node.js, typescript
- Domain
- devops, networking, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100