# cloudcoil-models-kubernetes
Versioned kubernetes models for cloudcoil.
> [!WARNING]
> This repository is auto-generated from the [cloudcoil repository](https://github.com/cloudcoil/cloudcoil/tree/main/models/kubernetes). Please do not submit pull requests here. Instead, submit them to the main repository at https://github.com/cloudcoil/cloudcoil.
## 🔧 Installation
> [!NOTE]
> For versioning information and compatibility, see the [Versioning Guide](https://github.com/cloudcoil/cloudcoil/blob/main/VERSIONING.md).
Using [uv](https://github.com/astral-sh/uv) (recommended):
```bash
# Install with Kubernetes support
uv add cloudcoil.models.kubernetes
```
Using pip:
```bash
pip install cloudcoil.models.kubernetes
```
## 💡 Examples
### Using Kubernetes Models
```python
from cloudcoil import apimachinery
import cloudcoil.models.kubernetes.core.v1 as k8score
import cloudcoil.models.kubernetes.apps.v1 as k8sapps
# Create a Deployment
deployment = k8sapps.Deployment(
metadata=apimachinery.ObjectMeta(name="nginx"),
spec=k8sapps.DeploymentSpec(
replicas=3,
selector=apimachinery.LabelSelector(
match_labels={"app": "nginx"}
),
template=k8score.PodTemplateSpec(
metadata=apimachinery.ObjectMeta(
labels={"app": "nginx"}
),
spec=k8score.PodSpec(
containers=[
k8score.Container(
name="nginx",
image="nginx:latest",
ports=[k8score.ContainerPort(container_port=80)]
)
]
)
)
)
).create()
# Create a Service
service = k8score.Service(
metadata=apimachinery.ObjectMeta(name="nginx"),
spec=k8score.ServiceSpec(
selector={"app": "nginx"},
ports=[k8score.ServicePort(port=80, target_port=80)]
)
).create()
# List Deployments
for deploy in k8sapps.Deployment.list():
print(f"Found deployment: {deploy.metadata.name}")
# Update a Deployment
deployment.spec.replicas = 5
deployment.save()
# Delete resources
k8score.Service.delete("nginx")
k8sapps.Deployment.delete("nginx")
```
### Using the Fluent Builder API
Cloudcoil provides a powerful fluent builder API for Kubernetes resources with full IDE support and rich autocomplete capabilities:
```python
from cloudcoil.models.kubernetes.apps.v1 import Deployment
from cloudcoil.models.kubernetes.core.v1 import Service
# Create a Deployment using the fluent builder
# The fluent style is great for one-liners and simple configurations
nginx_deployment = (
Deployment.builder()
# Metadata can be configured in a single chain for simple objects
.metadata(lambda metadata: metadata
.name("nginx")
.namespace("default")
)
# Complex nested structures can be built using nested lambda functions
.spec(lambda deployment_spec: deployment_spec
.replicas(3)
# Each level of nesting gets its own lambda for clarity
.selector(lambda label_selector: label_selector
.match_labels({"app": "nginx"})
)
.template(lambda pod_template: pod_template
.metadata(lambda pod_metadata: pod_metadata
.labels({"app": "nginx"})
)
.spec(lambda pod_spec: pod_spec
# Lists can be built using array literals with lambda items
.containers([
lambda container: container
.name("nginx")
.image("nginx:latest")
# Nested collections can use the add() helper
.ports(lambda port_list: port_list.add(
lambda port: port.container_port(80)
))
])
)
)
)
.build()
)
# Create a Service using the builder
service = (
Service.builder()
.metadata(lambda m: m
.name("nginx")
.namespace("default")
)
.spec(lambda s: s
.selector({"app": "nginx"})
.ports(lambda ports: ports.add(lambda p: p.container_port(80)))
)
.build()
)
```
The fluent builder provides:
- ✨ Full IDE support with detailed type information
- 🔍 Rich autocomplete for all fields and nested objects
- ⚡ Compile-time validation of your configuration
- 🎯 Clear and chainable API that guides you through resource creation
### Using the Context Manager Builder API
For complex nested resources, Cloudcoil also provides a context manager-based builder pattern that can make the structure more clear:
```python
from cloudcoil.models.kubernetes.apps.v1 import Deployment
from cloudcoil.models.kubernetes.core.v1 import Service
# Create a deployment using context managers
# Context managers are ideal for deeply nested structures
with Deployment.new() as nginx_deployment:
# Each context creates a clear visual scope
with nginx_deployment.metadata() as deployment_metadata:
deployment_metadata.name("nginx")
deployment_metadata.namespace("default")
with nginx_deployment.spec() as deployment_spec:
# Simple fields can be set directly
deployment_spec.replicas(3)
# Each nested object gets its own context
with deployment_spec.selector() as label_selector:
label_selector.match_labels({"app": "nginx"})
with deployment_spec.template() as pod_template:
with pod_template.metadata() as pod_metadata:
pod_metadata.labels({"app": "nginx"})
with pod_template.spec() as pod_spec:
# Collections use a parent context for the list
with pod_spec.containers() as container_list:
# And child contexts for each item
with container_list.add() as nginx_container:
nginx_container.name("nginx")
nginx_container.image("nginx:latest")
# Ports can be added one by one
with nginx_container.add_port() as container_port:
container_port.container_port(80)
final_deployment = nginx_deployment.build()
# Create a service using context managers
with Service.new() as nginx_service:
# Context managers make the structure very clear
with nginx_service.metadata() as service_metadata:
service_metadata.name("nginx")
service_metadata.namespace("default")
with nginx_service.spec() as service_spec:
# Simple fields can still be set directly
service_spec.selector({"app": "nginx"})
# Port configuration is more readable with contexts
with service_spec.add_port() as service_port:
service_port.port(80)
service_port.target_port(80)
final_service = nginx_service.build()
```
The context manager builder provides:
- 🎭 Clear visual nesting of resource structure
- 🔒 Automatic resource cleanup
- 🎯 Familiar Python context manager pattern
- ✨ Same great IDE support as the fluent builder
### Mixing Builder Styles
CloudCoil's intelligent builder system automatically detects which style you're using and provides appropriate IDE support:
```python
from cloudcoil.models.kubernetes.apps.v1 import Deployment
from cloudcoil import apimachinery
# Mixing styles lets you choose the best approach for each part
# The IDE automatically adapts to your chosen style at each level
with Deployment.new() as nginx_deployment:
# Direct object initialization with full type checking
nginx_deployment.metadata(apimachinery.ObjectMeta(
name="nginx",
namespace="default",
labels={"app": "nginx"}
))
with nginx_deployment.spec() as deployment_spec:
# IDE shows all available fields with types
deployment_spec.replicas(3)
# Fluent style with rich autocomplete
deployment_spec.selector(lambda sel: sel.match_labels({"app": "nginx"}))
# Context manager style with full type hints
with deployment_spec.template() as pod_template:
# Mix and match freely - IDE adjusts automatically
pod_template.metadata(apimachinery.ObjectMeta(labels={"app": "nginx"}))
with pod_template.spec() as pod_spec:
with pod_spec.containers() as container_list:
with container_list.add() as nginx_container:
# Complete IDE support regardless of style
nginx_container.name("nginx")
nginx_container.image("nginx:latest")
# Switch styles any time
nginx_container.ports(lambda ports: ports
.add(lambda p: p.container_port(80))
.add(lambda p: p.container_port(443))
)
final_deployment = nginx_deployment.build()
```
This flexibility allows you to:
- 🔀 Choose the most appropriate style for each part of your configuration
- 📖 Maximize readability for both simple and complex structures
- 🎨 Format your code according to your team's preferences
- 🧠 Get full IDE support with automatic style detection
- ✨ Enjoy rich autocomplete in all styles
- ⚡ Benefit from type checking across mixed styles
- 🎯 Receive immediate feedback on type errors
- 🔍 See documentation for all fields regardless of style
## 📚 Documentation
For complete documentation, visit [cloudcoil.github.io/cloudcoil](https://cloudcoil.github.io/cloudcoil)
## 📜 License
Apache License, Version 2.0 - see [LICENSE](LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "cloudcoil.models.kubernetes",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Sambhav Kothari <sambhavs.email@gmail.com>",
"keywords": "async, cloud-native, cloudcoil, cloudcoil-models, kubernetes, pydantic, python",
"author": null,
"author_email": "Sambhav Kothari <sambhavs.email@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/86/5d/3b49375453c610b010f8c969503a5f7b1a3bca5b073551fd51b195522292/cloudcoil_models_kubernetes-1.32.1.3.tar.gz",
"platform": null,
"description": "# cloudcoil-models-kubernetes\n\nVersioned kubernetes models for cloudcoil.\n> [!WARNING] \n> This repository is auto-generated from the [cloudcoil repository](https://github.com/cloudcoil/cloudcoil/tree/main/models/kubernetes). Please do not submit pull requests here. Instead, submit them to the main repository at https://github.com/cloudcoil/cloudcoil.\n\n\n## \ud83d\udd27 Installation\n\n> [!NOTE]\n> For versioning information and compatibility, see the [Versioning Guide](https://github.com/cloudcoil/cloudcoil/blob/main/VERSIONING.md).\n\nUsing [uv](https://github.com/astral-sh/uv) (recommended):\n\n```bash\n# Install with Kubernetes support\nuv add cloudcoil.models.kubernetes\n```\n\nUsing pip:\n\n```bash\npip install cloudcoil.models.kubernetes\n```\n\n## \ud83d\udca1 Examples\n\n### Using Kubernetes Models\n\n```python\nfrom cloudcoil import apimachinery\nimport cloudcoil.models.kubernetes.core.v1 as k8score\nimport cloudcoil.models.kubernetes.apps.v1 as k8sapps\n\n# Create a Deployment\ndeployment = k8sapps.Deployment(\n metadata=apimachinery.ObjectMeta(name=\"nginx\"),\n spec=k8sapps.DeploymentSpec(\n replicas=3,\n selector=apimachinery.LabelSelector(\n match_labels={\"app\": \"nginx\"}\n ),\n template=k8score.PodTemplateSpec(\n metadata=apimachinery.ObjectMeta(\n labels={\"app\": \"nginx\"}\n ),\n spec=k8score.PodSpec(\n containers=[\n k8score.Container(\n name=\"nginx\",\n image=\"nginx:latest\",\n ports=[k8score.ContainerPort(container_port=80)]\n )\n ]\n )\n )\n )\n).create()\n\n# Create a Service\nservice = k8score.Service(\n metadata=apimachinery.ObjectMeta(name=\"nginx\"),\n spec=k8score.ServiceSpec(\n selector={\"app\": \"nginx\"},\n ports=[k8score.ServicePort(port=80, target_port=80)]\n )\n).create()\n\n# List Deployments\nfor deploy in k8sapps.Deployment.list():\n print(f\"Found deployment: {deploy.metadata.name}\")\n\n# Update a Deployment\ndeployment.spec.replicas = 5\ndeployment.save()\n\n# Delete resources\nk8score.Service.delete(\"nginx\")\nk8sapps.Deployment.delete(\"nginx\")\n```\n\n### Using the Fluent Builder API\n\nCloudcoil provides a powerful fluent builder API for Kubernetes resources with full IDE support and rich autocomplete capabilities:\n\n```python\nfrom cloudcoil.models.kubernetes.apps.v1 import Deployment\nfrom cloudcoil.models.kubernetes.core.v1 import Service\n\n# Create a Deployment using the fluent builder\n# The fluent style is great for one-liners and simple configurations\nnginx_deployment = (\n Deployment.builder()\n # Metadata can be configured in a single chain for simple objects\n .metadata(lambda metadata: metadata\n .name(\"nginx\")\n .namespace(\"default\")\n )\n # Complex nested structures can be built using nested lambda functions\n .spec(lambda deployment_spec: deployment_spec\n .replicas(3)\n # Each level of nesting gets its own lambda for clarity\n .selector(lambda label_selector: label_selector\n .match_labels({\"app\": \"nginx\"})\n )\n .template(lambda pod_template: pod_template\n .metadata(lambda pod_metadata: pod_metadata\n .labels({\"app\": \"nginx\"})\n )\n .spec(lambda pod_spec: pod_spec\n # Lists can be built using array literals with lambda items\n .containers([\n lambda container: container\n .name(\"nginx\")\n .image(\"nginx:latest\")\n # Nested collections can use the add() helper\n .ports(lambda port_list: port_list.add(\n lambda port: port.container_port(80)\n ))\n ])\n )\n )\n )\n .build()\n)\n\n# Create a Service using the builder\nservice = (\n Service.builder()\n .metadata(lambda m: m\n .name(\"nginx\")\n .namespace(\"default\")\n )\n .spec(lambda s: s\n .selector({\"app\": \"nginx\"})\n .ports(lambda ports: ports.add(lambda p: p.container_port(80)))\n )\n .build()\n)\n```\n\nThe fluent builder provides:\n- \u2728 Full IDE support with detailed type information\n- \ud83d\udd0d Rich autocomplete for all fields and nested objects\n- \u26a1 Compile-time validation of your configuration\n- \ud83c\udfaf Clear and chainable API that guides you through resource creation\n\n### Using the Context Manager Builder API\n\nFor complex nested resources, Cloudcoil also provides a context manager-based builder pattern that can make the structure more clear:\n\n```python\nfrom cloudcoil.models.kubernetes.apps.v1 import Deployment\nfrom cloudcoil.models.kubernetes.core.v1 import Service\n\n# Create a deployment using context managers\n# Context managers are ideal for deeply nested structures\nwith Deployment.new() as nginx_deployment:\n # Each context creates a clear visual scope\n with nginx_deployment.metadata() as deployment_metadata:\n deployment_metadata.name(\"nginx\")\n deployment_metadata.namespace(\"default\")\n \n with nginx_deployment.spec() as deployment_spec:\n # Simple fields can be set directly\n deployment_spec.replicas(3)\n \n # Each nested object gets its own context\n with deployment_spec.selector() as label_selector:\n label_selector.match_labels({\"app\": \"nginx\"})\n \n with deployment_spec.template() as pod_template:\n with pod_template.metadata() as pod_metadata:\n pod_metadata.labels({\"app\": \"nginx\"})\n \n with pod_template.spec() as pod_spec:\n # Collections use a parent context for the list\n with pod_spec.containers() as container_list:\n # And child contexts for each item\n with container_list.add() as nginx_container:\n nginx_container.name(\"nginx\")\n nginx_container.image(\"nginx:latest\")\n # Ports can be added one by one\n with nginx_container.add_port() as container_port:\n container_port.container_port(80)\n\nfinal_deployment = nginx_deployment.build()\n\n# Create a service using context managers\nwith Service.new() as nginx_service:\n # Context managers make the structure very clear\n with nginx_service.metadata() as service_metadata:\n service_metadata.name(\"nginx\")\n service_metadata.namespace(\"default\")\n \n with nginx_service.spec() as service_spec:\n # Simple fields can still be set directly\n service_spec.selector({\"app\": \"nginx\"})\n # Port configuration is more readable with contexts\n with service_spec.add_port() as service_port:\n service_port.port(80)\n service_port.target_port(80)\n\nfinal_service = nginx_service.build()\n```\n\nThe context manager builder provides:\n- \ud83c\udfad Clear visual nesting of resource structure\n- \ud83d\udd12 Automatic resource cleanup\n- \ud83c\udfaf Familiar Python context manager pattern\n- \u2728 Same great IDE support as the fluent builder\n\n### Mixing Builder Styles\n\nCloudCoil's intelligent builder system automatically detects which style you're using and provides appropriate IDE support:\n\n```python\nfrom cloudcoil.models.kubernetes.apps.v1 import Deployment\nfrom cloudcoil import apimachinery\n\n# Mixing styles lets you choose the best approach for each part\n# The IDE automatically adapts to your chosen style at each level\nwith Deployment.new() as nginx_deployment:\n # Direct object initialization with full type checking\n nginx_deployment.metadata(apimachinery.ObjectMeta(\n name=\"nginx\",\n namespace=\"default\",\n labels={\"app\": \"nginx\"}\n ))\n \n with nginx_deployment.spec() as deployment_spec:\n # IDE shows all available fields with types\n deployment_spec.replicas(3)\n # Fluent style with rich autocomplete\n deployment_spec.selector(lambda sel: sel.match_labels({\"app\": \"nginx\"}))\n \n # Context manager style with full type hints\n with deployment_spec.template() as pod_template:\n # Mix and match freely - IDE adjusts automatically\n pod_template.metadata(apimachinery.ObjectMeta(labels={\"app\": \"nginx\"}))\n with pod_template.spec() as pod_spec:\n with pod_spec.containers() as container_list:\n with container_list.add() as nginx_container:\n # Complete IDE support regardless of style\n nginx_container.name(\"nginx\")\n nginx_container.image(\"nginx:latest\")\n # Switch styles any time\n nginx_container.ports(lambda ports: ports\n .add(lambda p: p.container_port(80))\n .add(lambda p: p.container_port(443))\n )\n\nfinal_deployment = nginx_deployment.build()\n```\n\nThis flexibility allows you to:\n- \ud83d\udd00 Choose the most appropriate style for each part of your configuration\n- \ud83d\udcd6 Maximize readability for both simple and complex structures\n- \ud83c\udfa8 Format your code according to your team's preferences\n- \ud83e\udde0 Get full IDE support with automatic style detection\n- \u2728 Enjoy rich autocomplete in all styles\n- \u26a1 Benefit from type checking across mixed styles\n- \ud83c\udfaf Receive immediate feedback on type errors\n- \ud83d\udd0d See documentation for all fields regardless of style\n\n## \ud83d\udcda Documentation\n\nFor complete documentation, visit [cloudcoil.github.io/cloudcoil](https://cloudcoil.github.io/cloudcoil)\n\n## \ud83d\udcdc License\n\nApache License, Version 2.0 - see [LICENSE](LICENSE)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Versioned kubernetes models for cloudcoil",
"version": "1.32.1.3",
"project_urls": {
"Changelog": "https://github.com/cloudcoil/models-kubernetes/releases",
"Documentation": "https://cloudcoil.github.io/cloudcoil",
"Homepage": "https://github.com/cloudcoil/cloudcoil",
"Issues": "https://github.com/cloudcoil/models-kubernetes/issues",
"Repository": "https://github.com/cloudcoil/models-kubernetes"
},
"split_keywords": [
"async",
" cloud-native",
" cloudcoil",
" cloudcoil-models",
" kubernetes",
" pydantic",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "447cdb13900309d57285e1724279e3dc00b89b9b2ba378ae0fd6a84b9120b896",
"md5": "a1751efdfb86df1e6b97cf5fe6972dd9",
"sha256": "58353d789b12dce2620d67b1d70b62e2dc272a3a1a5d464f32de8c940db8ae6f"
},
"downloads": -1,
"filename": "cloudcoil_models_kubernetes-1.32.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a1751efdfb86df1e6b97cf5fe6972dd9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 349524,
"upload_time": "2025-02-10T04:25:00",
"upload_time_iso_8601": "2025-02-10T04:25:00.351148Z",
"url": "https://files.pythonhosted.org/packages/44/7c/db13900309d57285e1724279e3dc00b89b9b2ba378ae0fd6a84b9120b896/cloudcoil_models_kubernetes-1.32.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "865d3b49375453c610b010f8c969503a5f7b1a3bca5b073551fd51b195522292",
"md5": "72d9e70b7f50bdd22ba9f6a9a282905e",
"sha256": "a0ba052d756878bf50637553e9670e2ea102ba82a25f3b1da818d4d9426f051b"
},
"downloads": -1,
"filename": "cloudcoil_models_kubernetes-1.32.1.3.tar.gz",
"has_sig": false,
"md5_digest": "72d9e70b7f50bdd22ba9f6a9a282905e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 364158,
"upload_time": "2025-02-10T04:25:01",
"upload_time_iso_8601": "2025-02-10T04:25:01.948482Z",
"url": "https://files.pythonhosted.org/packages/86/5d/3b49375453c610b010f8c969503a5f7b1a3bca5b073551fd51b195522292/cloudcoil_models_kubernetes-1.32.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-10 04:25:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cloudcoil",
"github_project": "models-kubernetes",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cloudcoil.models.kubernetes"
}