Class: Kdep::Commands::HelmInstall
- Inherits:
-
Object
- Object
- Kdep::Commands::HelmInstall
- Defined in:
- lib/kdep/commands/helm_install.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(global_options:, command_options:, args:) ⇒ HelmInstall
constructor
A new instance of HelmInstall.
Constructor Details
#initialize(global_options:, command_options:, args:) ⇒ HelmInstall
Returns a new instance of HelmInstall.
19 20 21 22 23 24 |
# File 'lib/kdep/commands/helm_install.rb', line 19 def initialize(global_options:, command_options:, args:) @global_options = @command_options = @args = args @ui = Kdep::UI.new(color: false) end |
Class Method Details
.option_parser ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kdep/commands/helm_install.rb', line 6 def self.option_parser OptionParser.new do |opts| opts. = "Usage: kdep helm-install [deploy] [env]" opts.separator "" opts.separator "Runs helm upgrade --install for a helm preset deploy target," opts.separator "then renders and applies any additional k8s resources (ingress, secrets)." opts.separator "" opts.separator "Supports single chart (chart:) or multiple charts (charts: array)." opts.separator "" opts.on("--dry-run", "Show what would be run without executing") end end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/kdep/commands/helm_install.rb', line 26 def execute deploy_name = @args[0] env = @args[1] @dry_run = @command_options[:"dry-run"] # Discover kdep/ directory discovery = Kdep::Discovery.new kdep_dir = discovery.find_kdep_dir unless kdep_dir @ui.error("No kdep/ directory found") exit 1 end # Resolve deploy directory @deploy_dir = resolve_deploy_dir(kdep_dir, deploy_name, discovery) unless @deploy_dir exit 1 end # Load config config = Kdep::Config.new(@deploy_dir, env).load @namespace = config["namespace"] unless config["preset"] == "helm" @ui.error("#{deploy_name} is not a helm preset (preset: #{config["preset"]})") exit 1 end # Validate context begin Kdep::ContextGuard.new(config["context"]).validate! rescue Kdep::Kubectl::Error => e @ui.error(e.) exit 1 end # Load secrets for --set interpolation @secrets = load_secrets(@deploy_dir) # Add helm repos repos = config["helm_repos"] || {} # Also support singular helm_repo for backward compat if config["helm_repo"] repo_name, repo_url = config["helm_repo"].split("=", 2) repos[repo_name] = repo_url if repo_name && repo_url end repos.each do |repo_name, repo_url| @ui.info("Adding helm repo: #{repo_name} -> #{repo_url}") Kdep::Helm.repo_add(repo_name, repo_url) unless @dry_run end # Install charts charts = build_chart_list(config) if charts.empty? @ui.error("app.yml has no chart or charts defined") exit 1 end charts.each do |chart_conf| install_chart(chart_conf) end # Render and apply additional k8s resources (ingress, secret, etc.) apply_extra_resources(config, kdep_dir) end |