bitnami / kube-libsonnet

Bitnami's jsonnet library for building Kubernetes manifests
https://bitnami.com
Apache License 2.0
172 stars 49 forks source link

Defaulting to `replicas: 1` in a deployment is detrimental #58

Open ghostsquad opened 3 years ago

ghostsquad commented 3 years ago

https://github.com/bitnami-labs/kube-libsonnet/blob/master/kube.libsonnet#L448

Since it's not easy to remove fields from a jsonnet obj (https://github.com/google/jsonnet/issues/312), and there's different behavior between:

replicas: null

and when the replicas field is missing.

In the latter case, the field isn't changed in the resulting object in Kubernetes. Thus, if you have a deployment replica count managed by an HPA (or similar), you want to exclude that field.

When a deployment is first deployed and the field doesn't exist, it it set to 1 in the final object in k8s. If the deployment already exists and the field doesn't exist in the manifest being reapplied, the field remains unchanged.

replicas: null is essentially equivalent to replicas: 1.

So there's no way, if using this library to easily remove the replicas field in order to get the desired behavior of having that field managed externally.