Sha256: 823c4cfa6af56328a405b68a76ce46b713aab960aee843950aaaaa6d72a408b8
Contents?: true
Size: 1.16 KB
Versions: 10
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Neptuno module K8s class Attach < Neptuno::CLI::Base include ::Neptuno::TTY::Config desc 'K8s: Attach to a container with k8s' option :context, type: :string, default: 'int', desc: 'K8s context to run in' option :namespace, type: :string, default: 'thrillshare', desc: 'K8s namespace to run in' option :dependent, type: :string, desc: 'Dependent service' option :pr, type: :integer, desc: "PR's Github ID" def call(**options) command_service_to('attach with k8s', service_as_args: options[:args]&.first) do |service, _project| deployment = "deploy/#{options[:dependent] || service}" deployment += "-#{service}-#{options[:pr]}" unless options[:pr].nil? context = options[:context] context = 'qa' unless options[:pr].nil? system("kubectl config use-context #{context} > /dev/null 2>&1") puts "Attaching to #{deployment} in the #{options[:namespace]} namespace using the #{context} context" system("kubectl exec #{deployment} -n #{options[:namespace]} --stdin --tty -- /bin/sh") end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems