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
1 unresolved thread
Compare and Show latest version
14 files
+ 209
22
Compare changes
  • Side-by-side
  • Inline
Files
14
@@ -47,7 +47,6 @@ class Kubernetes < ActiveRecord::Base
delegate :managed?, to: :cluster, allow_nil: true
delegate :cluster_project, to: :project, allow_nil: true
delegate :default_namespace, to: :cluster_project, allow_nil: true
alias_method :active?, :enabled?
@@ -58,6 +57,12 @@ class Kubernetes < ActiveRecord::Base
}
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?
namespace
else
@@ -118,8 +123,16 @@ def kubeconfig
ca_pem: ca_pem)
end
# DEPRECATED
def default_namespace
return unless project
slug = "#{project.path}-#{project.id}".downcase
slug.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '')
end
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
raise "Either username/password or token is required to access API"
Loading