Class: DTK::CrdClient
- Inherits:
-
Object
- Object
- DTK::CrdClient
- Defined in:
- lib/crd_client.rb
Constant Summary collapse
- DEFAULT_API_VERSION =
include Singleton
'v1alpha1'
- KubeclientVersions =
{}
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(apiVersion) ⇒ CrdClient
constructor
opts can have keys kubernetes_client - already instantiated kubernetes client.
Constructor Details
#initialize(apiVersion) ⇒ CrdClient
opts can have keys
kubernetes_client - already instantiated kubernetes client
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/crd_client.rb', line 40 def initialize(apiVersion) = {} = { bearer_token_file: '/var/run/secrets/kubernetes.io/serviceaccount/token' } if File.exist?("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt") [:ca_file] = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" end = { socket_class: Celluloid::IO::TCPSocket, ssl_socket_class: Celluloid::IO::SSLSocket } @kubeclient = Kubeclient::Client.new( 'https://kubernetes.default.svc/apis/', "dtk.io/#{apiVersion}", auth_options: , ssl_options: , socket_options: ) @kubeclient.discover unless @kubeclient.discovered @kubeclient end |
Instance Attribute Details
Class Method Details
.get_kubeclient(opts) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/crd_client.rb', line 17 def self.get_kubeclient(opts) if @kubeclient = opts[:kubeclient] @kubeclient else kubeclient_version(opts) end end |
.kubeclient_version(opts = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/crd_client.rb', line 25 def self.kubeclient_version(opts = {}) version = opts[:apiVersion] || DEFAULT_API_VERSION if existing_version = KubeclientVersions[version] return existing_version else new_instance = new(version).kubeclient KubeclientVersions[version] = new_instance new_instance end end |