Kubernetes Model¶
Maturity: stable
Defining objects with templates, kubernetes client models or YAML/JSON is stable: existing definitions keep loading within a major version. See the Roadmap for every feature’s status.
Piceli plans and applies Kubernetes objects defined in any of three ways, and
they can be mixed in one composition. For whole applications, start with the
typed App (Describe an app in typed Python), which builds on the same model.
Piceli templates¶
Python classes for the common kinds (Deployment, Service, ConfigMap, Job, CronJob, RBAC and more), with defaults and validation. See Piceli Templates for Kubernetes Objects.
Kubernetes client models¶
Objects of the official
Kubernetes Python client
(kubernetes.client.V1Service and the rest) are accepted as they are:
from kubernetes import client
service = client.V1Service(
api_version="v1",
kind="Service",
metadata=client.V1ObjectMeta(name="api", labels={"app": "api"}),
spec=client.V1ServiceSpec(
ports=[client.V1ServicePort(port=80, target_port=8080)],
selector={"app": "api"},
),
)
YAML and JSON files¶
Load a folder of manifests with piceli.k8s.ops.load_all and put the objects
into a composition with component_from_objects; Can I keep my existing YAML files?
shows the whole module. load_all also takes module_name (a dotted import
path) and module_path (a file or folder of Python modules), and loads every
Piceli template and kubernetes.client object they define;
sub_elements=False skips sub-folders and sub-modules. To turn manifests
into a typed App module instead, use piceli import yaml
(From kubectl scripts to Piceli).