Class: Kraaken::Cloud

Inherits:
Object
  • Object
show all
Defined in:
lib/kraaken/cloud.rb

Direct Known Subclasses

Hetzner

Defined Under Namespace

Classes: Hetzner, Server

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Cloud

Returns a new instance of Cloud.



10
11
12
# File 'lib/kraaken/cloud.rb', line 10

def initialize(config:)
  @config = config
end

Instance Method Details

#prepare(name) ⇒ Object



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

def prepare(name)
  new_relic = config.credentials.credential("new-relic")
  config.ssh.connect(name) do |ssh|
    ssh.run <<~BASH
      sudo apt update
      sudo apt upgrade -y
      sudo apt install -y docker.io docker-compose
      sudo docker network create cloudflaretunnel
      sudo gpasswd -a $USER docker
      curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=#{new_relic.password} NEW_RELIC_ACCOUNT_ID=#{new_relic.username} NEW_RELIC_REGION=EU /usr/local/bin/newrelic install -y
    BASH
  end
  logger.increment_progress by: 25
  config.ssh.connect(name) do |ssh|
    ssh.run "mkdir -p ~/traefik"
    ssh.write_file "~/traefik/docker-compose.yml", config.load_template("traefik-compose.yml", tunnel_token: config.ingress.tunnel_token_for_name(name))
    logger.increment_progress by: 20
    ssh.run "cd ~/traefik && docker-compose up -d"
    ssh.run "echo #{config.credentials.password("docker-registry")} | docker login ghcr.io -u USERNAME --password-stdin", log: false
  end
end

#provision(name) ⇒ Object

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/kraaken/cloud.rb', line 14

def provision(name)
  raise NotImplementedError
end

#serversObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/kraaken/cloud.rb', line 40

def servers
  raise NotImplementedError
end