Class: G5deploy::KubernetesHelper

Inherits:
Thor
  • Object
show all
Defined in:
lib/g5deploy/cli.rb

Instance Method Summary collapse

Instance Method Details

#deploy(environment) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/g5deploy/cli.rb', line 8

def deploy(environment)
  if environment == "production" && options[:with_migration]
    cmd = "kubectl config use-context g5-prod && kubectl \
    apply -f k8s/sidekiq-workers.yaml -f k8s/rails-servers.yaml \
    -f k8s/db-migrate.yaml"
    run_command(cmd)
  elsif environment == "production"
    cmd = "kubectl config use-context g5-prod && kubectl \
    apply -f k8s/sidekiq-workers.yaml -f k8s/rails-servers.yaml"
    run_command(cmd)
  elsif environment == "staging" && options[:with_migration]
    cmd = "kubectl config use-context integrations-staging && kubectl \
    apply -f k8s/sidekiq-workers.yaml -f k8s/rails-servers.yaml \
    -f k8s/db-migrate.yaml"
    run_command(cmd)
  elsif environment == "staging"
    cmd = "kubectl config use-context integrations-staging && kubectl \
    apply -f k8s/sidekiq-workers.yaml -f k8s/rails-servers.yaml"
    run_command(cmd)
  else
    puts "Command not found!".upcase
  end
end

#logs(pod_name) ⇒ Object



46
47
48
49
# File 'lib/g5deploy/cli.rb', line 46

def logs(pod_name)
  cmd = "kubectl exec -it #{pod_name} -- /bin/bash -f"
  run_command(cmd)
end

#pods(environment) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/g5deploy/cli.rb', line 33

def pods(environment)
  if environment == "production"
    cmd = "kubectl config use-context g5-prod && kubectl get pods"
    run_command(cmd)
  elsif environment == "staging"
    cmd = "kubectl config use-context integrations-staging && kubectl get pods"
    run_command(cmd)
  else
    puts "Command not found!".upcase
  end
end