30.11.16

Rob Extended the Kube API!

The kube API has always bewildered me.

Where does it come from ? How do you change it?  What are all these TL;DR docs about it ? Thankfully Rob Rati At red hat recently made a nice clean modification that serves as a pedagogical example of how to extend the API.

I tried reading the docs...
  • https://github.com/kubernetes/kubernetes/blob/master/docs/devel/api_changes.md
  • https://github.com/kubernetes/kubernetes/blob/master/docs/api.md
...but i got bored :(


THANKFULLY IM FRIENDS WITH ROB ! The author of

https://github.com/kubernetes/kubernetes/pull/37299

I'm sure there are other PRs like it, but this one is rob's, so i figured id read through the code rather than all those spammy docs.

Heres the summary for anyone wanting to extend the Kube API...

1) It is in two commits: One for data model changes, the other for autogenerated changes.

2) There are 51 total files touched, in his PR , 23 of them are his own changes, the other half is auto generated.


Breaking the changes down and grouping them , We can see there's alot of redundant work you have to do. I've attempted to collate that here so that I can use it for personal notes on what i need to do in my adventures modifying the pod scheduling data attributes.


pkg/api/testing/fuzzer.go

Add a thing to fuzz a new affinity when nil

pkg/api/types.go
pkg/api/v1/defaults.go
pkg/api/serialization_test.go
staging/src/k8s.io/client-go/pkg/api/types.go
staging/src/k8s.io/client-go/pkg/api/v1/types.go


    Added Affinity pointer to the PodSpec

staging/src/k8s.io/client-go/pkg/api/v1/defaults.go 

    Added SetDefaults for PodSpec to create a Affinity if nil.

plugin/pkg/scheduler/algorithm/priorities/node_affinity_test.go
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
pkg/controller/daemon/daemoncontroller_test.go



    Updated affinity checks to get rid of affinity annotations parsing crap, and use the newly added api field

pkg/registry/core/pod/etcd/etcd_test.go
pkg/kubelet/config/http_test.go
pkg/kubelet/config/file_linux_test.go
pkg/kubelet/config/common_test.go
pkg/apis/extensions/v1beta1/defaults_test.go
pkg/api/validation/validation_test.go

    Add Affinity field to Pod structs that are used.

pkg/api/validation/validation.go

    Updated validator to update the affinity stuf, externalized the function

:: note that there are some update scripts you need to run when doing this stuff ::
: update-(codecgen, codegen, generated-runtime, generated-protobuf, swagger, generated-swagger-docs)  openapi-spec, federation-openapi-spec, federation-swagger-spec, federation-api-reference-docs

No comments:

Post a Comment