k8s icon indicating copy to clipboard operation
k8s copied to clipboard

Can't create a deployment without specifying replicas

Open hairyhenderson opened this issue 2 years ago • 5 comments

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...

hairyhenderson avatar Jun 16 '22 17:06 hairyhenderson

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...

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

julienduchesne avatar Jun 16 '22 17:06 julienduchesne

Ah, interesting. Thanks @julienduchesne! It'd obviously be nice to bake this into the lib somehow too...

hairyhenderson avatar Jun 16 '22 17:06 hairyhenderson

@hairyhenderson we are doing the same as @julienduchesne suggested. Do you have suggestions for the UX workflow?

xvzf avatar Jun 17 '22 06:06 xvzf

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...

hairyhenderson avatar Jun 17 '22 19:06 hairyhenderson

actually makes sense for me. @hairyhenderson feel free to create a PR!

xvzf avatar Jul 21 '22 08:07 xvzf