Description
Bug Report
Empty K8s environment variables are stored as null
by Kubernetes, so in a reconciliation loop, the SSA matcher will sending a mismatch between the desired and the actual resource.
This will lead to infinite resource being updated in each reconciliation.
What did you do?
For example, for a Deployment with a PodSpec field as below:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
env:
- name: EMPTY_ENV_VAR
value: ""
The following will be shown by running a kubectl
command:
$ kubectl get deployments.apps nginx -o yaml
...
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
env:
- name: EMPTY_ENV_VAR
...
What did you expect to see?
No mismatch is triggered by the SSA matcher when an empty EnvVar is set.
What did you see instead? Under which circumstances?
Infinite mismatch and update in the resource.
Environment
Kubernetes cluster type:
Minikube v1.32.0
$ Mention java-operator-sdk version from pom.xml file
5.0.4
$ java -version
JDK 21
$ kubectl version
Client Version: v1.32.0
Kustomize Version: v5.5.0
Server Version: v1.32.0
Possible Solution
Improve ResourceRequirementsSanitizer class to keep this into account. Similar to what is done to the resource quantity and limits.
Additional context
Similar to #2509