KUBERNETES APIS PROGRAMMING
Kubernetes-API in Kubernetes | ANOTE.DEV
The Kubernetes API | Kubernetes
Kubernetes API Reference Docs
kubectl get --raw /apis/discovery.k8s.io/v1 |jq '.' |less
kubectl get --raw /apis/apps/v1 |jq '.resources' |less
kubectl get --raw /apis/apps/v1/deployments |jq '.items[]' |less
kubectl get --raw /api/v1/nodes |jq '.items' |less
kubectl get --raw /api/v1/namespaces |jq '.items[].metadata.name' |less
kubectl api-versions
2018 Introducing client-go version 6 | Kubernetes
Understanding the Kubernetes Resource Model and Controller Pattern
Writing a Kubernetes Controller | Rawkode Live - YouTube
Tutorial: Building CronJob - The Kubebuilder Book
Dynamic Admission Control | Kubernetes
Code PKG¶
- Scheme a registry to map (serialize) go type from apis (Group Version Kind)
- Informers in memory cache store syncing every 30 s
You get a Resource from a shared informer as a read only cache entry, so you need to map it (deepCopy) to an Object before modification - listers
- watchers
- workqueue package - k8s.io/client-go/util/workqueue - Go Packages
Runtime Object runtime package - k8s.io/apimachinery/pkg/runtime - Go Packages
encode the type of an API to a Schema
RestMapping meta package - k8s.io/apimachinery/pkg/api/meta - Go Packages
OpenAPI-Specification/3.1.0.md at main ยท OAI/OpenAPI-Specification (github.com)
Controller
Kubernetes Deep Dive: Code Generation for CustomResources (redhat.com)
kubernetes/sample-controller: Repository for sample controller. Complements sample-apiserver (github.com)
_____________________________________________________
- batch instead of batch.tutorial..?
https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go#L79
- Why to import multiple loggers?
controller: "sigs.k8s.io/controller-runtime/pkg/log"
main: "sigs.k8s.io/controller-runtime/pkg/log/zap"
zap is used to customize and flag the logging interface provided by logr, so you'll need to import both libraries in main, while zap or klog should be enough in a project module
https://sdk.operatorframework.io/docs/building-operators/golang/references/logging/
_____________________________________________________
SIG meetings¶
SIG API Machinery Meetings - YouTube
Real implementations¶
MongoDB Community Kubernetes Operator
Go Operator Tutorial | Operator SDK (operatorframework.io)
Questions
Why /api/v1 and /apis/apps/v1