Class: HubClustersCreator::Providers::GKE
- Inherits:
-
Object
- Object
- HubClustersCreator::Providers::GKE
- Includes:
- Errors, Logging, HubClustersCreator::Providers::GCP::Compute, HubClustersCreator::Providers::GCP::Containers
- Defined in:
- lib/hub-clusters-creator/providers/gke/gke.rb
Overview
GKE provides the GKE implmentation
Constant Summary collapse
- DEFAULT_PSP_CLUSTER_ROLE =
<<~YAML apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: default:psp rules: - apiGroups: - policy resourceNames: - gce.unprivileged-addon resources: - podsecuritypolicies verbs: - use YAML
- DEFAULT_PSP_CLUSTERROLE_BINDING =
<<~YAML apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: default:psp roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: default:psp subjects: - apiGroup: rbac.authorization.k8s.io kind: Group name: system:authenticated - apiGroup: rbac.authorization.k8s.io kind: Group name: system:serviceaccounts YAML
- Container =
Google::Apis::ContainerV1beta1
- Compute =
Google::Apis::ComputeV1
- Dns =
Google::Apis::DnsV1
Instance Method Summary collapse
-
#create(name, config) ⇒ Object
create is responsible for building the infrastructure.
-
#destroy(name) ⇒ Object
destroy is used to kill off a cluster.
-
#initialize(provider) ⇒ GKE
constructor
A new instance of GKE.
Methods included from Logging
Methods included from HubClustersCreator::Providers::GCP::Compute
#dns, #dns_records, #domain, #domain?, #domains, #network?, #networks, #router, #router?, #routers, #subnet?, #subnets
Constructor Details
#initialize(provider) ⇒ GKE
Returns a new instance of GKE.
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/hub-clusters-creator/providers/gke/gke.rb', line 78 def initialize(provider) @account = provider[:account] @project = provider[:project] @region = provider[:region] @compute = Compute::ComputeService.new @gke = Container::ContainerService.new @dns = Dns::DnsService.new @client = nil @compute. = @gke. = @dns. = end |
Instance Method Details
#create(name, config) ⇒ Object
create is responsible for building the infrastructure
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/hub-clusters-creator/providers/gke/gke.rb', line 93 def create(name, config) # @step: validate the configuration begin validate(config) rescue StandardError => e raise ConfigurationError, "invalid configuration, error: #{e}" end # @step: provision the infrastructure begin provision_gke(name, config) rescue StandardError => e raise InfrastructureError, "failed to provision cluster: '#{name}', error: #{e}" end # @step: initialize the cluster begin c = provision_cluster(name, config) rescue StandardError => e raise InitializerError, "failed to initialize the cluster: '#{name}', error: #{e}" end { cluster: { ca: c.master_auth.cluster_ca_certificate, endpoint: "https://#{c.endpoint}", token: @client.account('sysadmin') }, config: config, services: { grafana: { hostname: config[:grafana_hostname] } } } end |
#destroy(name) ⇒ Object
destroy is used to kill off a cluster
131 132 133 |
# File 'lib/hub-clusters-creator/providers/gke/gke.rb', line 131 def destroy(name) @gke.delete_project_location_cluster("projects/#{@project}/locations/#{@region}/clusters/#{name}") end |