Error to create the CRDs with kubebuilder [metadata.ownerReferences]

66 views
Skip to first unread message

Rafael Tomelin

unread,
Jan 15, 2023, 10:58:18 AM1/15/23
to kubebuilder
Hi,

I tried to create a CRDs but I'm having errors when creating the deployment and service.

the error is:
 Error to create the service, Service "sc-monogodb" is invalid: [metadata.ownerReferences.name: Invalid value: "": name must not be empty, metadata.ownerReferences.uid: Invalid value: "": uid must not be empty]1.673797609427857e+09    ERROR    controller.discovery    Reconciler error    {"reconciler group": "catalog.tomelin.tech", "reconciler kind": "Discovery", "name": "discovery-sample", "namespace": "service-discovery", "error": "Service \"sc-monogodb\" is invalid: [metadata.ownerReferences.name: Invalid value: \"\": name must not be empty, metadata.ownerReferences.uid: Invalid value: \"\": uid must not be empty]"}

My parameters are:
```
 d *catalogv1alpha1.Discovery
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "sc-monogodb",
Namespace: "service-discovery",
OwnerReferences: []metav1.OwnerReference{{
Name: "discovery-sample",
UID: "b4ebb054-2e65-4016-bc04-cc3aad91d644",
Kind: "Discovery",
}},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Name: "sc-mongodb",
Protocol: corev1.ProtocolTCP,
Port: 27017,
}},
},
}
```

I changed the parameters OwnerReferences to variable and not worked.

I'm using this kubebuilder version:
 kubebuilder version
Version: main.version{KubeBuilderVersion:"0.0.0-SNAPSHOT-fc59b56", KubernetesVendor:"1.23.5", GitCommit:"fc59b569ced3a2942b87ce20db39043be1bf8352", BuildDate:"2022-05-18T10:55:28Z", GoOs:"darwin", GoArch:"amd64"}

Can you help?

Reply all
Reply to author
Forward
0 new messages