Autopilot SDK Structure
The source code for the Autopilot SDK is composed of 3 core directories:
cli: contains source code for the
codegen: contains the source code for generating code, Kubernetes manifests, and other project files necessary to build and deploy the operator.
codegenis invoked by the
ap generatecommand, but can be invoked manually (see
debuggable_generate.gofor an example).
pkg: libraries used for running Autopilot Operators.
ap CLI is designed to manage the full lifecycle of the Operator, from code generation, build, and deployment.
Autopilot Operators can be built and deployed via standard means (e.g.
kubectl apply). The
ap CLI is designed to simplify this process, without being a required component.
codegen package contains the root
Generate functions which are used to generate code and other project files from the
It contains subpackages
model- contains the internal model of project data parsed from the
autopilot.yamlas well as utility functions which are used to render templates for generated files.
templates- contains the templates used to render generated code, deployment, and project files. Templates are organized by type, with
codecontaining all templates for generated
deploycontaining templates for generated Kubernetes manifests.
For the full list of files generated by Autopilot, see
pkg contains the core libraries for running Autopilot Operators. It is broken up into the following subpackages:
config: defaults and helper functions for loading the Autopilot Operator config. Read more about the Autopilot Operator config in the reference documentation.
defaults: defaults core to the system. Default file location of
autopilot.yamlas well as other variables (which can be overridden in
ezkubecontains a client which is a convenience wrapper for the dynamic
client.Clientof the controller-runtime library. It adds convenience functions for operators such as the
Ensurefunction which applies resources to Kubernetes, setting owner references and retrying on resource conflicts.
metrics: defines the base
metrics.Clienton which generated metrics code is based. The implemented metrics client is designed primarily for querying Prometheus.
run: contains the main entrypoint for Autopilot Operators. The Operator’s generated
run.Runfunction which runs the user’s scheduler
scheduler: contains utilities and shared code for the generated
scheduler.go, which is responsible for calling the user-defined workers.
utils: utilities used in various places in generated code.
version: small package containing the current version of Autopilot itself. This version is stored as a variable which is set at compile-time by Autopilot’s