summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński (Conference till 20th) <ayufan@ayufan.eu>2018-06-20 12:10:14 +0000
committerKamil Trzciński (Conference till 20th) <ayufan@ayufan.eu>2018-06-20 12:10:14 +0000
commitbd88a2769c8589c2258237fdd1587da920271cd8 (patch)
tree850ba8efdd97c5254dc260b1788bc872f292a5b8
parent3b38b4affb4f3525aa7f5d245008e43d33c73c41 (diff)
parent5841e92390051065d89a5b0602fa326eda018cd9 (diff)
downloadgitlab-ce-bd88a2769c8589c2258237fdd1587da920271cd8.tar.gz
Merge branch '48126-fix-prometheus-installation' into 'master'
Resolve "Unable to install Prometheus on Clusters: 'Error: Chart incompatible with Tiller v2.7.0'" Closes #48126 See merge request gitlab-org/gitlab-ce!20010
-rw-r--r--app/models/clusters/applications/prometheus.rb3
-rw-r--r--changelogs/unreleased/48126-fix-prometheus-installation.yml5
-rw-r--r--lib/gitlab/kubernetes/helm/install_command.rb11
-rw-r--r--spec/lib/gitlab/kubernetes/helm/api_spec.rb8
-rw-r--r--spec/lib/gitlab/kubernetes/helm/install_command_spec.rb62
-rw-r--r--spec/models/clusters/applications/ingress_spec.rb1
-rw-r--r--spec/models/clusters/applications/jupyter_spec.rb1
-rw-r--r--spec/models/clusters/applications/prometheus_spec.rb1
-rw-r--r--spec/models/clusters/applications/runner_spec.rb1
9 files changed, 59 insertions, 34 deletions
diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb
index c702c4ee807..48137c2ed68 100644
--- a/app/models/clusters/applications/prometheus.rb
+++ b/app/models/clusters/applications/prometheus.rb
@@ -3,7 +3,7 @@ module Clusters
class Prometheus < ActiveRecord::Base
include PrometheusAdapter
- VERSION = "2.0.0".freeze
+ VERSION = '6.7.3'.freeze
self.table_name = 'clusters_applications_prometheus'
@@ -37,6 +37,7 @@ module Clusters
Gitlab::Kubernetes::Helm::InstallCommand.new(
name,
chart: chart,
+ version: version,
values: values
)
end
diff --git a/changelogs/unreleased/48126-fix-prometheus-installation.yml b/changelogs/unreleased/48126-fix-prometheus-installation.yml
new file mode 100644
index 00000000000..e6ab9c46fbf
--- /dev/null
+++ b/changelogs/unreleased/48126-fix-prometheus-installation.yml
@@ -0,0 +1,5 @@
+---
+title: Specify chart version when installing applications on Clusters
+merge_request: 20010
+author:
+type: fixed
diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb
index 30af3e97b4a..d2133a6d65b 100644
--- a/lib/gitlab/kubernetes/helm/install_command.rb
+++ b/lib/gitlab/kubernetes/helm/install_command.rb
@@ -2,11 +2,12 @@ module Gitlab
module Kubernetes
module Helm
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
@chart = chart
+ @version = version
@values = values
@repository = repository
end
@@ -39,9 +40,13 @@ module Gitlab
def script_command
<<~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
end
+
+ def optional_version_flag
+ " --version #{version}" if version
+ end
end
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
index 740466ea5cb..aa7e43dfb16 100644
--- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
@@ -7,13 +7,7 @@ describe Gitlab::Kubernetes::Helm::Api do
let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client) }
let(:application) { create(:clusters_applications_prometheus) }
- let(:command) do
- Gitlab::Kubernetes::Helm::InstallCommand.new(
- application.name,
- chart: application.chart,
- values: application.values
- )
- end
+ let(:command) { application.install_command }
subject { helm }
diff --git a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
index 547f3f1752c..25c6fa3b9a3 100644
--- a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
@@ -3,44 +3,60 @@ require 'rails_helper'
describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:application) { create(:clusters_applications_prometheus) }
let(:namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
-
- let(:install_command) do
- described_class.new(
- application.name,
- chart: application.chart,
- values: application.values
- )
- end
+ let(:install_command) { application.install_command }
subject { install_command }
- it_behaves_like 'helm commands' do
- let(:commands) do
- <<~EOS
+ context 'for ingress' do
+ let(:application) { create(:clusters_applications_ingress) }
+
+ it_behaves_like 'helm commands' do
+ let(:commands) do
+ <<~EOS
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
- 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
- context 'with an application with a repository' do
+ context 'for runner' do
let(:ci_runner) { create(:ci_runner) }
let(:application) { create(:clusters_applications_runner, runner: ci_runner) }
- let(:install_command) do
- described_class.new(
- application.name,
- chart: application.chart,
- values: application.values,
- repository: application.repository
- )
+
+ it_behaves_like 'helm commands' do
+ let(:commands) do
+ <<~EOS
+ helm init --client-only >/dev/null
+ 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
+
+ context 'for jupyter' do
+ let(:application) { create(:clusters_applications_jupyter) }
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --client-only >/dev/null
- 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 init --client-only >/dev/null
+ 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
diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb
index a47a07d908d..bb5b2ef3a47 100644
--- a/spec/models/clusters/applications/ingress_spec.rb
+++ b/spec/models/clusters/applications/ingress_spec.rb
@@ -73,6 +73,7 @@ describe Clusters::Applications::Ingress do
it 'should be initialized with ingress arguments' do
expect(subject.name).to eq('ingress')
expect(subject.chart).to eq('stable/nginx-ingress')
+ expect(subject.version).to be_nil
expect(subject.values).to eq(ingress.values)
end
end
diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb
index ca48a1d8072..65750141e65 100644
--- a/spec/models/clusters/applications/jupyter_spec.rb
+++ b/spec/models/clusters/applications/jupyter_spec.rb
@@ -36,6 +36,7 @@ describe Clusters::Applications::Jupyter do
it 'should be initialized with 4 arguments' do
expect(subject.name).to eq('jupyter')
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.values).to eq(jupyter.values)
end
diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb
index d2302583ac8..efd57040005 100644
--- a/spec/models/clusters/applications/prometheus_spec.rb
+++ b/spec/models/clusters/applications/prometheus_spec.rb
@@ -109,6 +109,7 @@ describe Clusters::Applications::Prometheus do
it 'should be initialized with 3 arguments' do
expect(subject.name).to eq('prometheus')
expect(subject.chart).to eq('stable/prometheus')
+ expect(subject.version).to eq('6.7.3')
expect(subject.values).to eq(prometheus.values)
end
end
diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb
index 3ef59457c5f..b12500d0acd 100644
--- a/spec/models/clusters/applications/runner_spec.rb
+++ b/spec/models/clusters/applications/runner_spec.rb
@@ -31,6 +31,7 @@ describe Clusters::Applications::Runner do
it 'should be initialized with 4 arguments' do
expect(subject.name).to eq('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.values).to eq(gitlab_runner.values)
end