Commit 1134f540 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'helm-add-alpine-mirrors' into 'master'

Add alpine mirrors while operating on k8s cluster

Closes gitlab-ee#4922

See merge request gitlab-org/gitlab-ce!18651
parents bdc20840 ce5723c8
---
title: Increase cluster applications installer availability using alpine linux mirrors
merge_request:
author:
type: performance
...@@ -15,6 +15,9 @@ module Gitlab ...@@ -15,6 +15,9 @@ module Gitlab
def generate_script def generate_script
<<~HEREDOC <<~HEREDOC
set -eo pipefail set -eo pipefail
ALPINE_VERSION=$(cat /etc/alpine-release | cut -d '.' -f 1,2)
echo http://mirror.clarkson.edu/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories
echo http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories
apk add -U ca-certificates openssl >/dev/null apk add -U ca-certificates openssl >/dev/null
wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v#{Gitlab::Kubernetes::Helm::HELM_VERSION}-linux-amd64.tar.gz | tar zxC /tmp >/dev/null wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v#{Gitlab::Kubernetes::Helm::HELM_VERSION}-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
mv /tmp/linux-amd64/helm /usr/bin/ mv /tmp/linux-amd64/helm /usr/bin/
......
...@@ -4,22 +4,10 @@ describe Gitlab::Kubernetes::Helm::BaseCommand do ...@@ -4,22 +4,10 @@ describe Gitlab::Kubernetes::Helm::BaseCommand do
let(:application) { create(:clusters_applications_helm) } let(:application) { create(:clusters_applications_helm) }
let(:base_command) { described_class.new(application.name) } let(:base_command) { described_class.new(application.name) }
describe '#generate_script' do subject { base_command }
let(:helm_version) { Gitlab::Kubernetes::Helm::HELM_VERSION }
let(:command) do
<<~HEREDOC
set -eo pipefail
apk add -U ca-certificates openssl >/dev/null
wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v#{helm_version}-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
mv /tmp/linux-amd64/helm /usr/bin/
HEREDOC
end
subject { base_command.generate_script }
it 'should return a command that prepares the environment for helm-cli' do it_behaves_like 'helm commands' do
expect(subject).to eq(command) let(:commands) { '' }
end
end end
describe '#pod_resource' do describe '#pod_resource' do
......
...@@ -2,23 +2,9 @@ require 'spec_helper' ...@@ -2,23 +2,9 @@ require 'spec_helper'
describe Gitlab::Kubernetes::Helm::InitCommand do describe Gitlab::Kubernetes::Helm::InitCommand do
let(:application) { create(:clusters_applications_helm) } let(:application) { create(:clusters_applications_helm) }
let(:init_command) { described_class.new(application.name) } let(:commands) { 'helm init >/dev/null' }
describe '#generate_script' do subject { described_class.new(application.name) }
let(:command) do
<<~MSG.chomp
set -eo pipefail
apk add -U ca-certificates openssl >/dev/null
wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.7.0-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
mv /tmp/linux-amd64/helm /usr/bin/
helm init >/dev/null
MSG
end
subject { init_command.generate_script } it_behaves_like 'helm commands'
it 'should return the appropriate command' do
is_expected.to eq(command)
end
end
end end
...@@ -12,22 +12,15 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -12,22 +12,15 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
) )
end end
describe '#generate_script' do subject { install_command }
let(:command) do
<<~MSG it_behaves_like 'helm commands' do
set -eo pipefail let(:commands) do
apk add -U ca-certificates openssl >/dev/null <<~EOS
wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.7.0-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
mv /tmp/linux-amd64/helm /usr/bin/
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
MSG EOS
end end
subject { install_command.generate_script }
it 'should return appropriate command' do
is_expected.to eq(command)
end end
context 'with an application with a repository' do context 'with an application with a repository' do
...@@ -42,20 +35,13 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do ...@@ -42,20 +35,13 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
) )
end end
let(:command) do it_behaves_like 'helm commands' do
<<~MSG let(:commands) do
set -eo pipefail <<~EOS
apk add -U ca-certificates openssl >/dev/null
wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.7.0-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
mv /tmp/linux-amd64/helm /usr/bin/
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
MSG EOS
end
it 'should return appropriate command' do
is_expected.to eq(command)
end end
end end
end end
......
shared_examples 'helm commands' do
describe '#generate_script' do
let(:helm_setup) do
<<~EOS
set -eo pipefail
ALPINE_VERSION=$(cat /etc/alpine-release | cut -d '.' -f 1,2)
echo http://mirror.clarkson.edu/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories
echo http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories
apk add -U ca-certificates openssl >/dev/null
wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.7.0-linux-amd64.tar.gz | tar zxC /tmp >/dev/null
mv /tmp/linux-amd64/helm /usr/bin/
EOS
end
it 'should return appropriate command' do
expect(subject.generate_script).to eq(helm_setup + commands)
end
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