Commit 5841e923 authored by Mayra Cabrera's avatar Mayra Cabrera Committed by Kamil Trzciński (Conference till 20th)

Resolve "Unable to install Prometheus on Clusters: 'Error: Chart incompatible with Tiller v2.7.0'"

parent 3b38b4af
...@@ -3,7 +3,7 @@ module Clusters ...@@ -3,7 +3,7 @@ module Clusters
class Prometheus < ActiveRecord::Base class Prometheus < ActiveRecord::Base
include PrometheusAdapter include PrometheusAdapter
VERSION = "2.0.0".freeze VERSION = '6.7.3'.freeze
self.table_name = 'clusters_applications_prometheus' self.table_name = 'clusters_applications_prometheus'
...@@ -37,6 +37,7 @@ module Clusters ...@@ -37,6 +37,7 @@ module Clusters
Gitlab::Kubernetes::Helm::InstallCommand.new( Gitlab::Kubernetes::Helm::InstallCommand.new(
name, name,
chart: chart, chart: chart,
version: version,
values: values values: values
) )
end end
......
---
title: Specify chart version when installing applications on Clusters
merge_request: 20010
author:
type: fixed
...@@ -2,11 +2,12 @@ module Gitlab ...@@ -2,11 +2,12 @@ module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
class InstallCommand < BaseCommand class InstallCommand < BaseCommand
attr_reader :name, :chart, :repository, :values attr_reader :name, :chart, :version, :repository, :values
def initialize(name, chart:, values:, repository: nil) def initialize(name, chart:, values:, version: nil, repository: nil)
@name = name @name = name
@chart = chart @chart = chart
@version = version
@values = values @values = values
@repository = repository @repository = repository
end end
...@@ -39,9 +40,13 @@ module Gitlab ...@@ -39,9 +40,13 @@ module Gitlab
def script_command def script_command
<<~HEREDOC <<~HEREDOC
helm install #{chart} --name #{name} --namespace #{Gitlab::Kubernetes::Helm::NAMESPACE} -f /data/helm/#{name}/config/values.yaml >/dev/null helm install #{chart} --name #{name}#{optional_version_flag} --namespace #{Gitlab::Kubernetes::Helm::NAMESPACE} -f /data/helm/#{name}/config/values.yaml >/dev/null
HEREDOC HEREDOC
end end
def optional_version_flag
" --version #{version}" if version
end
end end
end end
end end
......
...@@ -7,13 +7,7 @@ describe Gitlab::Kubernetes::Helm::Api do ...@@ -7,13 +7,7 @@ describe Gitlab::Kubernetes::Helm::Api do
let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client) } let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client) }
let(:application) { create(:clusters_applications_prometheus) } let(:application) { create(:clusters_applications_prometheus) }
let(:command) do let(:command) { application.install_command }
Gitlab::Kubernetes::Helm::InstallCommand.new(
application.name,
chart: application.chart,
values: application.values
)
end
subject { helm } subject { helm }
......
...@@ -3,44 +3,60 @@ require 'rails_helper' ...@@ -3,44 +3,60 @@ require 'rails_helper'
describe Gitlab::Kubernetes::Helm::InstallCommand do describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:application) { create(:clusters_applications_prometheus) } let(:application) { create(:clusters_applications_prometheus) }
let(:namespace) { Gitlab::Kubernetes::Helm::NAMESPACE } let(:namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
let(:install_command) { application.install_command }
let(:install_command) do
described_class.new(
application.name,
chart: application.chart,
values: application.values
)
end
subject { install_command } subject { install_command }
it_behaves_like 'helm commands' do context 'for ingress' do
let(:commands) do let(:application) { create(:clusters_applications_ingress) }
<<~EOS
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
helm init --client-only >/dev/null helm init --client-only >/dev/null
helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
EOS EOS
end
end
end
context 'for prometheus' do
let(:application) { create(:clusters_applications_prometheus) }
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
helm init --client-only >/dev/null
helm install #{application.chart} --name #{application.name} --version #{application.version} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
EOS
end
end end
end end
context 'with an application with a repository' do context 'for runner' do
let(:ci_runner) { create(:ci_runner) } let(:ci_runner) { create(:ci_runner) }
let(:application) { create(:clusters_applications_runner, runner: ci_runner) } let(:application) { create(:clusters_applications_runner, runner: ci_runner) }
let(:install_command) do
described_class.new( it_behaves_like 'helm commands' do
application.name, let(:commands) do
chart: application.chart, <<~EOS
values: application.values, helm init --client-only >/dev/null
repository: application.repository helm repo add #{application.name} #{application.repository}
) helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
EOS
end
end end
end
context 'for jupyter' do
let(:application) { create(:clusters_applications_jupyter) }
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only >/dev/null helm init --client-only >/dev/null
helm repo add #{application.name} #{application.repository} helm repo add #{application.name} #{application.repository}
helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null helm install #{application.chart} --name #{application.name} --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml >/dev/null
EOS EOS
end end
end end
......
...@@ -73,6 +73,7 @@ describe Clusters::Applications::Ingress do ...@@ -73,6 +73,7 @@ describe Clusters::Applications::Ingress do
it 'should be initialized with ingress arguments' do it 'should be initialized with ingress arguments' do
expect(subject.name).to eq('ingress') expect(subject.name).to eq('ingress')
expect(subject.chart).to eq('stable/nginx-ingress') expect(subject.chart).to eq('stable/nginx-ingress')
expect(subject.version).to be_nil
expect(subject.values).to eq(ingress.values) expect(subject.values).to eq(ingress.values)
end end
end end
......
...@@ -36,6 +36,7 @@ describe Clusters::Applications::Jupyter do ...@@ -36,6 +36,7 @@ describe Clusters::Applications::Jupyter do
it 'should be initialized with 4 arguments' do it 'should be initialized with 4 arguments' do
expect(subject.name).to eq('jupyter') expect(subject.name).to eq('jupyter')
expect(subject.chart).to eq('jupyter/jupyterhub') expect(subject.chart).to eq('jupyter/jupyterhub')
expect(subject.version).to be_nil
expect(subject.repository).to eq('https://jupyterhub.github.io/helm-chart/') expect(subject.repository).to eq('https://jupyterhub.github.io/helm-chart/')
expect(subject.values).to eq(jupyter.values) expect(subject.values).to eq(jupyter.values)
end end
......
...@@ -109,6 +109,7 @@ describe Clusters::Applications::Prometheus do ...@@ -109,6 +109,7 @@ describe Clusters::Applications::Prometheus do
it 'should be initialized with 3 arguments' do it 'should be initialized with 3 arguments' do
expect(subject.name).to eq('prometheus') expect(subject.name).to eq('prometheus')
expect(subject.chart).to eq('stable/prometheus') expect(subject.chart).to eq('stable/prometheus')
expect(subject.version).to eq('6.7.3')
expect(subject.values).to eq(prometheus.values) expect(subject.values).to eq(prometheus.values)
end end
end end
......
...@@ -31,6 +31,7 @@ describe Clusters::Applications::Runner do ...@@ -31,6 +31,7 @@ describe Clusters::Applications::Runner do
it 'should be initialized with 4 arguments' do it 'should be initialized with 4 arguments' do
expect(subject.name).to eq('runner') expect(subject.name).to eq('runner')
expect(subject.chart).to eq('runner/gitlab-runner') expect(subject.chart).to eq('runner/gitlab-runner')
expect(subject.version).to be_nil
expect(subject.repository).to eq('https://charts.gitlab.io') expect(subject.repository).to eq('https://charts.gitlab.io')
expect(subject.values).to eq(gitlab_runner.values) expect(subject.values).to eq(gitlab_runner.values)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment