API Server Compatibility Checklist¶
This document outlines what the current babyctl api-server already exposes and what still needs to be implemented before kubectl can treat it like a general-purpose Kubernetes API server.
What the server already does¶
- Discovery endpoints plus sample CRUD – the HTTP router in
pkg/apiserver/server.gowires up handlers forGET /api,GET /apis, andGET /apis/<group>/<version>plus twobabyctl-specific helper routes for resource definitions and controllers. Cluster-scoped CRUD endpoints are now registered for any resource that exposes a REST controller (the bundledbabyctl.dev/v1alpha1/widgetsdefinition exercisesGET,POST,PUT, andDELETE). - File-backed resource metadata – API groups, versions, and resource lists are read from YAML files under
~/.babyctl/apis(or--api-path) via the loader. This keeps discovery data in sync with whatever definitions you install locally. - In-memory cache – the server preloads API resources at startup and filters out empty groups so kubectl’s discovery calls only see definitions that also have controller implementations.
These capabilities are sufficient for kubectl api-resources / api-versions, but kubectl requires more when you attempt get, apply, or other resource verbs.
Gaps to close for kubectl compatibility¶
- Resource endpoints for each verb
- Cluster-scoped CRUD handlers exist for resources that include a REST controller (see the widgets sample), but namespaced URLs, collection deletes, and patch verbs are not implemented yet.
- The handlers must support namespaced URLs, subresources such as
/status, and JSON Patch/Merge Patch (PATCHwith the properContent-Type). -
Until these semantics are added kubectl will still fail when targeting built-in resources such as
deployments. -
List/watch semantics
kubectl getand the informer cache expectlistpluswatchverbs to stream events. Implement chunking,resourceVersion,continue,labelSelector, andfieldSelectorquery parameters so clients can paginate or resume watches.-
Watches require HTTP streaming with the Kubernetes watch event envelope (
{"type":"ADDED","object":...}). -
Object schemas and metadata
- Responses need Kubernetes-style metadata fields (
apiVersion,kind,metadata.{name,namespace,uid,resourceVersion}) for every resource. -
Consider generating OpenAPI (
/openapi/v2or/openapi/v3) so kubectl can validate manifests. -
Status and scale subresources
- Many built-in commands (
kubectl rollout status,kubectl scale) rely on/statusand/scale. -
Expose separate handlers that delegate to the underlying
resourceconfig.Controllerimplementations or return “method not allowed” unless the definition explicitly supports them. -
Error handling and admission-style validation
- Use Kubernetes API status responses (
Statusobjects withstatus,reason,message,code). -
Validate request bodies and enforce optimistic concurrency via
metadata.resourceVersionto match kubectl expectations forupdate/patch. -
Authentication, authorization, and TLS
-
Real kubectl clients default to HTTPS with certificate verification. Add TLS flags (cert/key/CA) and optionally webhook-style authn/authz to avoid having to invoke
kubectl --server=http://... --insecure-skip-tls-verify. -
Miscellaneous Kubernetes endpoints
- Implement
/version,/readyz,/healthz, and/livezso kubectl and tooling can perform health checks. -
Consider supporting
/.well-known/openid-configurationif you later add token auth, because kubectl will call it when OIDC data is referenced in kubeconfig contexts. -
Dynamic reloading or informer refresh
-
Today the loader only reads definitions at startup. Add file watchers or an admin endpoint to reload definitions so cluster admins don’t have to restart the server when installing new APIs.
-
Multi-user reliability
- Add request logging, structured errors, and rate limiting.
- Provide consistent concurrency guarantees for controllers so concurrent kubectl operations do not corrupt backing systems.
Addressing the points above will move the server from “discovery-only shim” to something kubectl can treat like a full API server.