Class: Rubernetes::Auth::ServiceAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/rubernetes/auth/service_account.rb

Overview

This class is used as a serviceaccount’s crt/token options wrapper. It assumes that the serviceaccount crt/token is mounted at ‘/var/run/secrets/kubernetes.io/serviceaccount`.

Constant Summary collapse

CRT_PATH =
'/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'
TOKEN_PATH =
'/var/run/secrets/kubernetes.io/serviceaccount/token'

Instance Method Summary collapse

Constructor Details

#initializeServiceAccount

Returns a new instance of ServiceAccount.



12
# File 'lib/rubernetes/auth/service_account.rb', line 12

def initialize; end

Instance Method Details

#api_endpointObject



14
15
16
# File 'lib/rubernetes/auth/service_account.rb', line 14

def api_endpoint
  @api_endpoint ||= "#{ssl_options.empty? ? 'http' : 'https'}://kubernetes.default.svc"
end

#auth_optionsObject



26
27
28
29
30
# File 'lib/rubernetes/auth/service_account.rb', line 26

def auth_options
  @auth_options ||= {
    bearer_token_file: TOKEN_PATH
  }
end

#ssl_optionsObject



18
19
20
21
22
23
24
# File 'lib/rubernetes/auth/service_account.rb', line 18

def ssl_options
  @ssl_options ||= if File.exist?(CRT_PATH)
                     { ca_file: CRT_PATH }
                   else
                     {}
                   end
end