Skip to content
Snippets Groups Projects

Incorporates Kubernetes Namespace into Cluster's flow

Merged Thong Kuah requested to merge 51716-create-kube-namespace into master
Compare and
31 files
+ 993
327
Compare changes
  • Side-by-side
  • Inline
Files
31
@@ -6,6 +6,7 @@ class Kubernetes < ActiveRecord::Base
include Gitlab::Kubernetes
include ReactiveCaching
include EnumWithNil
include AfterCommitQueue
RESERVED_NAMESPACES = %w(gitlab-managed-apps).freeze
@@ -43,6 +44,7 @@ class Kubernetes < ActiveRecord::Base
validate :prevent_modification, on: :update
after_save :clear_reactive_cache!
after_update :update_kubernetes_namespace
alias_attribute :ca_pem, :ca_cert
@@ -60,11 +62,7 @@ class Kubernetes < ActiveRecord::Base
}
def actual_namespace
if namespace.present?
namespace
else
default_namespace
end
kubernetes_namespace&.namespace.presence || fallback_default_namespace
end
def predefined_variables
@@ -116,12 +114,16 @@ def kubeconfig
to_kubeconfig(
url: api_url,
namespace: actual_namespace,
token: token,
token: fetch_token,
ca_pem: ca_pem)
end
def default_namespace
kubernetes_namespace&.namespace.presence || fallback_default_namespace
def fetch_token
if rbac?
kubernetes_namespace.service_account_token
else
token
end
end
# DEPRECATED
@@ -201,6 +203,14 @@ def prevent_modification
true
end
def update_kubernetes_namespace
return unless namespace_changed?
run_after_commit do
ClusterPlatformConfigureWorker.perform_async(cluster_id)
end
end
end
end
end
Loading