crossplane-contrib / provider-kubernetes

Crossplane provider to provision and manage Kubernetes objects on (remote) Kubernetes clusters.
Apache License 2.0
139 stars 81 forks source link

Changing Object.spec.forProvider.manifest.metadata.name orphans previous resource #287

Open Avarei opened 2 weeks ago

Avarei commented 2 weeks ago

What happened?

After changing the Object.spec.forProvider.manifest.metadata.name the resource with the previous name does not get deleted.

How can we reproduce it?

Create a Resource:

apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
  name: foo
spec:
  forProvider:
    manifest:
      apiVersion: v1
      kind: ConfigMap
      metadata:
        namespace: default
        name: test1

Change the Resource

apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
  name: foo
spec:
  forProvider:
    manifest:
      apiVersion: v1
      kind: ConfigMap
      metadata:
        namespace: default
        name: test2

run kubectl get cm -n default and observe both test1 and test2 are present.

What environment did it happen in?

Provider Kubernetes: v0.14.1 Crossplane version: v1.16.0 Kubernetes: v1.28.8

bobh66 commented 2 weeks ago

I believe this is the expected behavior, at least for the current implementation. metadata.name is a "special" field since it defines the "key" to the object and the operator does not expect the key to change. That would require deleting the old Object and creating a new one with a new name.