k8s
k8s copied to clipboard
Can't create a deployment without specifying replicas
Currently if we create a deployment with this lib we're forced to have the replicas
field set to 1
by default (or a specified integer), because of this line: https://github.com/jsonnet-libs/k8s-libsonnet/blob/main/1.21/_custom/apps.libsonnet#L37
However, when using an HPA and Flux, we're ending up with Flux constantly resetting our replica count back to this setting every time the HPA decides to scale out. See this FAQ in the Flux docs for some details.
I'm not entirely sure how to fix this in a non-breaking way, but it seems that being able to set a null value might be reasonable...
Currently if we create a deployment with this lib we're forced to have the
replicas
field set to1
by default (or a specified integer), because of this line: https://github.com/jsonnet-libs/k8s-libsonnet/blob/main/1.21/_custom/apps.libsonnet#L37However, when using an HPA and Flux, we're ending up with Flux constantly resetting our replica count back to this setting every time the HPA decides to scale out. See this FAQ in the Flux docs for some details.
I'm not entirely sure how to fix this in a non-breaking way, but it seems that being able to set a null value might be reasonable...
From what I remember, if using an HPA, you have to hide the replicas. Example:
deployment.new(...) + {
spec+: {
// Hide the replica attribute so it's not output anymore
replicas:: super.replicas,
}
}
This is not supported in the lib obviously, but it's a workaround
Ah, interesting. Thanks @julienduchesne! It'd obviously be nice to bake this into the lib somehow too...
@hairyhenderson we are doing the same as @julienduchesne suggested. Do you have suggestions for the UX workflow?
Do you have suggestions for the UX workflow?
Just what I suggested in the description:
it seems that being able to set a null value might be reasonable...
actually makes sense for me. @hairyhenderson feel free to create a PR!