Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment replicas is overwritten #1842

Closed
1 task done
Nicklason opened this issue Sep 18, 2021 · 4 comments
Closed
1 task done

Deployment replicas is overwritten #1842

Nicklason opened this issue Sep 18, 2021 · 4 comments

Comments

@Nicklason
Copy link

Describe the bug

The replicas for a deployment is overwritten when flux reconciles when using a pod autoscaler. The pods are terminated and then created again right after.

Steps to reproduce

  1. Create a deployment and a pod autoscaler for the deployment
  2. Make the pod autoscaler increase the replica count for the deployment (either by setting min replicas higher than the deployment, or by stressing the pods to increase resource usage)
  3. Trigger reconciliation

Expected behavior

I would expect the deployment replicas to not be overwritten.

Screenshots and recordings

No response

OS / Distro

N/A

Flux version

N/A

Flux check

► checking prerequisites
✗ flux 0.17.0 <0.17.1 (new version is available, please upgrade)
✔ kubectl 1.22.1 >=1.18.0-0
✔ Kubernetes 1.21.4+k3s1 >=1.16.0-0
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.11.2
✔ image-automation-controller: deployment ready
► ghcr.io/fluxcd/image-automation-controller:v0.14.1
✔ image-reflector-controller: deployment ready
► ghcr.io/fluxcd/image-reflector-controller:v0.11.1
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v0.14.1
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v0.16.0
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v0.15.4
✔ all checks passed

Git provider

No response

Container Registry provider

No response

Additional context

I have also tried not specifying replicas on the deployment and only have them in the horizontal pod autoscaler, but the replicas still changed.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@makkes
Copy link
Member

makkes commented Sep 19, 2021

According to fluxcd/flux#1686 (comment) not specifying the replicas in the manifest should prevent Flux from overwriting the field and I wonder how it would overwrite it in this case because Flux basically doesn't have a value to overwrite the replicas field with. 🤔

@makkes
Copy link
Member

makkes commented Sep 19, 2021

I will try to reproduce this issue to make sure Flux overwrites the field and come back here later.

@stefanprodan
Copy link
Member

This behavior is documented in the FAQ, you need to remove the replicas field from your Deployment YAML and Flux will no longer override the value set by HPA.

@Nicklason
Copy link
Author

I tried removing the replica count from a deployment again but pods were still deleted and created again. I did another reconciliation right after and no pods were deleted that time. I am not sure why the pods were deleted the first time but it seems more like a thing with Kubernetes and not one with flux. Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants