diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-06-18 04:11:48 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-06-18 04:11:48 +0300 |
commit | db9ef69272155b3c8ead5c0e7d027bda2b623d43 (patch) | |
tree | f95645eb6a20e0613c5f4d02b01bb4a34ee5205c /app/models/clusters | |
parent | 1276ff85453c6331e53f79680627c981b5ef00f7 (diff) | |
parent | 5aa9b710be2e03b296b68942d4053fa0a24e884c (diff) |
Merge branch '60617-allow-switching-from-gitlab-managed-to-unmanaged-clusters' into 'master'
Allow switching clusters between managed/unmanaged
Closes #60617
See merge request gitlab-org/gitlab-ce!29322
Diffstat (limited to 'app/models/clusters')
-rw-r--r-- | app/models/clusters/platforms/kubernetes.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index 8e06156c73d..272861cacf0 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -80,9 +80,18 @@ module Clusters .append(key: 'KUBE_CA_PEM_FILE', value: ca_pem, file: true) end - if kubernetes_namespace = cluster.kubernetes_namespaces.has_service_account_token.find_by(project: project) + if !cluster.managed? + project_namespace = namespace.presence || "#{project.path}-#{project.id}".downcase + + variables + .append(key: 'KUBE_URL', value: api_url) + .append(key: 'KUBE_TOKEN', value: token, public: false, masked: true) + .append(key: 'KUBE_NAMESPACE', value: project_namespace) + .append(key: 'KUBECONFIG', value: kubeconfig(project_namespace), public: false, file: true) + + elsif kubernetes_namespace = cluster.kubernetes_namespaces.has_service_account_token.find_by(project: project) variables.concat(kubernetes_namespace.predefined_variables) - elsif cluster.project_type? || !cluster.managed? + elsif cluster.project_type? # As of 11.11 a user can create a cluster that they manage themselves, # which replicates the existing project-level cluster behaviour. # Once we have marked all project-level clusters that make use of this |