class Kubernetes::Resources::Deployments

Overview

High-level API for Deployment resources.

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

Defined in:

resources/deployments.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Client) #

Instance Method Detail

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

Delete a deployment.


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


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

Paginate through deployments.


def read_namespaced(namespace : String, name : String) : Deployment #

Read a single deployment.


def ready?(namespace : String, name : String) : Bool #

Check if a deployment is ready.


def replicas(namespace : String, name : String) : Int32 #

Get current replica count.


def 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"

def 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"

def 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!"

def watch_namespaced(namespace : String, resource_version = "0", timeout = 10.minutes, & : Watch(Deployment) -> Nil) #

Watch deployments for changes.