Commit 5b75fcf6 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '49726-upgrade-helm-to-2-11' into 'master'

Resolve "Upgrade Helm Tiller Version Used By GitLab Managed Apps"

Closes #49726

See merge request gitlab-org/gitlab-ce!22693
parents 6ac06e95 1244533b
...@@ -64,6 +64,13 @@ module Clusters ...@@ -64,6 +64,13 @@ module Clusters
status_reason = transition.args.first status_reason = transition.args.first
app_status.status_reason = status_reason if status_reason app_status.status_reason = status_reason if status_reason
end end
before_transition any => [:installed, :updated] do |app_status, _|
# When installing any application we are also performing an update
# of tiller (see Gitlab::Kubernetes::Helm::ClientCommand) so
# therefore we need to reflect that in the database.
app_status.cluster.application_helm.update!(version: Gitlab::Kubernetes::Helm::HELM_VERSION)
end
end end
end end
......
---
title: Upgrade helm to 2.11.0 and upgrade on every install
merge_request: 22693
author:
type: added
...@@ -230,6 +230,10 @@ twice, which can lead to confusion during deployments. ...@@ -230,6 +230,10 @@ twice, which can lead to confusion during deployments.
| [JupyterHub](http://jupyter.org/) | 11.0+ | [JupyterHub](https://jupyterhub.readthedocs.io/en/stable/) is a multi-user service for managing notebooks across a team. [Jupyter Notebooks](https://jupyter-notebook.readthedocs.io/en/latest/) provide a web-based interactive programming environment used for data analysis, visualization, and machine learning. We use [this](https://gitlab.com/gitlab-org/jupyterhub-user-image/blob/master/Dockerfile) custom Jupyter image that installs additional useful packages on top of the base Jupyter. You will also see ready-to-use DevOps Runbooks built with Nurtch's [Rubix library](https://github.com/amit1rrr/rubix). More information on creating executable runbooks can be found at [Nurtch Documentation](http://docs.nurtch.com/en/latest). **Note**: Authentication will be enabled for any user of the GitLab server via OAuth2. HTTPS will be supported in a future release. | [jupyter/jupyterhub](https://jupyterhub.github.io/helm-chart/) | | [JupyterHub](http://jupyter.org/) | 11.0+ | [JupyterHub](https://jupyterhub.readthedocs.io/en/stable/) is a multi-user service for managing notebooks across a team. [Jupyter Notebooks](https://jupyter-notebook.readthedocs.io/en/latest/) provide a web-based interactive programming environment used for data analysis, visualization, and machine learning. We use [this](https://gitlab.com/gitlab-org/jupyterhub-user-image/blob/master/Dockerfile) custom Jupyter image that installs additional useful packages on top of the base Jupyter. You will also see ready-to-use DevOps Runbooks built with Nurtch's [Rubix library](https://github.com/amit1rrr/rubix). More information on creating executable runbooks can be found at [Nurtch Documentation](http://docs.nurtch.com/en/latest). **Note**: Authentication will be enabled for any user of the GitLab server via OAuth2. HTTPS will be supported in a future release. | [jupyter/jupyterhub](https://jupyterhub.github.io/helm-chart/) |
| [Knative](https://cloud.google.com/knative) | 0.1.2 | Knative provides a platform to create, deploy, and manage serverless workloads from a Kubernetes cluster. It is used in conjunction with, and includes [Istio](https://istio.io) to provide an external IP address for all programs hosted by Knative. You will be prompted to enter a wildcard domain where your applications will be exposed. Configure your DNS server to use the external IP address for that domain. For any application created and installed, they will be accessible as `<program_name>.<kubernetes_namespace>.<domain_name>`. **Note**: This will require your kubernetes cluster to have RBAC enabled. | [knative/knative](https://storage.googleapis.com/triggermesh-charts) | [Knative](https://cloud.google.com/knative) | 0.1.2 | Knative provides a platform to create, deploy, and manage serverless workloads from a Kubernetes cluster. It is used in conjunction with, and includes [Istio](https://istio.io) to provide an external IP address for all programs hosted by Knative. You will be prompted to enter a wildcard domain where your applications will be exposed. Configure your DNS server to use the external IP address for that domain. For any application created and installed, they will be accessible as `<program_name>.<kubernetes_namespace>.<domain_name>`. **Note**: This will require your kubernetes cluster to have RBAC enabled. | [knative/knative](https://storage.googleapis.com/triggermesh-charts)
NOTE: **Note:**
As of GitLab 11.6 Helm Tiller will be upgraded to the latest version supported
by GitLab before installing any of the above applications.
## Getting the external IP address ## Getting the external IP address
NOTE: **Note:** NOTE: **Note:**
......
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
HELM_VERSION = '2.7.2'.freeze HELM_VERSION = '2.11.0'.freeze
KUBECTL_VERSION = '1.11.0'.freeze KUBECTL_VERSION = '1.11.0'.freeze
NAMESPACE = 'gitlab-managed-apps'.freeze NAMESPACE = 'gitlab-managed-apps'.freeze
SERVICE_ACCOUNT = 'tiller'.freeze SERVICE_ACCOUNT = 'tiller'.freeze
......
module Gitlab
module Kubernetes
module Helm
module ClientCommand
def init_command
# Here we are always upgrading to the latest version of Tiller when
# installing an app. We ensure the helm version stored in the
# database is correct by also updating this after transition to
# :installed,:updated in Clusters::Concerns::ApplicationStatus
'helm init --upgrade'
end
def wait_for_tiller_command
# This is necessary to give Tiller time to restart after upgrade.
# Ideally we'd be able to use --wait but cannot because of
# https://github.com/helm/helm/issues/4855
'for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done'
end
def repository_command
['helm', 'repo', 'add', name, repository].shelljoin if repository
end
end
end
end
end
...@@ -3,6 +3,7 @@ module Gitlab ...@@ -3,6 +3,7 @@ module Gitlab
module Helm module Helm
class InstallCommand class InstallCommand
include BaseCommand include BaseCommand
include ClientCommand
attr_reader :name, :files, :chart, :version, :repository, :preinstall, :postinstall attr_reader :name, :files, :chart, :version, :repository, :preinstall, :postinstall
...@@ -20,6 +21,7 @@ module Gitlab ...@@ -20,6 +21,7 @@ module Gitlab
def generate_script def generate_script
super + [ super + [
init_command, init_command,
wait_for_tiller_command,
repository_command, repository_command,
repository_update_command, repository_update_command,
preinstall_command, preinstall_command,
...@@ -34,14 +36,6 @@ module Gitlab ...@@ -34,14 +36,6 @@ module Gitlab
private private
def init_command
'helm init --client-only'
end
def repository_command
['helm', 'repo', 'add', name, repository].shelljoin if repository
end
def repository_update_command def repository_update_command
'helm repo update' if repository 'helm repo update' if repository
end end
......
...@@ -5,6 +5,7 @@ module Gitlab ...@@ -5,6 +5,7 @@ module Gitlab
module Helm module Helm
class UpgradeCommand class UpgradeCommand
include BaseCommand include BaseCommand
include ClientCommand
attr_reader :name, :chart, :version, :repository, :files attr_reader :name, :chart, :version, :repository, :files
...@@ -20,6 +21,7 @@ module Gitlab ...@@ -20,6 +21,7 @@ module Gitlab
def generate_script def generate_script
super + [ super + [
init_command, init_command,
wait_for_tiller_command,
repository_command, repository_command,
script_command script_command
].compact.join("\n") ].compact.join("\n")
...@@ -35,14 +37,6 @@ module Gitlab ...@@ -35,14 +37,6 @@ module Gitlab
private private
def init_command
'helm init --client-only'
end
def repository_command
"helm repo add #{name} #{repository}" if repository
end
def script_command def script_command
upgrade_flags = "#{optional_version_flag}#{optional_tls_flags}" \ upgrade_flags = "#{optional_version_flag}#{optional_tls_flags}" \
" --reset-values" \ " --reset-values" \
......
...@@ -26,7 +26,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -26,7 +26,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add app-name https://repository.example.com helm repo add app-name https://repository.example.com
helm repo update helm repo update
#{helm_install_comand} #{helm_install_comand}
...@@ -54,7 +55,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -54,7 +55,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add app-name https://repository.example.com helm repo add app-name https://repository.example.com
helm repo update helm repo update
#{helm_install_command} #{helm_install_command}
...@@ -84,7 +86,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -84,7 +86,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
#{helm_install_command} #{helm_install_command}
EOS EOS
end end
...@@ -111,7 +114,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -111,7 +114,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add app-name https://repository.example.com helm repo add app-name https://repository.example.com
helm repo update helm repo update
#{helm_install_command} #{helm_install_command}
...@@ -134,7 +138,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -134,7 +138,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add app-name https://repository.example.com helm repo add app-name https://repository.example.com
helm repo update helm repo update
#{helm_install_command} #{helm_install_command}
...@@ -157,7 +162,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -157,7 +162,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add app-name https://repository.example.com helm repo add app-name https://repository.example.com
helm repo update helm repo update
#{helm_install_command} #{helm_install_command}
...@@ -182,7 +188,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -182,7 +188,8 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add app-name https://repository.example.com helm repo add app-name https://repository.example.com
helm repo update helm repo update
#{helm_install_command} #{helm_install_command}
......
...@@ -30,7 +30,7 @@ describe Gitlab::Kubernetes::Helm::Pod do ...@@ -30,7 +30,7 @@ describe Gitlab::Kubernetes::Helm::Pod do
it 'should generate the appropriate specifications for the container' do it 'should generate the appropriate specifications for the container' do
container = subject.generate.spec.containers.first container = subject.generate.spec.containers.first
expect(container.name).to eq('helm') expect(container.name).to eq('helm')
expect(container.image).to eq('registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/2.7.2-kube-1.11.0') expect(container.image).to eq('registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/2.11.0-kube-1.11.0')
expect(container.env.count).to eq(3) expect(container.env.count).to eq(3)
expect(container.env.map(&:name)).to match_array([:HELM_VERSION, :TILLER_NAMESPACE, :COMMAND_SCRIPT]) expect(container.env.map(&:name)).to match_array([:HELM_VERSION, :TILLER_NAMESPACE, :COMMAND_SCRIPT])
expect(container.command).to match_array(["/bin/sh"]) expect(container.command).to match_array(["/bin/sh"])
......
...@@ -21,7 +21,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do ...@@ -21,7 +21,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm upgrade #{application.name} #{application.chart} --tls --tls-ca-cert /data/helm/#{application.name}/config/ca.pem --tls-cert /data/helm/#{application.name}/config/cert.pem --tls-key /data/helm/#{application.name}/config/key.pem --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml helm upgrade #{application.name} #{application.chart} --tls --tls-ca-cert /data/helm/#{application.name}/config/ca.pem --tls-cert /data/helm/#{application.name}/config/cert.pem --tls-key /data/helm/#{application.name}/config/key.pem --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml
EOS EOS
end end
...@@ -33,7 +34,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do ...@@ -33,7 +34,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm upgrade #{application.name} #{application.chart} --tls --tls-ca-cert /data/helm/#{application.name}/config/ca.pem --tls-cert /data/helm/#{application.name}/config/cert.pem --tls-key /data/helm/#{application.name}/config/key.pem --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml helm upgrade #{application.name} #{application.chart} --tls --tls-ca-cert /data/helm/#{application.name}/config/ca.pem --tls-cert /data/helm/#{application.name}/config/cert.pem --tls-key /data/helm/#{application.name}/config/key.pem --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml
EOS EOS
end end
...@@ -56,7 +58,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do ...@@ -56,7 +58,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm repo add #{application.name} #{application.repository} helm repo add #{application.name} #{application.repository}
helm upgrade #{application.name} #{application.chart} --tls --tls-ca-cert /data/helm/#{application.name}/config/ca.pem --tls-cert /data/helm/#{application.name}/config/cert.pem --tls-key /data/helm/#{application.name}/config/key.pem --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml helm upgrade #{application.name} #{application.chart} --tls --tls-ca-cert /data/helm/#{application.name}/config/ca.pem --tls-cert /data/helm/#{application.name}/config/cert.pem --tls-key /data/helm/#{application.name}/config/key.pem --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml
EOS EOS
...@@ -70,7 +73,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do ...@@ -70,7 +73,8 @@ describe Gitlab::Kubernetes::Helm::UpgradeCommand do
it_behaves_like 'helm commands' do it_behaves_like 'helm commands' do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --client-only helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
helm upgrade #{application.name} #{application.chart} --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml helm upgrade #{application.name} #{application.chart} --reset-values --install --namespace #{namespace} -f /data/helm/#{application.name}/config/values.yaml
EOS EOS
end end
......
...@@ -35,7 +35,7 @@ describe Clusters::Applications::Prometheus do ...@@ -35,7 +35,7 @@ describe Clusters::Applications::Prometheus do
describe 'transition to installed' do describe 'transition to installed' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:cluster) { create(:cluster, projects: [project]) } let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) }
let(:prometheus_service) { double('prometheus_service') } let(:prometheus_service) { double('prometheus_service') }
subject { create(:clusters_applications_prometheus, :installing, cluster: cluster) } subject { create(:clusters_applications_prometheus, :installing, cluster: cluster) }
......
...@@ -44,10 +44,40 @@ shared_examples 'cluster application status specs' do |application_name| ...@@ -44,10 +44,40 @@ shared_examples 'cluster application status specs' do |application_name|
subject { create(application_name, :installing) } subject { create(application_name, :installing) }
it 'is installed' do it 'is installed' do
subject.make_installed subject.make_installed!
expect(subject).to be_installed expect(subject).to be_installed
end end
it 'updates helm version' do
subject.cluster.application_helm.update!(version: '1.2.3')
subject.make_installed!
subject.cluster.application_helm.reload
expect(subject.cluster.application_helm.version).to eq(Gitlab::Kubernetes::Helm::HELM_VERSION)
end
end
describe '#make_updated' do
subject { create(application_name, :updating) }
it 'is updated' do
subject.make_updated!
expect(subject).to be_updated
end
it 'updates helm version' do
subject.cluster.application_helm.update!(version: '1.2.3')
subject.make_updated!
subject.cluster.application_helm.reload
expect(subject.cluster.application_helm.version).to eq(Gitlab::Kubernetes::Helm::HELM_VERSION)
end
end end
describe '#make_errored' do describe '#make_errored' do
......
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