Class: Porkadot::Assets::Bootstrap

Inherits:
Object
  • Object
show all
Includes:
Porkadot::Assets
Defined in:
lib/porkadot/assets/bootstrap.rb

Constant Summary collapse

TEMPLATE_DIR =
File.join(File.dirname(__FILE__), "bootstrap")

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Porkadot::Assets

#render_erb, #render_secrets_erb

Constructor Details

#initialize(global_config) ⇒ Bootstrap

Returns a new instance of Bootstrap.



12
13
14
15
16
17
# File 'lib/porkadot/assets/bootstrap.rb', line 12

def initialize global_config
  @global_config = global_config
  @config = global_config.bootstrap
  @certs_config = global_config.certs
  @logger = global_config.logger
end

Instance Attribute Details

#certs_configObject (readonly)

Returns the value of attribute certs_config.



9
10
11
# File 'lib/porkadot/assets/bootstrap.rb', line 9

def certs_config
  @certs_config
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/porkadot/assets/bootstrap.rb', line 8

def config
  @config
end

#global_configObject (readonly)

Returns the value of attribute global_config.



7
8
9
# File 'lib/porkadot/assets/bootstrap.rb', line 7

def global_config
  @global_config
end

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/porkadot/assets/bootstrap.rb', line 10

def logger
  @logger
end

Instance Method Details

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/porkadot/assets/bootstrap.rb', line 19

def render
  logger.info "--> Rendering bootstrap manifests"
  unless File.directory?(config.bootstrap_path)
    FileUtils.mkdir_p(config.bootstrap_path)
  end
  render_secrets
  render_erb 'bootstrap/kubeconfig-bootstrap.yaml'
  render_erb 'bootstrap/kube-proxy-bootstrap.yaml'
  render_manifests
  render_erb 'install.sh'
  render_erb 'cleanup.sh'
end

#render_manifestsObject



40
41
42
43
44
45
46
47
48
# File 'lib/porkadot/assets/bootstrap.rb', line 40

def render_manifests
  unless File.directory?(config.manifests_path)
    FileUtils.mkdir_p(config.manifests_path)
  end
  render_erb 'manifests/kube-apiserver.bootstrap.yaml'
  render_erb 'manifests/kube-controller-manager.bootstrap.yaml'
  render_erb 'manifests/kube-scheduler.bootstrap.yaml'
  render_erb 'manifests/kube-proxy.bootstrap.yaml'
end

#render_secretsObject



32
33
34
35
36
37
38
# File 'lib/porkadot/assets/bootstrap.rb', line 32

def render_secrets
  logger.info "----> Secrets"
  unless File.directory?(config.secrets_path)
    FileUtils.mkdir_p(config.secrets_path)
  end
  FileUtils.cp_r(Dir.glob(File.join(certs_config.certs_root_dir, '*')), config.secrets_path)
end