Class: Gitlab::QA::Service::KubernetesCluster

Inherits:
Object
  • Object
show all
Includes:
Gitlab::QA::Support::Shellout
Defined in:
lib/gitlab/qa/service/kubernetes_cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::QA::Support::Shellout

shell

Constructor Details

#initialize(provider_class: QA::Service::ClusterProvider::K3d) ⇒ KubernetesCluster

Returns a new instance of KubernetesCluster.



13
14
15
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 13

def initialize(provider_class: QA::Service::ClusterProvider::K3d)
  @provider = provider_class.new
end

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider.



11
12
13
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 11

def provider
  @provider
end

Instance Method Details

#apply_manifest(manifest) ⇒ Object



46
47
48
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 46

def apply_manifest(manifest)
  shell('kubectl apply -f -', stdin_data: manifest)
end

#cluster_nameObject



30
31
32
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 30

def cluster_name
  @provider.cluster_name
end

#create!Object



17
18
19
20
21
22
23
24
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 17

def create!
  validate_dependencies

  @provider.validate_dependencies
  @provider.setup

  self
end

#create_registry_mirrorObject



38
39
40
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 38

def create_registry_mirror
  @provider.create_registry_mirror
end

#create_secret(secret, secret_name) ⇒ Object



42
43
44
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 42

def create_secret(secret, secret_name)
  shell("kubectl create secret generic #{secret_name} --from-literal=token='#{secret}'", mask_secrets: [secret])
end

#remove!Object



26
27
28
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 26

def remove!
  @provider.teardown
end

#to_sObject



34
35
36
# File 'lib/gitlab/qa/service/kubernetes_cluster.rb', line 34

def to_s
  cluster_name
end