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
6 files
+ 37
21
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -46,6 +46,8 @@ class Kubernetes < ActiveRecord::Base
@@ -46,6 +46,8 @@ class Kubernetes < ActiveRecord::Base
delegate :enabled?, to: :cluster, allow_nil: true
delegate :enabled?, to: :cluster, allow_nil: true
delegate :managed?, to: :cluster, allow_nil: true
delegate :managed?, to: :cluster, allow_nil: true
 
delegate :cluster_project, to: :project, allow_nil: true
 
alias_method :active?, :enabled?
alias_method :active?, :enabled?
enum_with_nil authorization_type: {
enum_with_nil authorization_type: {
@@ -55,6 +57,12 @@ class Kubernetes < ActiveRecord::Base
@@ -55,6 +57,12 @@ class Kubernetes < ActiveRecord::Base
}
}
def actual_namespace
def actual_namespace
 
cluster_project&.namespace || fallback_actual_namespace
 
end
 
 
# DEPRECATED
 
# To remove after migration of data to cluster_projects
 
def fallback_actual_namespace
if namespace.present?
if namespace.present?
namespace
namespace
else
else
@@ -115,6 +123,7 @@ def kubeconfig
@@ -115,6 +123,7 @@ def kubeconfig
ca_pem: ca_pem)
ca_pem: ca_pem)
end
end
 
# DEPRECATED
def default_namespace
def default_namespace
return unless project
return unless project
@@ -123,7 +132,7 @@ def default_namespace
@@ -123,7 +132,7 @@ def default_namespace
end
end
def build_kube_client!(api_groups: ['api'], api_version: 'v1')
def build_kube_client!(api_groups: ['api'], api_version: 'v1')
raise "Incomplete settings" unless api_url && actual_namespace
raise "Incomplete settings" unless api_url
unless (username && password) || token
unless (username && password) || token
raise "Either username/password or token is required to access API"
raise "Either username/password or token is required to access API"
Loading