未验证 提交 e45ed8b3 编写于 作者: Y Yaron Schneider 提交者: GitHub

added image pull secret to controller config (#63)

上级 c02f6ad7
......@@ -4,6 +4,7 @@ import "github.com/kelseyhightower/envconfig"
type Config struct {
ActionsRuntimeImage string `envconfig:"RUNTIME_IMAGE" required:"true"`
ImagePullSecretName string `envconfig:"IMAGE_PULL_SECRET_NAME" required:"false"`
}
func GetConfigFromEnvironment() (Config, error) {
......
......@@ -43,7 +43,7 @@ func NewController(kubeClient kubernetes.Interface, actionsClient scheme.Interfa
nil,
nil,
),
ActionsHandler: handlers.NewActionsHandler(actionsClient, handlers.ActionsHandlerConfig{RuntimeImage: config.ActionsRuntimeImage}),
ActionsHandler: handlers.NewActionsHandler(actionsClient, handlers.ActionsHandlerConfig{RuntimeImage: config.ActionsRuntimeImage, ImagePullSecretName: config.ImagePullSecretName}),
EventSourcesHandler: handlers.NewEventSourcesHandler(kubeClient),
}
......
......@@ -40,7 +40,8 @@ type ActionsHandler struct {
}
type ActionsHandlerConfig struct {
RuntimeImage string
RuntimeImage string
ImagePullSecretName string
}
func NewActionsHandler(client scheme.Interface, config ActionsHandlerConfig) *ActionsHandler {
......@@ -150,26 +151,6 @@ func (r *ActionsHandler) GetAppProtocol(deployment *appsv1.Deployment) string {
return string(HTTPProtocol)
}
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, r.Config.RuntimeImage)
deployment.Spec.Template.Spec.Containers = append(deployment.Spec.Template.Spec.Containers, sidecar)
err := r.CreateEventingService(actionName, deployment)
if err != nil {
return err
}
err = kubernetes.UpdateDeployment(deployment)
if err != nil {
return err
}
return nil
}
func (r *ActionsHandler) IsAnnotatedForActions(deployment *appsv1.Deployment) bool {
annotations := deployment.ObjectMeta.Annotations
if annotations != nil {
......@@ -191,6 +172,32 @@ func (r *ActionsHandler) ActionEnabled(deployment *appsv1.Deployment) bool {
return false
}
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, r.Config.RuntimeImage)
deployment.Spec.Template.Spec.Containers = append(deployment.Spec.Template.Spec.Containers, sidecar)
if r.Config.ImagePullSecretName != "" {
deployment.Spec.Template.Spec.ImagePullSecrets = append(deployment.Spec.Template.Spec.ImagePullSecrets, corev1.LocalObjectReference{
Name: r.Config.ImagePullSecretName,
})
}
err := r.CreateEventingService(actionName, deployment)
if err != nil {
return err
}
err = kubernetes.UpdateDeployment(deployment)
if err != nil {
return err
}
return nil
}
func (r *ActionsHandler) RemoveActionFromDeployment(deployment *appsv1.Deployment) error {
for i := len(deployment.Spec.Template.Spec.Containers) - 1; i >= 0; i-- {
if deployment.Spec.Template.Spec.Containers[i].Name == actionSidecarContainerName {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册