Commit f2582fbc authored by Sean McGivern's avatar Sean McGivern

Merge branch '63694-tls-opts-for-helm-wait' into 'master'

GitLab Managed App ensure helm version uses tls opts

Closes #63694

See merge request gitlab-org/gitlab-ce!30654
parents c29da98f c9b0ac5f
...@@ -13,15 +13,27 @@ module Gitlab ...@@ -13,15 +13,27 @@ module Gitlab
end end
def wait_for_tiller_command def wait_for_tiller_command
helm_check = ['helm', 'version', *optional_tls_flags].shelljoin
# This is necessary to give Tiller time to restart after upgrade. # This is necessary to give Tiller time to restart after upgrade.
# Ideally we'd be able to use --wait but cannot because of # Ideally we'd be able to use --wait but cannot because of
# https://github.com/helm/helm/issues/4855 # https://github.com/helm/helm/issues/4855
'for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done' "for i in $(seq 1 30); do #{helm_check} && break; sleep 1s; echo \"Retrying ($i)...\"; done"
end end
def repository_command def repository_command
['helm', 'repo', 'add', name, repository].shelljoin if repository ['helm', 'repo', 'add', name, repository].shelljoin if repository
end end
def optional_tls_flags
return [] unless files.key?(:'ca.pem')
[
'--tls',
'--tls-ca-cert', "#{files_dir}/ca.pem",
'--tls-cert', "#{files_dir}/cert.pem",
'--tls-key', "#{files_dir}/key.pem"
]
end
end end
end end
end end
......
...@@ -95,17 +95,6 @@ module Gitlab ...@@ -95,17 +95,6 @@ module Gitlab
['--version', version] ['--version', version]
end end
def optional_tls_flags
return [] unless files.key?(:'ca.pem')
[
'--tls',
'--tls-ca-cert', "#{files_dir}/ca.pem",
'--tls-cert', "#{files_dir}/cert.pem",
'--tls-key', "#{files_dir}/key.pem"
]
end
end end
end end
end end
......
...@@ -20,6 +20,15 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do ...@@ -20,6 +20,15 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do
end end
end end
let(:tls_flags) do
<<~EOS.squish
--tls
--tls-ca-cert /data/helm/app-name/config/ca.pem
--tls-cert /data/helm/app-name/config/cert.pem
--tls-key /data/helm/app-name/config/key.pem
EOS
end
context 'when there is a ca.pem file' do context 'when there is a ca.pem file' do
let(:files) { { 'ca.pem': 'some file content' } } let(:files) { { 'ca.pem': 'some file content' } }
...@@ -27,7 +36,7 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do ...@@ -27,7 +36,7 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done
#{helm_delete_command} #{helm_delete_command}
EOS EOS
end end
...@@ -35,10 +44,7 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do ...@@ -35,10 +44,7 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do
let(:helm_delete_command) do let(:helm_delete_command) do
<<~EOS.squish <<~EOS.squish
helm delete --purge app-name helm delete --purge app-name
--tls #{tls_flags}
--tls-ca-cert /data/helm/app-name/config/ca.pem
--tls-cert /data/helm/app-name/config/cert.pem
--tls-key /data/helm/app-name/config/key.pem
EOS EOS
end end
end end
......
...@@ -36,7 +36,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -36,7 +36,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && 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}
...@@ -64,7 +64,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -64,7 +64,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && 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}
...@@ -93,7 +93,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -93,7 +93,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done
#{helm_install_command} #{helm_install_command}
EOS EOS
end end
...@@ -120,7 +120,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -120,7 +120,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && 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
/bin/date /bin/date
...@@ -151,7 +151,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -151,7 +151,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && 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}
...@@ -210,7 +210,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -210,7 +210,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:commands) do let(:commands) do
<<~EOS <<~EOS
helm init --upgrade helm init --upgrade
for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done for i in $(seq 1 30); do helm version #{tls_flags} && 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}
......
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