-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Support both TPR and CRD with custom objects spec #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cc @djmckinley |
cc @enisoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. Some questions below.
scripts/custom_objects_spec.json
Outdated
"type": "string" | ||
}, | ||
{ | ||
"name": "kind", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "kind" just shorthand for the plural resource name? In CRD we distinguish between the kind (CronJob), the singular (cronjob), and plural resource name (cronjobs). The plural resource name is technically the one that goes in the URL here, and it doesn't have to be related to the other names at all (they can all be specified independently). So if you wanted, you could define a CRD with kind "CronJob" and plural resource name "moomoofarm" and the latter would go in the URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the one goes into URL. Do you have any suggestion for its name that make sense in both CRD and TPR world?
scripts/custom_objects_spec.json
Outdated
"consumes": [ | ||
"*/*" | ||
], | ||
"produces": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this tell clients what content types they are allowed to request? If so, we should be careful what we list because custom objects served by CRD don't support protobuf. I'm not sure if they even support yaml; I'd be surprised if they do.
If this spec gets used for custom objects backed by an aggregated API server, there's no reason it couldn't support protobuf and yaml, but then I would expect them to export their own spec at that point. This generic spec makes more sense for low-effort integrations like CRD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Will remove yaml and proto.
scripts/custom_objects_spec.json
Outdated
"produces": [ | ||
"application/json", | ||
"application/yaml", | ||
"application/vnd.kubernetes.protobuf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about the content types for protobuf and yaml.
scripts/custom_objects_spec.json
Outdated
"name": "group", | ||
"in": "path", | ||
"required": true, | ||
"description": "The Custom object's group name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the usages of "custom object" in this spec make more sense to me as "custom resource". We intentionally added the "D" in "CRD" to distinguish the custom resource from the thing that installs it (the custom resource definition).
The way I think of it is: the CRD installs a custom resource, which is the location in the API where you can store custom objects.
@enisoc updated with your comments. Can you take another look? |
This looks good as far as fixing #280. I have a couple of questions about the "list" functions, though. The previous third_party_resources_api.py module appeared to list third party resources across all namespaces. Now, with the custom_objects_api.py module, the list functions for namespaced CRs seem to support listing namespaced custom objects only in a single namespace. Is there a reason there is not a "list_namespaced_custom_objects_for_all_namespaces" function like there are for the various core resources? (For example, does "list_cluster_custom_objects" perhaps do that if the object kind it identifies is a namespaced object?) Second, is there a reason that the list functions do not have the optional parameters, "label_selector" and "resource_generation" that are present on the list functions for core objects? Both the ability to list objects in a single namespace, or across all namespaces, and the ability to filter by label and resource_generation would be very useful for my use case. |
@djmckinley both good points. On your first point, On your second point, you are right, I will add those optional parameters to all list operations. |
LGTM other than the additional list options mentioned above. I verified that you can list namespaced custom objects across all namespaces by hitting the non-namespaced resource path: $ kubectl get --raw /apis/stable.example.com/v1/crontabs/ | json_pp
{
"kind" : "CronTabList",
"metadata" : {
"resourceVersion" : "1805",
"selfLink" : "/apis/stable.example.com/v1/crontabs/"
},
"items" : [
{
"spec" : {
"image" : "old-image",
"cronSpec" : "* * * * /5"
},
"apiVersion" : "stable.example.com/v1",
"kind" : "CronTab",
"metadata" : {
"deletionGracePeriodSeconds" : null,
"creationTimestamp" : "2017-07-06T18:52:03Z",
"namespace" : "default",
"uid" : "3385cb16-627c-11e7-9d68-a0481c9805b1",
"deletionTimestamp" : null,
"resourceVersion" : "1363",
"clusterName" : "",
"name" : "my-new-cron-object",
"selfLink" : "/apis/stable.example.com/v1/namespaces/default/crontabs/my-new-cron-object"
}
},
{
"spec" : {
"cronSpec" : "* * * * /5",
"image" : "my-awesome-cron-image"
},
"apiVersion" : "stable.example.com/v1",
"kind" : "CronTab",
"metadata" : {
"name" : "crontab-1",
"clusterName" : "",
"selfLink" : "/apis/stable.example.com/v1/namespaces/ns2/crontabs/crontab-1",
"creationTimestamp" : "2017-07-06T18:56:00Z",
"resourceVersion" : "1796",
"deletionTimestamp" : null,
"uid" : "c05f8fd5-627c-11e7-9d68-a0481c9805b1",
"namespace" : "ns2",
"deletionGracePeriodSeconds" : null
}
}
],
"apiVersion" : "stable.example.com/v1"
} |
Thanks @enisoc and @djmckinley. I need to close this PR and send the PR agains kubernetes-client/gen repo (we moved to use that for generation). |
Re-opening this PR (to keep history of this change) with just updating the client after gen repo PR is merged. |
@mbohlool Thanks for doing this; it's an important issue. There is one thing I can't get to work though. Main question: How do I manage CRDs with client-python 3.0? Background Here is an example cluster response:
I'm calling the method "create_third_party_resource" with the CRD YAML as its body on a client.ExtensionsV1beta1Api instance. I'm on k8s 1.7.4. Ideas: Thanks! |
Fixes #251
should also fix #280