Search code examples
kuberneteskubernetes-podazure-aks

Is it possible to bind a new Deployment to an existing ReplicaSet?


I have some older ReplicaSets that were manually created by me, so they are not bound to/managed by a Deployment.

Is it possible to create the Deployments now, in a way that no new ReplicaSets will be created and the Deployments will automatically pair with the existing Replicasets and Pods?

I know I could delete the existing ReplicaSets, but I'm trying to find another way. I tried to give the new Deployment the same selector and matchLables as the existing ReplicaSet, but that didn't work and the Deployment created a new ReplicaSet and Pod.

Thanks!


Solution

  • The Deployment resource specification does not expose any fields for specifying the initial ReplicaSet. So, the logic of creating a new ReplicaSet seems to be hardcoded in the Deployment controller.

    So, the answer is, you can't do it. If you really wanted to have a Deployment where you can specify the ReplicaSet, you could create a Custom Resource Definition (CRD) and operator.