Class: Porkadot::Assets::Kubernetes

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Porkadot::Assets

#render_erb, #render_secrets_erb

Constructor Details

#initialize(global_config) ⇒ Kubernetes

Returns a new instance of Kubernetes.



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

def initialize global_config
  @global_config = global_config
  @config = global_config.kubernetes
  @logger = global_config.logger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#global_configObject (readonly)

Returns the value of attribute global_config.



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

def global_config
  @global_config
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

Instance Method Details

#prune_allowlistObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/porkadot/assets/kubernetes.rb', line 38

def prune_allowlist
  return %w[
    apiextensions.k8s.io/v1/customresourcedefinition
    apps/v1/daemonset
    apps/v1/deployment
    core/v1/configmap
    core/v1/namespace
    core/v1/service
    core/v1/secret
    core/v1/serviceaccount
    policy/v1/poddisruptionbudget
    rbac.authorization.k8s.io/v1/clusterrole
    rbac.authorization.k8s.io/v1/clusterrolebinding
    rbac.authorization.k8s.io/v1/role
    rbac.authorization.k8s.io/v1/rolebinding
    admissionregistration.k8s.io/v1/validatingwebhookconfiguration
  ]
end

#renderObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/porkadot/assets/kubernetes.rb', line 18

def render
  logger.info "--> Rendering kubernetes manifests"
  render_erb 'manifests/porkadot.yaml'
  render_erb 'manifests/kubelet.yaml'
  render_erb "manifests/kube-apiserver.yaml"
  render_secrets_erb "manifests/kube-apiserver.secrets.yaml"
  render_erb "manifests/kube-proxy.yaml"
  render_erb "manifests/kube-scheduler.yaml"
  render_erb "manifests/kube-controller-manager.yaml"
  render_secrets_erb "manifests/kube-controller-manager.secrets.yaml"
  render_secrets_erb "kubeconfig.yaml"
  render_erb 'manifests/kustomization.yaml'
  render_erb 'kustomization.yaml', force: false
  render_erb 'install.sh', prune_allowlist: prune_allowlist
  render_secrets_erb 'install.secrets.sh'

  addons = Addons.new(global_config)
  addons.render
end