diff --git a/pkg/ipamd/ipamd.go b/pkg/ipamd/ipamd.go index 2717cb93aa..6a3b031035 100644 --- a/pkg/ipamd/ipamd.go +++ b/pkg/ipamd/ipamd.go @@ -1920,6 +1920,9 @@ func (c *IPAMContext) AnnotatePod(podName, podNamespace, key, val string) error } newPod := pod.DeepCopy() + if newPod.Annotations == nil { + newPod.Annotations = make(map[string]string) + } newPod.Annotations[key] = val if err = c.rawK8SClient.Patch(ctx, newPod, client.MergeFrom(pod)); err != nil { log.Errorf("Failed to annotate %s the pod with %s, error %v", key, val, err)