lib/seira/pods.rb in seira-0.3.3 vs lib/seira/pods.rb in seira-0.3.6
- old
+ new
@@ -1,9 +1,11 @@
require 'json'
module Seira
class Pods
+ include Seira::Commands
+
VALID_ACTIONS = %w[help list delete logs top run connect].freeze
SUMMARY = "Manage your application's pods.".freeze
attr_reader :app, :action, :args, :pod_name, :context
@@ -43,22 +45,22 @@
puts "\n\n"
puts "TODO"
end
def run_list
- puts `kubectl get pods --namespace=#{app} -o wide`
+ kubectl("get pods -o wide", context: context)
end
def run_delete
- puts `kubectl delete pod #{pod_name} --namespace=#{app}`
+ kubectl("delete pod #{pod_name}", context: context)
end
def run_logs
- puts `kubectl logs #{pod_name} --namespace=#{app} -c #{app}`
+ kubectl("logs #{pod_name} -c #{app}")
end
def run_top
- puts `kubectl top pod #{pod_name} --namespace=#{app} --containers`
+ kubectl("top pod #{pod_name} --containers", context: context)
end
def run_connect
# If a pod name is specified, connect to that pod; otherwise pick a random web pod
target_pod_name = pod_name || Helpers.fetch_pods(app: app, filters: { tier: 'web' }).sample&.dig('metadata', 'name')