Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
d65cd0a6
Commit
d65cd0a6
authored
Sep 26, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tie KubernetesService
parent
bdc618c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
13 deletions
+33
-13
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+29
-11
app/models/ci/cluster.rb
app/models/ci/cluster.rb
+1
-0
config/routes/project.rb
config/routes/project.rb
+2
-1
lib/google_api/cloud_platform/client.rb
lib/google_api/cloud_platform/client.rb
+1
-1
No files found.
app/controllers/projects/clusters_controller.rb
View file @
d65cd0a6
...
...
@@ -32,8 +32,10 @@ class Projects::ClustersController < Projects::ApplicationController
# - If create on GKE, Use Google::Apis::ContainerV1::ContainerService
# - If create manually, save in db (Prob, Project > Setting)
# - Dry up with Service
# - Transaction
def
create
if
params
[
'creation_type'
]
==
'on_gke'
# Create a cluster on GKE
results
=
api_client
.
projects_zones_clusters_create
(
params
[
'gcp_project_id'
],
params
[
'cluster_zone'
],
...
...
@@ -41,22 +43,24 @@ class Projects::ClustersController < Projects::ApplicationController
params
[
'cluster_size'
]
)
# TODO: How to create
project
.
kubernetes_service
.
save
(
end_point:
results
[
'end_point'
],
ca_cert:
results
[
'ca_cert'
],
token:
nil
,
username:
results
[
'username'
],
password:
results
[
'password'
],
project_namespace:
params
[
'project_namespace'
]
)
# Update service
kubernetes_service
.
attributes
=
service_params
(
active:
true
,
api_url:
results
[
'end_point'
],
ca_pem:
results
[
'ca_cert'
],
# TODO: Decode Base64
namespace:
params
[
'project_namespace'
],
token:
'aaa'
# TODO: username/password
)
kubernetes_service
.
save!
# Save info
project
.
clusters
.
create
(
creation_type:
params
[
'creation_type'
],
gcp_project_id:
params
[
'gcp_project_id'
],
cluster_zone:
params
[
'cluster_zone'
],
cluster_name:
params
[
'cluster_name'
],
kubernetes_service:
project
.
kubernetes_service
service:
kubernetes_service
)
elsif
params
[
'creation_type'
]
==
'manual'
# TODO: Transaction
...
...
@@ -121,7 +125,7 @@ class Projects::ClustersController < Projects::ApplicationController
def
cluster
# Each project has only one cluster, for now. In the future iteraiton, we'll support multiple clusters
@cluster
||=
project
.
clusters
.
fir
st
@cluster
||=
project
.
clusters
.
la
st
end
# def cluster_params
...
...
@@ -136,4 +140,18 @@ class Projects::ClustersController < Projects::ApplicationController
state:
namespace_project_clusters_url
.
to_s
)
end
def
kubernetes_service
@kubernetes_service
||=
project
.
find_or_initialize_service
(
'kubernetes'
)
end
def
service_params
(
active
:,
api_url
:,
ca_pem
:,
namespace
:,
token
:)
{
active:
active
,
api_url:
api_url
,
ca_pem:
ca_pem
,
namespace:
namespace
,
token:
token
}
end
end
app/models/ci/cluster.rb
View file @
d65cd0a6
...
...
@@ -4,6 +4,7 @@ module Ci
belongs_to
:project
belongs_to
:owner
,
class_name:
'User'
belongs_to
:service
enum
creation_type:
{
unknown:
nil
,
...
...
config/routes/project.rb
View file @
d65cd0a6
...
...
@@ -183,10 +183,11 @@ constraints(ProjectUrlConstrainer.new) do
end
end
resources
:clusters
,
except:
[
:show
,
:destroy
]
do
resources
:clusters
,
except:
[
:
edit
,
:
show
,
:destroy
]
do
collection
do
get
:gcp_projects
# TODO: This doesn't belong here. Grape or under user. Hint. Serilizer
get
:gke_zones
get
:edit
end
end
...
...
lib/google_api/cloud_platform/client.rb
View file @
d65cd0a6
...
...
@@ -28,7 +28,7 @@ module GoogleApi
# TODO: Debug
{
'end_point'
=>
'111.111.111.111'
,
'end_point'
=>
'
https://
111.111.111.111'
,
'ca_cert'
=>
'XXXXXXXXXXXXXXXXXX'
,
'username'
=>
'AAA'
,
'password'
=>
'BBB'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment