class SwarmClusterCliOpe::K8s
Public Class Methods
cfgs()
click to toggle source
# File lib/swarm_cluster_cli_ope/k8s.rb, line 13 def self.cfgs SwarmClusterCliOpe::Kubernetes::Configuration.instance end
exit_on_failure?()
click to toggle source
# File lib/swarm_cluster_cli_ope/k8s.rb, line 9 def self.exit_on_failure? true end
Public Instance Methods
install()
click to toggle source
# File lib/swarm_cluster_cli_ope/k8s.rb, line 19 def install #contolliamo se presente la configurazione base nella home if Configuration.exist_base? say "Configurazione già presente" else #se non presente allora chiediamo le varie configurazioni if yes? "Sei nel contesto corretto di kubectl?" #scriviamo le varie configurazioni cfg = cfgs cfg.save_base_cfgs else say "Cambia prima contesto, sarà quello usato per l'installazione" end end end
rsync(src, dst)
click to toggle source
# File lib/swarm_cluster_cli_ope/k8s.rb, line 45 def rsync(src, dst) reg_exp = /(?<pod_name>.*)\:(?<path>.*)/ if File.exist?(src) # il src é la cartella, quindi la destizione è il pod direction = :up local_path = src podname = dst.match(reg_exp)[:pod_name] podpath = dst.match(reg_exp)[:path] else direction = :down podname = src.match(reg_exp)[:pod_name] podpath = src.match(reg_exp)[:path] local_path = dst end puts "#{src} #{direction} #{dst}" cfgs.env(options[:environment]) do |cfgs| cfgs.stack_name = options[:stack_name] || cfgs.stack_name sync = Kubernetes::SyncConfigs::Rsync.new(cfgs, { service: Kubernetes::Pod.find_by_name(podname), how: 'rsync', configs: { local: local_path, remote: podpath } }) if direction == :down sync.pull end if direction == :up sync.push end end end