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
1
Merge Requests
1
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
nexedi
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
Show 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
...
@@ -32,8 +32,10 @@ class Projects::ClustersController < Projects::ApplicationController
# - If create on GKE, Use Google::Apis::ContainerV1::ContainerService
# - If create on GKE, Use Google::Apis::ContainerV1::ContainerService
# - If create manually, save in db (Prob, Project > Setting)
# - If create manually, save in db (Prob, Project > Setting)
# - Dry up with Service
# - Dry up with Service
# - Transaction
def
create
def
create
if
params
[
'creation_type'
]
==
'on_gke'
if
params
[
'creation_type'
]
==
'on_gke'
# Create a cluster on GKE
results
=
api_client
.
projects_zones_clusters_create
(
results
=
api_client
.
projects_zones_clusters_create
(
params
[
'gcp_project_id'
],
params
[
'gcp_project_id'
],
params
[
'cluster_zone'
],
params
[
'cluster_zone'
],
...
@@ -41,22 +43,24 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -41,22 +43,24 @@ class Projects::ClustersController < Projects::ApplicationController
params
[
'cluster_size'
]
params
[
'cluster_size'
]
)
)
# TODO: How to create
# Update service
project
.
kubernetes_service
.
save
(
kubernetes_service
.
attributes
=
service_params
(
end_point:
results
[
'end_point'
],
active:
true
,
ca_cert:
results
[
'ca_cert'
],
api_url:
results
[
'end_point'
],
token:
nil
,
ca_pem:
results
[
'ca_cert'
],
# TODO: Decode Base64
username:
results
[
'username'
],
namespace:
params
[
'project_namespace'
],
password:
results
[
'password'
],
token:
'aaa'
# TODO: username/password
project_namespace:
params
[
'project_namespace'
]
)
)
kubernetes_service
.
save!
# Save info
project
.
clusters
.
create
(
project
.
clusters
.
create
(
creation_type:
params
[
'creation_type'
],
creation_type:
params
[
'creation_type'
],
gcp_project_id:
params
[
'gcp_project_id'
],
gcp_project_id:
params
[
'gcp_project_id'
],
cluster_zone:
params
[
'cluster_zone'
],
cluster_zone:
params
[
'cluster_zone'
],
cluster_name:
params
[
'cluster_name'
],
cluster_name:
params
[
'cluster_name'
],
kubernetes_service:
project
.
kubernetes_service
service:
kubernetes_service
)
)
elsif
params
[
'creation_type'
]
==
'manual'
elsif
params
[
'creation_type'
]
==
'manual'
# TODO: Transaction
# TODO: Transaction
...
@@ -121,7 +125,7 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -121,7 +125,7 @@ class Projects::ClustersController < Projects::ApplicationController
def
cluster
def
cluster
# Each project has only one cluster, for now. In the future iteraiton, we'll support multiple clusters
# 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
end
# def cluster_params
# def cluster_params
...
@@ -136,4 +140,18 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -136,4 +140,18 @@ class Projects::ClustersController < Projects::ApplicationController
state:
namespace_project_clusters_url
.
to_s
state:
namespace_project_clusters_url
.
to_s
)
)
end
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
end
app/models/ci/cluster.rb
View file @
d65cd0a6
...
@@ -4,6 +4,7 @@ module Ci
...
@@ -4,6 +4,7 @@ module Ci
belongs_to
:project
belongs_to
:project
belongs_to
:owner
,
class_name:
'User'
belongs_to
:owner
,
class_name:
'User'
belongs_to
:service
enum
creation_type:
{
enum
creation_type:
{
unknown:
nil
,
unknown:
nil
,
...
...
config/routes/project.rb
View file @
d65cd0a6
...
@@ -183,10 +183,11 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -183,10 +183,11 @@ constraints(ProjectUrlConstrainer.new) do
end
end
end
end
resources
:clusters
,
except:
[
:show
,
:destroy
]
do
resources
:clusters
,
except:
[
:
edit
,
:
show
,
:destroy
]
do
collection
do
collection
do
get
:gcp_projects
# TODO: This doesn't belong here. Grape or under user. Hint. Serilizer
get
:gcp_projects
# TODO: This doesn't belong here. Grape or under user. Hint. Serilizer
get
:gke_zones
get
:gke_zones
get
:edit
end
end
end
end
...
...
lib/google_api/cloud_platform/client.rb
View file @
d65cd0a6
...
@@ -28,7 +28,7 @@ module GoogleApi
...
@@ -28,7 +28,7 @@ module GoogleApi
# TODO: Debug
# TODO: Debug
{
{
'end_point'
=>
'111.111.111.111'
,
'end_point'
=>
'
https://
111.111.111.111'
,
'ca_cert'
=>
'XXXXXXXXXXXXXXXXXX'
,
'ca_cert'
=>
'XXXXXXXXXXXXXXXXXX'
,
'username'
=>
'AAA'
,
'username'
=>
'AAA'
,
'password'
=>
'BBB'
'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