Class: HubClustersCreator::Providers::Bootstrap
- Inherits:
-
Object
- Object
- HubClustersCreator::Providers::Bootstrap
- Includes:
- Logging, Utils::Template
- Defined in:
- lib/hub-clusters-creator/providers/bootstrap.rb
Overview
Bootstrap the provider of the bootstrap job rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULT_CLUSTER_ADMIN_ROLE =
"apiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: sysadmin\n namespace: kube-system\n"- DEFAULT_CLUSTER_ADMIN_BINDING =
"apiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: cluster:admin\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n name: sysadmin\n namespace: kube-system\n"- BOOTSTRAP_IMAGE =
is the name of the container image
'quay.io/appvia/hub-bootstrap:latest'- BOOTSTRAP_NAME =
is the name of the job
'bootstrap'- BOOTSTRAP_NAMESPACE =
is the name of the namespace the job lives in
'kube-system'
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#bootstrap(image = BOOTSTRAP_IMAGE) ⇒ Object
provision_bootstrap is responsible for setting up the agents and strapper a) pushes in the configuration for the bootstrapper b) rolls out the kubernetes job to bootstrap the cluster c) grabs the services and provisions the dns rubocop:disable Metrics/AbcSize.
-
#initialize(name, client, config) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
Methods included from Logging
Constructor Details
#initialize(name, client, config) ⇒ Bootstrap
Returns a new instance of Bootstrap.
62 63 64 65 66 |
# File 'lib/hub-clusters-creator/providers/bootstrap.rb', line 62 def initialize(name, client, config) @name = name @client = client @config = config end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
60 61 62 |
# File 'lib/hub-clusters-creator/providers/bootstrap.rb', line 60 def client @client end |
#config ⇒ Object
Returns the value of attribute config.
60 61 62 |
# File 'lib/hub-clusters-creator/providers/bootstrap.rb', line 60 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
60 61 62 |
# File 'lib/hub-clusters-creator/providers/bootstrap.rb', line 60 def name @name end |
Instance Method Details
#bootstrap(image = BOOTSTRAP_IMAGE) ⇒ Object
provision_bootstrap is responsible for setting up the agents and strapper a) pushes in the configuration for the bootstrapper b) rolls out the kubernetes job to bootstrap the cluster c) grabs the services and provisions the dns rubocop:disable Metrics/AbcSize
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/hub-clusters-creator/providers/bootstrap.rb', line 73 def bootstrap(image = BOOTSTRAP_IMAGE) client.wait_for_kubeapi info 'applying the default cluster admin service account and role' client.kubectl(DEFAULT_CLUSTER_ADMIN_ROLE) client.kubectl(DEFAULT_CLUSTER_ADMIN_BINDING) info 'attempting to bootstrap the cluster configuration' client.kubectl(generate_bootstrap_config) client.kubectl(generate_bootstrap_job(image)) info 'waiting for the bootstrap to complete successfully' name = BOOTSTRAP_NAME namespace = BOOTSTRAP_NAMESPACE client.wait(name, namespace, 'jobs', version: 'batch/v1', interval: 10, timeout: 500) do |x| x.status.nil? || x.status['succeeded'] <= 0 ? false : true end info 'bootstrap has successfully completed' info 'waiting for grafana ingress load balancer to be provisioned' # @step: wait for the ingress to appaar and provision and grab the address @client.wait('loki-grafana', 'loki', 'ingresses', version: 'extensions/v1beta1') do |x| x.status.loadBalancer.ingress.empty? ? false : true end end |