spotahome / redis-operator

Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Apache License 2.0
1.49k stars 357 forks source link

Resources are pruned if using ApplySets #592

Closed uhthomas closed 11 months ago

uhthomas commented 1 year ago

Expected behaviour

Kubernetes has introduced ApplySets, an improvement to server side apply and pruning.

https://kubernetes.io/blog/2023/05/09/introducing-kubectl-applyset-pruning/

ApplySets work by applying labels to objects it manages.

{
  "labels": {
      "app.kubernetes.io/component": "redis",
      "app.kubernetes.io/managed-by": "redis-operator",
      "app.kubernetes.io/name": "redis",
      "app.kubernetes.io/part-of": "redis-failover",
      "applyset.kubernetes.io/part-of": "applyset-xjZyH1FmMYtP-oSkfLUgubxDYIbsrD-IuDRLmezicIo-v1",
      "redisfailovers-role": "slave",
      "redisfailovers.databases.spotahome.com/name": "redis"
  }
}

The applyset label should not be inherited, or else the created resources are pruned.

Actual behaviour

service/rfr-redis pruned
service/rfs-redis pruned
deployment.apps/rfs-redis pruned
poddisruptionbudget.policy/rfr-redis pruned
poddisruptionbudget.policy/rfs-redis pruned
statefulset.apps/rfr-redis pruned
configmap/rfr-readiness-redis pruned
configmap/rfr-redis pruned
configmap/rfr-s-redis pruned
configmap/rfs-redis pruned

Steps to reproduce the behaviour

Create a RedisFailover object with KUBECTL_APPLYSET=true kubectl apply --server-side --applyset=some-apply-set --prune -f -. Wait for the resources to be created, and then observe they are pruned when the original custom resource is applied again.

Environment

How are the pieces configured?

Logs

N/A

uhthomas commented 1 year ago

I recognise this behaviour is configurable with the LabelWhitelist field, though I would urge the authors to reconsider the default behaviour. I would expect that with the introduction of ApplySets, pruning will become more popular and label propagation should be opt-in rather than opt-out. Either that, or an exception should be made specifically for applyset labels.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 45 days with no activity.

uhthomas commented 1 year ago

Closing an issue due to age isn't helpful for anyone.

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 45 days with no activity.

github-actions[bot] commented 11 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.