Sha256: 25f8b38644ad059f063b58e33823dc78b489f77bbaf1100432f79af13e7e333f
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'json' require 'shellwords' class KuberKit::Shell::Commands::KubectlCommands def apply_file(shell, file_path, kubeconfig_path: nil) command_parts = [] if kubeconfig_path command_parts << "KUBECONFIG=#{kubeconfig_path}" end command_parts << "kubectl apply -f #{file_path}" shell.exec!(command_parts.join(" ")) end def rolling_restart(shell, deployment_name, kubeconfig_path: nil) patch_deployment(shell, deployment_name, { spec: { template: { metadata: { labels: { redeploy: "$(date +%s)" } } } } }, kubeconfig_path: kubeconfig_path) end def patch_deployment(shell, deployment_name, specs, kubeconfig_path: nil) command_parts = [] if kubeconfig_path command_parts << "KUBECONFIG=#{kubeconfig_path}" end specs_json = JSON.dump(specs).gsub('"', '\"') command_parts << %Q{kubectl patch deployment #{deployment_name} -p "#{specs_json}"} shell.exec!(command_parts.join(" ")) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kuber_kit-0.1.9 | lib/kuber_kit/shell/commands/kubectl_commands.rb |