class Kube::Client

Overview

Top-level client wrapper. Uses a Transport instance to talk to the kube API. Offers access to Kube::ApiClient and ResourceClient instances.

Defined in:

kube-client/version.cr
kube/client.cr

Constant Summary

VERSION = {{ (`shards version \"/home/runner/work/kube-client.cr/kube-client.cr/src/kube-client\"`).chomp.stringify }}

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(transport : Kube::Transport, namespace : String | Nil = nil) #

[View source]

Class Method Detail

def self.autoconfig(namespace : String | Nil = nil, **options) : Kube::Client #

Attempts to create a K8s::Client instance automatically using environment variables, existing configuration files or in cluster configuration.

Look-up order:

  • KUBE_TOKEN, KUBE_CA, KUBE_SERVER environment variables
  • KUBECONFIG environment variable
  • $HOME/.kube/config file
  • In cluster configuration

Will raise when no means of configuration is available


[View source]
def self.config(config : Kube::Config, namespace : String | Nil = nil, **options) : Kube::Client #

[View source]
def self.in_cluster_config(namespace : String | Nil = nil, **options) : Kube::Client #

An Kube::Client instance from in-cluster config within a kube pod, using the kubernetes service envs and serviceaccount secrets


[View source]
def self.logger #

[View source]

Instance Method Detail

def api(api_version : String = "v1") : Kube::ApiClient #

api_version [String] "group/version" or "version" (core)


[View source]
def api_groups : Array(String) #

Cached /apis preferred group apiVersions


[View source]
def api_groups! : Array(String) #

Force-update /apis cache. Required if creating new CRDs/apiservices.


[View source]
def apis(api_versions = nil, prefetch_resources = false, skip_missing = false, skip_forbidden = true, skip_unknown = true) : Array(Kube::ApiClient) #

api_versions [Array(String)] defaults to all APIs prefetch_resources [Bool] prefetch any missing api_resources for each api_version skip_missing [Bool] return Kube::ApiClient without api_resources? if 404


[View source]
def client_for_resource(resource : T.class | T, namespace : String | Nil = nil) forall T #

[View source]
def create_resource(resource : T) forall T #

[View source]
def delete_resource(resource : T, **options) forall T #

[View source]
def get_resource(resource : T) forall T #

[View source]
def get_resources(resources : Enumerable(T)) forall T #

[View source]
def list_resources(resource_list : Array(Kube::ResourceClient) | Nil = nil, **options) #

Pipeline list requests for multiple resource types.

Returns flattened array with mixed resource kinds.


[View source]
def logger #

[View source]
def patch_resource(resource, attrs) #

[View source]
def resources(namespace : String | Nil = nil) #

[View source]
def update_resource(resource : T) forall T #

[View source]
def version : K8S::Apimachinery::Version::Info #

[View source]