Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --enable=automation-service-broker #19409

Merged
merged 1 commit into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions install/automationservicebroker/install-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Template
metadata:
name: automation-broker-apb-rbac
objects:
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: automation-broker-apb
roleRef:
name: cluster-admin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm... perhaps I misunderstood what's happening. This is basically an installer pod?

kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: automation-broker-apb
namespace: "${NAMESPACE}"

parameters:
- description: Namespace of the project that is being deploy
displayname: broker client cert key
name: NAMESPACE
value: "openshift-automation-service-broker"
34 changes: 34 additions & 0 deletions install/automationservicebroker/install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v1
kind: Template
metadata:
name: automation-broker-apb
objects:
- apiVersion: v1
kind: ServiceAccount
metadata:
name: automation-broker-apb
namespace: "${NAMESPACE}"

- apiVersion: batch/v1
kind: Job
metadata:
name: automation-broker-apb
namespace: "${NAMESPACE}"
spec:
backoffLimit: 5
activeDeadlineSeconds: 300
template:
spec:
restartPolicy: OnFailure
serviceAccount: automation-broker-apb
containers:
- image: docker.io/automationbroker/automation-broker-apb:latest
name: automation-broker-apb
args: [ "provision", "-e", "broker_name=${NAMESPACE}" ]


parameters:
- description: Namespace of the project that is being deploy
displayname: broker client cert key
name: NAMESPACE
value: "openshift-automation-service-broker"
99 changes: 99 additions & 0 deletions pkg/oc/bootstrap/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/oc/bootstrap/clusteradd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/variable"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/componentinstall"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/components/automation-service-broker"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/components/default-imagestreams"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/components/registry"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/components/router"
Expand Down Expand Up @@ -48,6 +49,9 @@ var (

// availableComponents lists the components that are available for installation.
var availableComponents = map[string]func(ctx componentinstall.Context) componentinstall.Component{
"automation-service-broker": func(ctx componentinstall.Context) componentinstall.Component {
return &automation_service_broker.AutomationServiceBrokerComponentOptions{InstallContext: ctx}
},
"centos-imagestreams": func(ctx componentinstall.Context) componentinstall.Component {
return &default_imagestreams.CentosImageStreamsComponentOptions{InstallContext: ctx}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
reviewers:
- jmontleon
- djzager
approvers:
- jmontleon
- djzager
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package automation_service_broker

import (
"github.com/golang/glog"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/openshift/origin/pkg/oc/bootstrap"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/componentinstall"
"github.com/openshift/origin/pkg/oc/bootstrap/docker/dockerhelper"
"github.com/openshift/origin/pkg/oc/errors"
"k8s.io/client-go/kubernetes"
)

const (
asbNamespace = "openshift-automation-service-broker"
)

type AutomationServiceBrokerComponentOptions struct {
InstallContext componentinstall.Context
}

func (c *AutomationServiceBrokerComponentOptions) Name() string {
return "automation-service-broker"
}

func (c *AutomationServiceBrokerComponentOptions) Install(dockerClient dockerhelper.Interface) error {
kubeAdminClient, err := kubernetes.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
if err != nil {
return errors.NewError("cannot obtain API clients").WithCause(err)
}

params := map[string]string{
"NAMESPACE": asbNamespace,
}
glog.V(2).Infof("instantiating automation service broker template with parameters %v", params)

component := componentinstall.Template{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're going to require the WaitCondition value.

@mfojtik probably worth updating to enforce. I can't think of a reason not to.

Name: "automation-service-broker",
Namespace: asbNamespace,
RBACTemplate: bootstrap.MustAsset("install/automationservicebroker/install-rbac.yaml"),
InstallTemplate: bootstrap.MustAsset("install/automationservicebroker/install.yaml"),

WaitCondition: func() (bool, error) {
glog.V(2).Infof("polling for automation broker apb to complete")
job, err := kubeAdminClient.BatchV1().Jobs(asbNamespace).Get("automation-broker-apb", metav1.GetOptions{})
if err != nil {
return false, err
}
if job.Status.Succeeded > 0 {
return true, nil
}
return false, nil

},
}

return component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir(),
params).Install(dockerClient)

}
2 changes: 2 additions & 0 deletions pkg/oc/bootstrap/docker/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@ var (
"router",
"sample-templates",
"persistent-volumes",
"automation-service-broker",
"service-catalog",
"template-service-broker",
"web-console",
)

componentsDisabledByDefault = sets.NewString(
"automation-service-broker",
"service-catalog",
"template-service-broker")
)
Expand Down
Loading