class

Kubernetes::Resources::Deployments

Inherits Reference < Object

High-level API for Deployment resources.

Provides type-safe methods plus helpful utilities like scale and restart.

Constructors

new(client : Client)
Source

Instance methods

delete_namespaced(namespace : String, name : String) : Status

Delete a deployment.

Source
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.

Source
paginate_namespaced(namespace : String, label_selector : String | Nil = nil, field_selector : String | Nil = nil, page_size : Int32 = 500, &)

Paginate through deployments.

Source
read_namespaced(namespace : String, name : String) : Deployment

Read a single deployment.

Source
ready?(namespace : String, name : String) : Bool

Check if a deployment is ready.

Source
replicas(namespace : String, name : String) : Int32

Get current replica count.

Source
restart(namespace : String, name : String) : Deployment

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"
Source
scale(namespace : String, name : String, replicas : Int32) : Deployment

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"
Source
wait_until_ready(namespace : String, name : String, timeout = 5.minutes) : Deployment

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!"
Source
watch_namespaced(namespace : String, resource_version = "0", timeout = 10.minutes, & : Watch(Deployment) -> Nil)

Watch deployments for changes.

Source

Nested types