class
Kubernetes::Resources::Deployments
- Kubernetes::Resources::Deployments
- Reference
- Object
Overview
High-level API for Deployment resources.
Provides type-safe methods plus helpful utilities like scale and restart.
Defined in:
resources/deployments.crConstructors
Instance Method Summary
-
#delete_namespaced(namespace : String, name : String) : Status
Delete a deployment.
-
#list_namespaced(namespace : String, label_selector : String | Nil = nil, field_selector : String | Nil = nil, limit : Int32 | Nil = nil) : List(Deployment)
List all deployments in a namespace.
-
#paginate_namespaced(namespace : String, label_selector : String | Nil = nil, field_selector : String | Nil = nil, page_size : Int32 = 500, &)
Paginate through deployments.
-
#read_namespaced(namespace : String, name : String) : Deployment
Read a single deployment.
-
#ready?(namespace : String, name : String) : Bool
Check if a deployment is ready.
-
#replicas(namespace : String, name : String) : Int32
Get current replica count.
-
#restart(namespace : String, name : String) : Deployment
Restart a deployment by adding a restart annotation.
-
#scale(namespace : String, name : String, replicas : Int32) : Deployment
Scale a deployment to a specific number of replicas.
-
#wait_until_ready(namespace : String, name : String, timeout = 5.minutes) : Deployment
Wait for a deployment to be ready.
-
#watch_namespaced(namespace : String, resource_version = "0", timeout = 10.minutes, & : Watch(Deployment) -> Nil)
Watch deployments for changes.
Constructor Detail
Instance Method Detail
List all deployments in a namespace.
Paginate through deployments.
Restart a deployment by adding a restart annotation.
This triggers a rollout restart by updating the pod template with a restart timestamp annotation.
Example:
deployment = k8s.v1.deployments.restart("default", "nginx")
puts "Deployment restarted"
Scale a deployment to a specific number of replicas.
This uses a JSON merge patch to update only the replicas field.
Example:
deployment = k8s.v1.deployments.scale("default", "nginx", replicas: 10)
puts "Scaled to #{deployment.spec.try(&.replicas)} replicas"
Wait for a deployment to be ready.
A deployment is considered ready when:
- status.readyReplicas == spec.replicas
- status.updatedReplicas == spec.replicas
Example:
deployment = k8s.v1.deployments.wait_until_ready("default", "nginx")
puts "Deployment is ready!"
Watch deployments for changes.