Class: Clusters::Kubernetes::CreateOrUpdateServiceAccountService

Inherits:
Object
  • Object
show all
Defined in:
app/services/clusters/kubernetes/create_or_update_service_account_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kubeclient, service_account_name:, service_account_namespace:, token_name:, rbac:, service_account_namespace_labels: nil, namespace_creator: false, role_binding_name: nil) ⇒ CreateOrUpdateServiceAccountService

Returns a new instance of CreateOrUpdateServiceAccountService.



6
7
8
9
10
11
12
13
14
15
# File 'app/services/clusters/kubernetes/create_or_update_service_account_service.rb', line 6

def initialize(kubeclient, service_account_name:, service_account_namespace:, token_name:, rbac:, service_account_namespace_labels: nil, namespace_creator: false, role_binding_name: nil)
  @kubeclient = kubeclient
  @service_account_name = 
  @service_account_namespace = 
  @service_account_namespace_labels = 
  @token_name = token_name
  @rbac = rbac
  @namespace_creator = namespace_creator
  @role_binding_name = role_binding_name
end

Class Method Details

.gitlab_creator(kubeclient, rbac:) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/services/clusters/kubernetes/create_or_update_service_account_service.rb', line 17

def self.gitlab_creator(kubeclient, rbac:)
  self.new(
    kubeclient,
    service_account_name: Clusters::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAME,
    service_account_namespace: Clusters::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAMESPACE,
    token_name: Clusters::Kubernetes::GITLAB_ADMIN_TOKEN_NAME,
    rbac: rbac
  )
end

.namespace_creator(kubeclient, service_account_name:, service_account_namespace:, service_account_namespace_labels:, rbac:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/services/clusters/kubernetes/create_or_update_service_account_service.rb', line 27

def self.namespace_creator(kubeclient, service_account_name:, service_account_namespace:, service_account_namespace_labels:, rbac:)
  self.new(
    kubeclient,
    service_account_name: ,
    service_account_namespace: ,
    service_account_namespace_labels: ,
    token_name: "#{}-token",
    rbac: rbac,
    namespace_creator: true,
    role_binding_name: "gitlab-#{}"
  )
end

Instance Method Details

#executeObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/services/clusters/kubernetes/create_or_update_service_account_service.rb', line 40

def execute
  ensure_project_namespace_exists if namespace_creator

  kubeclient.()
  kubeclient.create_or_update_secret()

  return unless rbac

  create_role_or_cluster_role_binding

  return unless namespace_creator

  create_or_update_knative_serving_role
  create_or_update_knative_serving_role_binding
  create_or_update_crossplane_database_role
  create_or_update_crossplane_database_role_binding
end