Skip to content

[metadata.ownerReferences] Error to create the deployment and service with custom CRDs #3160

Closed Answered by camilamacedo86
Tomelin asked this question in Support
Discussion options

You must be logged in to vote

Hi @Tomelin ,

The error you're encountering seems came from the fact that the name and uid fields in the OwnerReferences shouldn't be empty. Using the controller-runtime library, which comes bundled with kubebuilder, there's a more straightforward way to set the owner reference correctly.

Here's how you can do it:

  • Fetch the actual Discovery custom resource (CR) instance that you want to set as the owner of the Service object.

  • Use the controllerutil.SetOwnerReference method to correctly set the owner reference.

import (
	...
	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

// Assuming you've fetched the actual Discovery CR into a variable named 'd'
svc := &corev1.Se…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by camilamacedo86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants