Kubernetes::Resources::Deployments
High-level API for Deployment resources.
Provides type-safe methods plus helpful utilities like scale and restart.
Constructors
new(client : Client)
SourceInstance methods
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.
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!"