diff options
author | Amit Rathi <amit@hypertrack.io> | 2018-11-12 09:36:59 +0300 |
---|---|---|
committer | Amit Rathi <amit@hypertrack.io> | 2018-11-12 09:36:59 +0300 |
commit | c2407dab3e3ba1471ccebc008179f829d21fe3ce (patch) | |
tree | b6f7165dbe4abb93dab5dde04fd4d6403a273eb0 /lib/gitlab/kubernetes | |
parent | 8837519445c319a699e0f3ced1c6912c839f3389 (diff) | |
parent | ec1d4243b2dbca7df6b793b412717f9b5b3db998 (diff) |
Merge branch 'master' into certmanager-temp
Diffstat (limited to 'lib/gitlab/kubernetes')
-rw-r--r-- | lib/gitlab/kubernetes/helm.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/base_command.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/init_command.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/install_command.rb | 29 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/pod.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/upgrade_command.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/role_binding.rb | 11 |
7 files changed, 35 insertions, 22 deletions
diff --git a/lib/gitlab/kubernetes/helm.rb b/lib/gitlab/kubernetes/helm.rb index 4a1bdf34c3e..1cd4f9e17b7 100644 --- a/lib/gitlab/kubernetes/helm.rb +++ b/lib/gitlab/kubernetes/helm.rb @@ -2,6 +2,7 @@ module Gitlab module Kubernetes module Helm HELM_VERSION = '2.7.2'.freeze + KUBECTL_VERSION = '1.11.0'.freeze NAMESPACE = 'gitlab-managed-apps'.freeze SERVICE_ACCOUNT = 'tiller'.freeze CLUSTER_ROLE_BINDING = 'tiller-admin'.freeze diff --git a/lib/gitlab/kubernetes/helm/base_command.rb b/lib/gitlab/kubernetes/helm/base_command.rb index 6752f2cff43..f2ce24fefa1 100644 --- a/lib/gitlab/kubernetes/helm/base_command.rb +++ b/lib/gitlab/kubernetes/helm/base_command.rb @@ -10,13 +10,7 @@ module Gitlab def generate_script <<~HEREDOC - 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 wget 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 - mv /tmp/linux-amd64/helm /usr/bin/ + set -xeo pipefail HEREDOC end diff --git a/lib/gitlab/kubernetes/helm/init_command.rb b/lib/gitlab/kubernetes/helm/init_command.rb index c7046a9ea75..6691080deca 100644 --- a/lib/gitlab/kubernetes/helm/init_command.rb +++ b/lib/gitlab/kubernetes/helm/init_command.rb @@ -45,7 +45,7 @@ module Gitlab def init_helm_command command = %w[helm init] + init_command_flags - command.shelljoin + " >/dev/null\n" + command.shelljoin end def init_command_flags diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb index fb8d61bc5db..e55c86ed8b1 100644 --- a/lib/gitlab/kubernetes/helm/install_command.rb +++ b/lib/gitlab/kubernetes/helm/install_command.rb @@ -4,22 +4,27 @@ module Gitlab class InstallCommand include BaseCommand - attr_reader :name, :files, :chart, :version, :repository + attr_reader :name, :files, :chart, :version, :repository, :preinstall, :postinstall - def initialize(name:, chart:, files:, rbac:, version: nil, repository: nil) + def initialize(name:, chart:, files:, rbac:, version: nil, repository: nil, preinstall: nil, postinstall: nil) @name = name @chart = chart @version = version @rbac = rbac @files = files @repository = repository + @preinstall = preinstall + @postinstall = postinstall end def generate_script super + [ init_command, repository_command, - script_command + repository_update_command, + preinstall_command, + install_command, + postinstall_command ].compact.join("\n") end @@ -30,17 +35,29 @@ module Gitlab private def init_command - 'helm init --client-only >/dev/null' + 'helm init --client-only' end def repository_command ['helm', 'repo', 'add', name, repository].shelljoin if repository end - def script_command + def repository_update_command + 'helm repo update' if repository + end + + def install_command command = ['helm', 'install', chart] + install_command_flags - command.shelljoin + " >/dev/null\n" + command.shelljoin + end + + def preinstall_command + preinstall.join("\n") if preinstall + end + + def postinstall_command + postinstall.join("\n") if postinstall end def install_command_flags diff --git a/lib/gitlab/kubernetes/helm/pod.rb b/lib/gitlab/kubernetes/helm/pod.rb index 95192b11c0d..e9c621d96f0 100644 --- a/lib/gitlab/kubernetes/helm/pod.rb +++ b/lib/gitlab/kubernetes/helm/pod.rb @@ -25,7 +25,7 @@ module Gitlab def container_specification { name: 'helm', - image: 'alpine:3.6', + image: "registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/#{Gitlab::Kubernetes::Helm::HELM_VERSION}-kube-#{Gitlab::Kubernetes::Helm::KUBECTL_VERSION}", env: generate_pod_env(command), command: %w(/bin/sh), args: %w(-c $(COMMAND_SCRIPT)) diff --git a/lib/gitlab/kubernetes/helm/upgrade_command.rb b/lib/gitlab/kubernetes/helm/upgrade_command.rb index 74188046739..b36315f7a82 100644 --- a/lib/gitlab/kubernetes/helm/upgrade_command.rb +++ b/lib/gitlab/kubernetes/helm/upgrade_command.rb @@ -36,7 +36,7 @@ module Gitlab private def init_command - 'helm init --client-only >/dev/null' + 'helm init --client-only' end def repository_command @@ -50,7 +50,7 @@ module Gitlab " --namespace #{::Gitlab::Kubernetes::Helm::NAMESPACE}" \ " -f /data/helm/#{name}/config/values.yaml" - "helm upgrade #{name} #{chart}#{upgrade_flags} >/dev/null\n" + "helm upgrade #{name} #{chart}#{upgrade_flags}" end def optional_version_flag diff --git a/lib/gitlab/kubernetes/role_binding.rb b/lib/gitlab/kubernetes/role_binding.rb index 4f3ee040bf2..cb0cb42d007 100644 --- a/lib/gitlab/kubernetes/role_binding.rb +++ b/lib/gitlab/kubernetes/role_binding.rb @@ -3,9 +3,8 @@ module Gitlab module Kubernetes class RoleBinding - attr_reader :role_name, :namespace, :service_account_name - - def initialize(role_name:, namespace:, service_account_name:) + def initialize(name:, role_name:, namespace:, service_account_name:) + @name = name @role_name = role_name @namespace = namespace @service_account_name = service_account_name @@ -21,14 +20,16 @@ module Gitlab private + attr_reader :name, :role_name, :namespace, :service_account_name + def metadata - { name: "gitlab-#{namespace}", namespace: namespace } + { name: name, namespace: namespace } end def role_ref { apiGroup: 'rbac.authorization.k8s.io', - kind: 'Role', + kind: 'ClusterRole', name: role_name } end |