Class: Gitlab::QA::Service::ClusterProvider::K3d

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/qa/service/cluster_provider/k3d.rb

Constant Summary

Constants inherited from Base

Base::GITLAB_REGISTRY

Instance Attribute Summary

Attributes inherited from Base

#create_args

Instance Method Summary collapse

Methods inherited from Base

#cluster_name

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

shell

Instance Method Details

#create_registry_mirrorObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/qa/service/cluster_provider/k3d.rb', line 8

def create_registry_mirror
  return if registry_mirror_exists?('registry-gitlab')

  Runtime::Env.require_qa_container_registry_access_token!

  shell <<~CMD
    k3d registry create registry-gitlab \
      -p 5000 \
      --proxy-remote-url https://#{GITLAB_REGISTRY} \
      --proxy-password #{Runtime::Env.gitlab_username} \
      --proxy-username #{Runtime::Env.qa_container_registry_access_token} \
      -v tmp/registry-gitlab:/var/lib/registry
  CMD

  File.write('tmp/registry-mirror.yml', registry_mirror)

  create_args << %w[--registry-use k3d-registry-gitlab:5000 --registry-config tmp/registry-mirror.yml]
end

#setupObject



31
32
33
34
35
# File 'lib/gitlab/qa/service/cluster_provider/k3d.rb', line 31

def setup
  shell "k3d cluster create #{cluster_name} #{create_args&.join(' ')}"

  install_local_storage
end

#teardownObject



37
38
39
# File 'lib/gitlab/qa/service/cluster_provider/k3d.rb', line 37

def teardown
  shell "k3d cluster delete #{cluster_name}"
end

#validate_dependenciesObject



27
28
29
# File 'lib/gitlab/qa/service/cluster_provider/k3d.rb', line 27

def validate_dependencies
  find_executable('k3d') || raise("You must first install `k3d` executable to run these tests.")
end