stakater / Reloader

A Kubernetes controller to watch changes in ConfigMap and Secrets and do rolling upgrades on Pods with their associated Deployment, StatefulSet, DaemonSet and DeploymentConfig – [✩Star] if you're using it!
https://docs.stakater.com/reloader/
Apache License 2.0
7.5k stars 501 forks source link

[BUG] With kubernetes/eks 1.30 or higher and sleep lifecycle the controller not restart deployment #754

Open mlophez opened 2 weeks ago

mlophez commented 2 weeks ago

Describe the bug When using Kubernetes 1.30 or higher, the Deployment object adds new lifecycle policies, such as sleeplifecycle. https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/

When you add this, the controller throws the following error and not restart deployment:

time="2024-09-26T06:24:29Z" level=error msg="Update for of type 'Deployment' in namespace 'core' failed with error Deployment.apps is invalid: spec.template.spec.containers[0].lifecycle.preStop: Required value: must specify a handler type"

This happens because, in the current project libraries, the Deployment object does not have those properties. When we updated the project's libraries to version 1.31, the problem was resolved.

´´´ go get k8s.io/api@v0.31.1 go get k8s.io/apimachinery@v0.31.1 go get k8s.io/client-go@v0.31.1 go get k8s.io/kubectl@v0.31.1 ´´´

To Reproduce Use kubernetes 1.30 and use deployment with lifecycle sleep or kubernetes 1.29 with de alpha feature enable

Expected behavior The controller must be function as normally

Environment

Additional context

MuneebAijaz commented 1 week ago

@mlophez PRs are welcome for this fix. However, we would prefer it if the change can be tested on older versions to make sure it doesn't break community on older kubernetes versions. (< 1.30)

mlophez commented 1 week ago

Hi @MuneebAijaz, i open PR for this, only update k8s libraries.

Unfortunately, I cannot test on earlier versions because our EKS clusters have already been updated. However, the Kubernetes libraries should be backward compatible with previous versions.