Skip to content

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

clientgo

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)

kubernetes/sample-apiserver: Reference implementation of an apiserver for a custom Kubernetes API. (github.com)

Controller
Kubernetes Deep Dive: Code Generation for CustomResources (redhat.com)
kubernetes/sample-controller: Repository for sample controller. Complements sample-apiserver (github.com)

_____________________________________________________

KUBEBUILDER

- 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