Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Dapr
提交
8fe64ab7
D
Dapr
项目概览
int
/
Dapr
12 个月 前同步成功
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dapr
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8fe64ab7
编写于
6月 25, 2019
作者:
Y
Yaron Schneider
提交者:
GitHub
6月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
externalize image to config (#52)
上级
3d7e9323
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
7 deletion
+30
-7
cmd/controller/main.go
cmd/controller/main.go
+5
-1
pkg/controller/config.go
pkg/controller/config.go
+14
-0
pkg/controller/controller.go
pkg/controller/controller.go
+2
-2
pkg/handlers/actions_handler.go
pkg/handlers/actions_handler.go
+9
-4
未找到文件。
cmd/controller/main.go
浏览文件 @
8fe64ab7
...
...
@@ -19,7 +19,11 @@ func main() {
log
.
Fatalf
(
"Error building Kubernetes clients: %s"
,
err
)
}
controller
.
NewController
(
kubeClient
,
actionsClient
)
.
Run
(
ctx
)
cfg
,
err
:=
controller
.
GetConfigFromEnvironment
()
if
err
!=
nil
{
log
.
Fatalf
(
"Error getting config: %s"
,
err
)
}
controller
.
NewController
(
kubeClient
,
actionsClient
,
cfg
)
.
Run
(
ctx
)
shutdownDuration
:=
5
*
time
.
Second
log
.
Infof
(
"allowing %s for graceful shutdown to complete"
,
shutdownDuration
)
...
...
pkg/controller/config.go
0 → 100644
浏览文件 @
8fe64ab7
package
controller
import
"github.com/kelseyhightower/envconfig"
type
Config
struct
{
ActionsRuntimeImage
string
`envconfig:"RUNTIME_IMAGE" required:"true"`
}
func
GetConfigFromEnvironment
()
(
Config
,
error
)
{
c
:=
Config
{}
err
:=
envconfig
.
Process
(
""
,
&
c
)
return
c
,
err
}
pkg/controller/controller.go
浏览文件 @
8fe64ab7
...
...
@@ -27,7 +27,7 @@ type controller struct {
EventSourcesHandler
handlers
.
Handler
}
func
NewController
(
kubeClient
kubernetes
.
Interface
,
actionsClient
scheme
.
Interface
)
*
controller
{
func
NewController
(
kubeClient
kubernetes
.
Interface
,
actionsClient
scheme
.
Interface
,
config
Config
)
*
controller
{
c
:=
&
controller
{
KubeClient
:
kubeClient
,
ActionsClient
:
actionsClient
,
...
...
@@ -43,7 +43,7 @@ func NewController(kubeClient kubernetes.Interface, actionsClient scheme.Interfa
nil
,
nil
,
),
ActionsHandler
:
handlers
.
NewActionsHandler
(
actionsClient
),
ActionsHandler
:
handlers
.
NewActionsHandler
(
actionsClient
,
handlers
.
ActionsHandlerConfig
{
RuntimeImage
:
config
.
ActionsRuntimeImage
}
),
EventSourcesHandler
:
handlers
.
NewEventSourcesHandler
(
kubeClient
),
}
...
...
pkg/handlers/actions_handler.go
浏览文件 @
8fe64ab7
...
...
@@ -25,7 +25,6 @@ const (
actionSidecarContainerName
=
"action"
actionSidecarHTTPPortName
=
"actions-http"
actionSidecarGRPCPortName
=
"actions-grpc"
actionSidecarImage
=
"yaron2/actionsedge:v2"
actionSidecarHTTPPort
=
3500
actionSidecarGRPCPort
=
50001
apiAddress
=
"http://actions-api.default.svc.cluster.local"
...
...
@@ -37,10 +36,16 @@ const (
type
ActionsHandler
struct
{
Client
scheme
.
Interface
DeploymentsLock
*
sync
.
Mutex
Config
ActionsHandlerConfig
}
func
NewActionsHandler
(
client
scheme
.
Interface
)
*
ActionsHandler
{
type
ActionsHandlerConfig
struct
{
RuntimeImage
string
}
func
NewActionsHandler
(
client
scheme
.
Interface
,
config
ActionsHandlerConfig
)
*
ActionsHandler
{
return
&
ActionsHandler
{
Config
:
config
,
Client
:
client
,
DeploymentsLock
:
&
sync
.
Mutex
{},
}
...
...
@@ -51,7 +56,7 @@ func (r *ActionsHandler) Init() error {
return
nil
}
func
(
r
*
ActionsHandler
)
GetEventingSidecar
(
applicationPort
,
applicationProtocol
,
actionName
string
)
v1
.
Container
{
func
(
r
*
ActionsHandler
)
GetEventingSidecar
(
applicationPort
,
applicationProtocol
,
actionName
,
actionSidecarImage
string
)
v1
.
Container
{
return
v1
.
Container
{
Name
:
actionSidecarContainerName
,
Image
:
actionSidecarImage
,
...
...
@@ -149,7 +154,7 @@ func (r *ActionsHandler) EnableAction(deployment *appsv1.Deployment) error {
appPort
:=
r
.
GetApplicationPort
(
deployment
.
Spec
.
Template
.
Spec
.
Containers
)
appProtocol
:=
r
.
GetAppProtocol
(
deployment
)
actionName
:=
r
.
GetActionName
(
deployment
)
sidecar
:=
r
.
GetEventingSidecar
(
appPort
,
appProtocol
,
actionName
)
sidecar
:=
r
.
GetEventingSidecar
(
appPort
,
appProtocol
,
actionName
,
r
.
Config
.
RuntimeImage
)
deployment
.
Spec
.
Template
.
Spec
.
Containers
=
append
(
deployment
.
Spec
.
Template
.
Spec
.
Containers
,
sidecar
)
err
:=
r
.
CreateEventingService
(
actionName
,
deployment
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录