Friday, May 03, 2019

Error: cannot load k8s.io/client-go/pkg/api": cannot find module providing package k8s.io/client-go/pkg/api

Symptom:

  When we use client-go api ,there is line of code :
api.Codecs.UniversalDeserializer()
We often import "k8s.io/client-go/pkg/api". It was working. Then suddently we hit this error
Error: cannot load k8s.io/client-go/pkg/api": cannot find module providing package k8s.io/client-go/pkg/api

Solution:

  The reason of this error is due to code baseline has moved to a new location
Instead of import "k8s.io/client-go/pkg/api"
we should use
import "k8s.io/client-go/kubernetes/scheme"

Then change code to use scheme instead of api
scheme.Codecs.UniversalDeserializer()

No comments: