Comments (8)
If you add a type to a scheme, its Go type name is used as kind (via reflection).
Now I also understand what is going on. You are getting a CronTab from the server and the client tries to find a CronTab in its scheme. It only finds a Crontab, which is not helpful. So the server returns an unexpected object. Those two have to match.
Where Crontab
is added to the scheme in register.go, you can give a custom name with the capital T
. Then it will work too.
from cnat.
@sttts @mhausenblas thanks for the help. it works.
from cnat.
Thanks for raising this @yang-wang11 and I'm unsure I follow what exactly your steps were. You mentioned generate-groups.sh
(I assume you're referring to https://github.com/kubernetes/code-generator?) Maybe @sttts has a better view?
from cnat.
@mhausenblas @sttts yes, I follow the book step by step(chapter 4-5). I did the following changes:
- upgrade to v1 instead of v1alpha1 for CRD
- remove the sub-resource status for CRD
you may see below code generated from generate-groups.sh
, it seems to look good.
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
stablev1.AddToScheme,
}
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}
I tried to force execute its init function. the error does seem not to disappear.
_ "typedClient/client/clientset/versioned/scheme"
from cnat.
Note the different spelling: CronTab vs. Crontab. The scheme has the latter, the clients wants the former.
from cnat.
no kind "CronTab" is registered for version "stable.example.com/v1" in scheme "pkg/crd/typedClient/client/clientset/versioned/scheme/register.go:15"
Is this a copy-and-pasted error message? Am not sure where client-gen gets the CronTab type from. It is based on the Go type, not the CRD yaml. Hence, it should print a "Crontab" error, not "CronTab" 🤔
from cnat.
@sttts thanks for the help.
I'm a little confused, is that mean I need to rename my go type from Crontab
to CronTab
? like below
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CronTabList{},
&CronTab{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
from cnat.
no kind "CronTab" is registered for version "stable.example.com/v1" in scheme "pkg/crd/typedClient/client/clientset/versioned/scheme/register.go:15"
Is this a copy-and-pasted error message? Am not sure where client-gen gets the CronTab type from. It is based on the Go type, not the CRD yaml. Hence, it should print a "Crontab" error, not "CronTab" 🤔
yes, this error message copy from the console.
from cnat.
Related Issues (8)
- "error": "ats.cnat.programming-kubernetes.info \"example-at\" not found" HOT 1
- bug: odd number of arguments passed as key-value pairs HOT 1
- [Issue] [Chapter4.4.3] controller-runtime work with CR HOT 1
- Update-codegen.sh get a wrong package name
- go.mod: unexpected module path "k8s.io/sample-controller" HOT 2
- Should the query back object be deepcopied before update it? HOT 4
- Running on GKE, need to use Upadate() instead of UpdateStatus() in cnat-client-go/controller.go.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cnat.