Class: KuberKit::Shell::KubectlCommands
- Defined in:
- lib/kuber_kit/shell/kubectl_commands.rb
Instance Method Summary collapse
- #apply_file(shell, file_path, kubeconfig_path: nil) ⇒ Object
- #patch_deployment(shell, deployment_name, specs, kubeconfig_path: nil) ⇒ Object
- #rolling_restart(shell, deployment_name, kubeconfig_path: nil) ⇒ Object
Instance Method Details
#apply_file(shell, file_path, kubeconfig_path: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/kuber_kit/shell/kubectl_commands.rb', line 5 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 |
#patch_deployment(shell, deployment_name, specs, kubeconfig_path: nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kuber_kit/shell/kubectl_commands.rb', line 30 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 |
#rolling_restart(shell, deployment_name, kubeconfig_path: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kuber_kit/shell/kubectl_commands.rb', line 16 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 |