class
Kubernetes::Resources::Pods
- Kubernetes::Resources::Pods
- Reference
- Object
Overview
High-level API for Pod resources.
Provides type-safe methods for working with Pods without blocks, plus helpful utility methods like waiting for readiness and fetching logs.
Defined in:
resources/pods.crConstructors
Instance Method Summary
-
#delete_namespaced(namespace : String, name : String) : Status
Delete a pod.
-
#exec(namespace : String, name : String, command : Array(String), container : String | Nil = nil) : String
Execute a command in a pod (requires WebSocket support - planned for v1.0.0).
-
#list_namespaced(namespace : String, label_selector : String | Nil = nil, field_selector : String | Nil = nil, limit : Int32 | Nil = nil) : List(Pod)
List all pods in a namespace.
-
#logs(namespace : String, name : String, container : String | Nil = nil, follow : Bool = false, tail_lines : Int32 | Nil = nil) : String
Get logs from a pod.
-
#paginate_namespaced(namespace : String, label_selector : String | Nil = nil, field_selector : String | Nil = nil, page_size : Int32 = 500, &)
Paginate through all pods in a namespace.
-
#read_namespaced(namespace : String, name : String) : Pod
Read a single pod.
-
#ready?(namespace : String, name : String) : Bool
Check if a pod is ready.
-
#running?(namespace : String, name : String) : Bool
Check if a pod is running.
-
#wait_until_ready(namespace : String, name : String, timeout = 5.minutes) : Pod
Wait for a pod to be ready.
-
#wait_until_running(namespace : String, name : String, timeout = 5.minutes) : Pod
Wait for a pod to reach Running phase.
-
#watch_namespaced(namespace : String, resource_version = "0", timeout = 10.minutes, & : Watch(Pod) -> Nil)
Watch pods for changes.
Constructor Detail
Instance Method Detail
Delete a pod.
Example:
status = k8s.v1.pods.delete_namespaced("default", "nginx-12345")
Execute a command in a pod (requires WebSocket support - planned for v1.0.0).
Example:
output = k8s.v1.pods.exec("default", "nginx", ["ls", "-la"])
List all pods in a namespace.
Example:
pods = k8s.v1.pods.list_namespaced("default")
pods.items.each { |pod| puts pod.metadata.name }
Get logs from a pod.
Example:
logs = k8s.v1.pods.logs("default", "nginx")
puts logs
# Get logs from specific container
logs = k8s.v1.pods.logs("default", "nginx", container: "app")
Paginate through all pods in a namespace.
Example:
k8s.v1.pods.paginate_namespaced("default", page_size: 100) do |pod|
puts pod.metadata.name
end
Read a single pod.
Example:
pod = k8s.v1.pods.read_namespaced("default", "nginx-12345")
puts pod.status.try(&.phase)
Check if a pod is ready.
Example:
if k8s.v1.pods.ready?("default", "nginx")
puts "Pod is ready"
end
Check if a pod is running.
Example:
if k8s.v1.pods.running?("default", "nginx")
puts "Pod is running"
end
Wait for a pod to be ready.
This method polls the pod status until all containers are ready or the timeout is reached.
Example:
pod = k8s.v1.pods.wait_until_ready("default", "nginx", timeout: 5.minutes)
puts "Pod is ready!"
Wait for a pod to reach Running phase.
Example:
pod = k8s.v1.pods.wait_until_running("default", "nginx")