yunlee
yunlee

Reputation: 89

Kubernetes cluster agent: Could not construct reference to ConfigMap

ConfigMap exists in the right namespace, but getting this error that it couldn't construct reference to configmap, and did not get a confirmation that leaderelection has been successfully required. Any advice would be appreciated

error log snippet

...
2021-08-04T18:14:35.659Z        INFO    setup   starting manager
2021-08-04T18:14:35.659Z        INFO    controller-runtime.manager      starting metrics server {"path": "/metrics"}
E0804 18:14:35.701075       1 event.go:247] Could not construct reference to: '&v1.ConfigMap{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"controller-leader-election-helper", GenerateName:"", Namespace:"kubestone-system", SelfLink:"", UID:"e28283ca-45ad-4095-9077-d55c8c0a40be", ResourceVersion:"10947", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:63763697675, loc:(*time.Location)(0x21639e0)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string{"control-plane.alpha.kubernetes.io/leader":"{\"holderIdentity\":\"kubestone-controller-manager-f467b7c47-8n8nz_d30009f2-f54f-11eb-9895-d6c135c24951\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2021-08-04T18:14:35Z\",\"renewTime\":\"2021-08-04T18:14:35Z\",\"leaderTransitions\":0}"}, OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry{v1.ManagedFieldsEntry{Manager:"manager", Operation:"Update", APIVersion:"v1", Time:(*v1.Time)(0xc0002739e0), Fields:(*v1.Fields)(nil)}}}, Data:map[string]string(nil), BinaryData:map[string][]uint8(nil)}' due to: 'selfLink was empty, can't make reference'. Will not report event: 'Normal' 'LeaderElection' 'kubestone-controller-manager-f467b7c47-8n8nz_d30009f2-f54f-11eb-9895-d6c135c24951 became leader'
2021-08-04T18:14:37.760Z        INFO    controller-runtime.controller   Starting Controller     {"controller": "sysbench"}
...

Upvotes: 1

Views: 3368

Answers (2)

ahmet alp balkan
ahmet alp balkan

Reputation: 45302

You need to register these packages

coordinationv1 "k8s.io/api/coordination/v1"
corev1 "k8s.io/api/core/v1"

to your scheme:

utilruntime.Must(corev1.AddToScheme(scheme))         // for leader election
utilruntime.Must(coordinationv1.AddToScheme(scheme)) // for leader election

If you're using a global scheme, that'd be scheme.Scheme.

Funny the leader election actually works without this so I'm not sure why this is logged as an error.

Upvotes: 1

Rob Evans
Rob Evans

Reputation: 2874

Looks like the error is telling you:

...
SelfLink: "",
...

... due to: 'selfLink was empty, can't make reference' ...

Thread here suggests some solutions https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/issues/25#issuecomment-742616668

You may need to update your Kubernetes client but hard to say without more info

Upvotes: 2

Related Questions