diff options
author | Tiger <twatson@gitlab.com> | 2019-06-07 04:24:59 +0300 |
---|---|---|
committer | Tiger <twatson@gitlab.com> | 2019-06-18 02:09:11 +0300 |
commit | 5aa9b710be2e03b296b68942d4053fa0a24e884c (patch) | |
tree | 5c7e49194490d49422196c1fbf935058a2199bee /app/models/clusters/platforms/kubernetes.rb | |
parent | 11810cb2b7185202c5178557ebb6205b27ed4148 (diff) |
Allow switching clusters between managed/unmanaged
Any resources created while the cluster was managed
will be untouched, allowing users to set/unset this
flag as they please.
Diffstat (limited to 'app/models/clusters/platforms/kubernetes.rb')
-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 |