K3s/Kubernetes substrate — manages pods, deployments, and services via kubectl.
Module: factory.deploy/extend.substrate/ObjK3s.py
Mirrors the ObjDocker substrate interface for Kubernetes. Wraps kubectl
commands with consistent error handling and structured output.
| Method | K8s Action |
|---|---|
connect() |
kubectl cluster-info |
list_instances() |
kubectl get pods -o json |
get_instance(name) |
kubectl get pod <name> -o json |
create_instance(config) |
kubectl apply -f <manifest> |
start_instance(name) |
kubectl scale deployment/<name> --replicas=1 |
stop_instance(name) |
kubectl scale deployment/<name> --replicas=0 |
delete_instance(name) |
kubectl delete pod <name> |
execute_command(name, cmd) |
kubectl exec <name> -- <cmd> |
| Method | Purpose |
|---|---|
get_deployments() |
List all deployments with replica status |
get_services() |
List services with ports and cluster IPs |
scale(deployment, replicas) |
Scale a deployment |
rollout_restart(deployment) |
Rolling restart |
get_logs(pod, tail) |
Pod log output |
get_events(limit) |
Recent namespace events |
apply_file(manifest) |
Apply YAML/JSON manifest |
delete_file(manifest) |
Delete resources from manifest |
python factory.deploy/extend.substrate/ObjK3s.py pods -n homechoice-dev
python factory.deploy/extend.substrate/ObjK3s.py deployments -n homechoice-dev
python factory.deploy/extend.substrate/ObjK3s.py services -n homechoice-dev
python factory.deploy/extend.substrate/ObjK3s.py logs <pod> -n homechoice-dev
python factory.deploy/extend.substrate/ObjK3s.py scale-cmd <deployment> 3 -n homechoice-dev
python factory.deploy/extend.substrate/ObjK3s.py restart <deployment> -n homechoice-dev
ObjDocker.py — Docker substrate (same interface pattern)ObjBuild.py — uses ObjBuildHelm for Helm operationsObjSubstrate.py — base class with ResourceLimits, InstanceTemplate