A transparent, lightweight Kubernetes manifest generator
Project description
k8smith
A transparent, lightweight Kubernetes manifest generator.
Philosophy
- Transparency over abstraction — Generated YAML is predictable; no hidden defaults
- Composition over inheritance — Build complex resources from simple pieces
- Type safety at the boundary — Validate inputs with Pydantic, output plain dicts
- Cloud-agnostic core — Vanilla K8s resources work anywhere; cloud extensions are optional
Installation
pip install k8smith
# or
uv add k8smith
Quick Start
from k8smith import (
DeploymentSpec,
Container,
PodSpec,
PodTemplateSpec,
ResourceRequirements,
ResourceQuantity,
build_deployment,
Manifest,
)
spec = DeploymentSpec(
name="web",
namespace="production",
replicas=3,
template=PodTemplateSpec(
spec=PodSpec(
containers=[
Container(
name="web",
image="nginx:1.25",
resources=ResourceRequirements(
requests=ResourceQuantity(cpu="100m", memory="128Mi"),
limits=ResourceQuantity(memory="256Mi"),
),
)
]
)
),
)
deployment = build_deployment(spec)
# Collect resources into a manifest
manifest = Manifest()
manifest.add(deployment)
print(manifest.to_yaml())
GPU Support (no workarounds needed!)
from k8smith import (
Container,
ResourceRequirements,
ResourceQuantity,
)
container = Container(
name="ml-worker",
image="ml-training:v1",
resources=ResourceRequirements(
requests=ResourceQuantity(memory="4Gi", cpu="1"),
limits=ResourceQuantity(
memory="8Gi",
extended={"nvidia.com/gpu": "1"}, # Just works!
),
),
)
GKE Extensions
from k8smith.gke import (
GatewaySpec,
HTTPRouteSpec,
build_gateway,
build_httproute,
)
gateway = build_gateway(GatewaySpec(
name="main-gateway",
namespace="gateway",
gateway_class_name="gke-l7-global-external-managed",
listeners=[{
"name": "https",
"port": 443,
"protocol": "HTTPS",
}],
))
Core Resources
| Resource | Builder |
|---|---|
| Deployment | build_deployment(DeploymentSpec) |
| Service | build_service(ServiceSpec) |
| Ingress | build_ingress(IngressSpec) |
| StatefulSet | build_statefulset(StatefulSetSpec) |
| DaemonSet | build_daemonset(DaemonSetSpec) |
| CronJob | build_cronjob(CronJobSpec) |
| ConfigMap | build_configmap(ConfigMapSpec) |
| Secret | build_secret(SecretSpec) |
| HPA | build_hpa(HPASpec) |
| PDB | build_pdb(PDBSpec) |
| ServiceAccount | build_serviceaccount(ServiceAccountSpec) |
| Namespace | build_namespace(NamespaceSpec) |
| Role | build_role(RoleSpec) |
| ClusterRole | build_clusterrole(ClusterRoleSpec) |
| RoleBinding | build_rolebinding(RoleBindingSpec) |
| ClusterRoleBinding | build_clusterrolebinding(ClusterRoleBindingSpec) |
GKE Resources
| Resource | Builder |
|---|---|
| Gateway | build_gateway(GatewaySpec) |
| HTTPRoute | build_httproute(HTTPRouteSpec) |
| HealthCheckPolicy | build_healthcheckpolicy(HealthCheckPolicySpec) |
| GCPBackendPolicy | build_gcp_backend_policy(GCPBackendPolicySpec) |
| PodMonitoring | build_pod_monitoring(PodMonitoringSpec) |
| ClusterPodMonitoring | build_cluster_pod_monitoring(ClusterPodMonitoringSpec) |
Why not cdk8s?
k8smith was created to replace cdk8s after encountering these issues:
| cdk8s Problem | k8smith Solution |
|---|---|
Size.gibibytes(6) outputs 6144Mi |
Strings stay as strings: "6Gi" |
Can't add nvidia.com/gpu via resources |
Built into ResourceQuantity.extended |
Adds hostNetwork: false when not set |
Only outputs what you specify |
| Requires label cleanup post-processing | No generated labels |
| JSII/Node.js dependency | Pure Python |
License
GPL-3.0 - See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k8smith-0.4.1.tar.gz.
File metadata
- Download URL: k8smith-0.4.1.tar.gz
- Upload date:
- Size: 53.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
029f5723712f61aebf794af3aace2b99b0a48d8d3d995a9ce0634aa0898d1ce0
|
|
| MD5 |
8a288b65543be7d1bbedeb415b4d6373
|
|
| BLAKE2b-256 |
52f6a51b590f16f73a882f1db1e63c223857914d5baca37b807239d96db3ffc9
|
Provenance
The following attestation bundles were made for k8smith-0.4.1.tar.gz:
Publisher:
release.yml on eliminyro/k8smith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k8smith-0.4.1.tar.gz -
Subject digest:
029f5723712f61aebf794af3aace2b99b0a48d8d3d995a9ce0634aa0898d1ce0 - Sigstore transparency entry: 801104255
- Sigstore integration time:
-
Permalink:
eliminyro/k8smith@f4387c31e1c0b2db830a48356c638adfa0c00e44 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/eliminyro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f4387c31e1c0b2db830a48356c638adfa0c00e44 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file k8smith-0.4.1-py3-none-any.whl.
File metadata
- Download URL: k8smith-0.4.1-py3-none-any.whl
- Upload date:
- Size: 43.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4ba4de376917972ccb11ac238c632eb5bd1776a95c49b2cda796a6dc7785a86
|
|
| MD5 |
af43aa2f9070bf496dba38c8b9a48cdd
|
|
| BLAKE2b-256 |
2168928c3fdbd61c0f7d3b68dbe1bf5e3e74c749c83cbfb651d29b9bb8fb3663
|
Provenance
The following attestation bundles were made for k8smith-0.4.1-py3-none-any.whl:
Publisher:
release.yml on eliminyro/k8smith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k8smith-0.4.1-py3-none-any.whl -
Subject digest:
e4ba4de376917972ccb11ac238c632eb5bd1776a95c49b2cda796a6dc7785a86 - Sigstore transparency entry: 801104300
- Sigstore integration time:
-
Permalink:
eliminyro/k8smith@f4387c31e1c0b2db830a48356c638adfa0c00e44 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/eliminyro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f4387c31e1c0b2db830a48356c638adfa0c00e44 -
Trigger Event:
workflow_run
-
Statement type: