Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
31c256c1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
31c256c1
编写于
11月 02, 2017
作者:
A
Alessio Caiazza
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
General cleanup
上级
30938b89
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
21 addition
and
38 deletion
+21
-38
app/models/clusters/applications/helm.rb
app/models/clusters/applications/helm.rb
+1
-1
app/services/clusters/base_helm_service.rb
app/services/clusters/base_helm_service.rb
+1
-1
app/services/clusters/install_app_service.rb
app/services/clusters/install_app_service.rb
+0
-1
app/services/clusters/install_tiller_service.rb
app/services/clusters/install_tiller_service.rb
+0
-24
db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
...te/20171031100710_create_clusters_kubernetes_helm_apps.rb
+4
-0
lib/gitlab/kubernetes/helm.rb
lib/gitlab/kubernetes/helm.rb
+15
-11
未找到文件。
app/models/clusters/applications/helm.rb
浏览文件 @
31c256c1
...
@@ -9,7 +9,7 @@ module Clusters
...
@@ -9,7 +9,7 @@ module Clusters
belongs_to
:cluster
,
class_name:
'Clusters::Cluster'
,
foreign_key: :cluster_id
belongs_to
:cluster
,
class_name:
'Clusters::Cluster'
,
foreign_key: :cluster_id
default_value_for
:version
,
Gitlab
::
Cluster
s
::
Helm
::
HELM_VERSION
default_value_for
:version
,
Gitlab
::
Kubernete
s
::
Helm
::
HELM_VERSION
def
name
def
name
NAME
NAME
...
...
app/services/clusters/base_helm_service.rb
浏览文件 @
31c256c1
...
@@ -17,7 +17,7 @@ module Clusters
...
@@ -17,7 +17,7 @@ module Clusters
end
end
def
helm_api
def
helm_api
@helm
||=
Gitlab
::
Cluster
s
::
Helm
.
new
(
kubeclient
)
@helm
||=
Gitlab
::
Kubernete
s
::
Helm
.
new
(
kubeclient
)
end
end
end
end
end
end
app/services/clusters/install_app_service.rb
浏览文件 @
31c256c1
...
@@ -15,7 +15,6 @@ module Clusters
...
@@ -15,7 +15,6 @@ module Clusters
rescue
KubeException
=>
ke
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
rescue
StandardError
=>
e
rescue
StandardError
=>
e
Rails
.
logger
.
warn
(
e
.
message
)
app
.
make_errored!
(
"Can't start installation process"
)
app
.
make_errored!
(
"Can't start installation process"
)
end
end
end
end
...
...
app/services/clusters/install_tiller_service.rb
已删除
100644 → 0
浏览文件 @
30938b89
module
Clusters
class
InstallTillerService
<
BaseService
def
execute
ensure_namespace
install
end
private
def
kubernetes_service
return
@kubernetes_service
if
defined?
(
@kubernetes_service
)
@kubernetes_service
=
project
&
.
kubernetes_service
end
def
ensure_namespace
kubernetes_service
&
.
ensure_namespace!
end
def
install
kubernetes_service
&
.
helm_client
&
.
init!
end
end
end
db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
浏览文件 @
31c256c1
class
CreateClustersKubernetesHelmApps
<
ActiveRecord
::
Migration
class
CreateClustersKubernetesHelmApps
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
def
change
create_table
:clusters_applications_helm
do
|
t
|
create_table
:clusters_applications_helm
do
|
t
|
t
.
references
:cluster
,
null:
false
,
unique:
true
,
foreign_key:
{
on_delete: :cascade
}
t
.
references
:cluster
,
null:
false
,
unique:
true
,
foreign_key:
{
on_delete: :cascade
}
...
...
lib/gitlab/
cluster
s/helm.rb
→
lib/gitlab/
kubernete
s/helm.rb
浏览文件 @
31c256c1
module
Gitlab
module
Gitlab
module
Cluster
s
module
Kubernete
s
class
Helm
class
Helm
Error
=
Class
.
new
(
StandardError
)
HELM_VERSION
=
'2.7.0'
.
freeze
HELM_VERSION
=
'2.7.0'
.
freeze
NAMESPACE
=
'gitlab-managed-apps'
.
freeze
NAMESPACE
=
'gitlab-managed-apps'
.
freeze
COMMAND_SCRIPT
=
<<-
EOS
.
freeze
COMMAND_SCRIPT
=
<<-
EOS
.
freeze
...
@@ -18,12 +17,11 @@ module Gitlab
...
@@ -18,12 +17,11 @@ module Gitlab
end
end
def
init!
def
init!
ensure_namespace!
install
(
OpenStruct
.
new
(
name:
'helm'
))
@kubeclient
.
create_pod
(
pod_resource
(
OpenStruct
.
new
(
name:
'helm'
)))
end
end
def
install
(
app
)
def
install
(
app
)
ensure_namespace!
create_namespace!
unless
has_namespace?
@kubeclient
.
create_pod
(
pod_resource
(
app
))
@kubeclient
.
create_pod
(
pod_resource
(
app
))
end
end
...
@@ -86,18 +84,24 @@ module Gitlab
...
@@ -86,18 +84,24 @@ module Gitlab
"install
#{
app
.
chart
}
--name
#{
app
.
name
}
--namespace
#{
NAMESPACE
}
"
"install
#{
app
.
chart
}
--name
#{
app
.
name
}
--namespace
#{
NAMESPACE
}
"
end
end
def
ensure_namespace!
def
has_namespace?
return
@has_namespace
if
defined?
(
@has_namespace
)
begin
begin
@kubeclient
.
get_namespace
(
NAMESPACE
)
@kubeclient
.
get_namespace
(
NAMESPACE
)
@has_namespace
=
true
rescue
KubeException
=>
ke
rescue
KubeException
=>
ke
raise
ke
unless
ke
.
error_code
==
404
raise
ke
unless
ke
.
error_code
==
404
false
end
end
namespace_resource
=
::
Kubeclient
::
Resource
.
new
def
create_namespace!
namespace_resource
.
metadata
=
{}
namespace_resource
=
::
Kubeclient
::
Resource
.
new
namespace_resource
.
metadata
.
name
=
NAMESPACE
namespace_resource
.
metadata
=
{}
namespace_resource
.
metadata
.
name
=
NAMESPACE
@kubeclient
.
create_namespace
(
namespace_resource
)
@kubeclient
.
create_namespace
(
namespace_resource
)
end
end
end
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录