Skip to content

Commit

Permalink
switch to template-service-broker binary
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k authored and bparees committed Dec 5, 2017
1 parent b85f660 commit 9776370
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 71 deletions.
7 changes: 7 additions & 0 deletions cmd/template-service-broker/tsb.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import (
"github.com/golang/glog"
"github.com/openshift/origin/pkg/cmd/util/serviceability"
tsbcmd "github.com/openshift/origin/pkg/templateservicebroker/cmd/server"

// install all APIs
_ "github.com/openshift/origin/pkg/api/install"
_ "k8s.io/kubernetes/pkg/api/install"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
_ "k8s.io/kubernetes/pkg/apis/batch/install"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
)

func main() {
Expand Down
7 changes: 7 additions & 0 deletions hack/build-local-images.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@
"files": {},
"enable_default": False,
},
"template-service-broker": {
"directory": "template-service-broker",
"binaries": {
"template-service-broker": "/usr/bin/template-service-broker"
},
"files": {}
},
}


Expand Down
4 changes: 2 additions & 2 deletions install/templateservicebroker/apiserver-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: template-service-broker-apiserver
parameters:
- name: IMAGE
value: openshift/origin:latest
value: openshift/origin-template-service-broker:latest
- name: NAMESPACE
value: openshift-template-service-broker
- name: LOGLEVEL
Expand Down Expand Up @@ -40,7 +40,7 @@ objects:
image: ${IMAGE}
imagePullPolicy: IfNotPresent
command:
- "/usr/bin/openshift"
- "/usr/bin/template-service-broker"
- "start"
- "template-service-broker"
- "--secure-port=8443"
Expand Down
4 changes: 2 additions & 2 deletions pkg/oc/bootstrap/bindata.go

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

2 changes: 1 addition & 1 deletion pkg/oc/bootstrap/docker/openshift/templateservicebroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (h *Helper) InstallTemplateServiceBroker(f *clientcmd.Factory, imageFormat
imageTemplate.Latest = false

params := map[string]string{
"IMAGE": imageTemplate.ExpandOrDie(""),
"IMAGE": imageTemplate.ExpandOrDie("template-service-broker"),
"LOGLEVEL": fmt.Sprint(serverLogLevel),
"NAMESPACE": tsbNamespace,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/bootstrap/docker/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ func (c *ClientStartConfig) InstallTemplateServiceBroker(out io.Writer) error {
}
// TODO we want to use this eventually, but until we have our own image for TSB, we have to hardcode this origin
//return c.OpenShiftHelper().InstallTemplateServiceBroker(f, c.imageFormat())
return c.OpenShiftHelper().InstallTemplateServiceBroker(f, fmt.Sprintf("%s:%s", c.Image, c.ImageVersion), c.ServerLogLevel)
return c.OpenShiftHelper().InstallTemplateServiceBroker(f, fmt.Sprintf("%s-${component}:%s", c.Image, c.ImageVersion), c.ServerLogLevel)
}

// RegisterTemplateServiceBroker will register the tsb with the service catalog
Expand Down
133 changes: 70 additions & 63 deletions test/extended/templates/templateservicebroker_bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,81 +39,88 @@ var _ = g.Describe("[Conformance][templates] templateservicebroker bind test", f
cliUser user.Info
)

g.BeforeEach(func() {
framework.SkipIfProviderIs("gce")

var err error

brokercli, portForwardCmdClose = EnsureTSB(tsbOC)

cliUser = &user.DefaultInfo{Name: cli.Username(), Groups: []string{"system:authenticated"}}

// enable unauthenticated access to the service broker
clusterrolebinding, err = cli.AdminAuthorizationClient().Authorization().ClusterRoleBindings().Create(&authorizationapi.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: cli.Namespace() + "templateservicebroker-client",
},
RoleRef: kapi.ObjectReference{
Name: bootstrappolicy.TemplateServiceBrokerClientRoleName,
},
Subjects: []kapi.ObjectReference{
{
Kind: authorizationapi.GroupKind,
Name: bootstrappolicy.UnauthenticatedGroup,
},
},
})
o.Expect(err).NotTo(o.HaveOccurred())
g.Context("", func() {
g.BeforeEach(func() {
framework.SkipIfProviderIs("gce")

err = cli.AsAdmin().Run("new-app").Args(fixture, "-p", "NAMESPACE="+cli.Namespace()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
var err error

// wait for templateinstance controller to do its thing
err = wait.Poll(time.Second, time.Minute, func() (bool, error) {
templateinstance, err := cli.TemplateClient().Template().TemplateInstances(cli.Namespace()).Get(instanceID, metav1.GetOptions{})
if err != nil {
return false, err
}
brokercli, portForwardCmdClose = EnsureTSB(tsbOC)

cliUser = &user.DefaultInfo{Name: cli.Username(), Groups: []string{"system:authenticated"}}

// enable unauthenticated access to the service broker
clusterrolebinding, err = cli.AdminAuthorizationClient().Authorization().ClusterRoleBindings().Create(&authorizationapi.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: cli.Namespace() + "templateservicebroker-client",
},
RoleRef: kapi.ObjectReference{
Name: bootstrappolicy.TemplateServiceBrokerClientRoleName,
},
Subjects: []kapi.ObjectReference{
{
Kind: authorizationapi.GroupKind,
Name: bootstrappolicy.UnauthenticatedGroup,
},
},
})
o.Expect(err).NotTo(o.HaveOccurred())

for _, c := range templateinstance.Status.Conditions {
if c.Reason == "Failed" && c.Status == kapi.ConditionTrue {
return false, fmt.Errorf("failed condition: %s", c.Message)
err = cli.AsAdmin().Run("new-app").Args(fixture, "-p", "NAMESPACE="+cli.Namespace()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

// wait for templateinstance controller to do its thing
err = wait.Poll(time.Second, time.Minute, func() (bool, error) {
templateinstance, err := cli.TemplateClient().Template().TemplateInstances(cli.Namespace()).Get(instanceID, metav1.GetOptions{})
if err != nil {
return false, err
}
if c.Reason == "Created" && c.Status == kapi.ConditionTrue {
return true, nil

for _, c := range templateinstance.Status.Conditions {
if c.Reason == "Failed" && c.Status == kapi.ConditionTrue {
return false, fmt.Errorf("failed condition: %s", c.Message)
}
if c.Reason == "Created" && c.Status == kapi.ConditionTrue {
return true, nil
}
}
}

return false, nil
return false, nil
})
o.Expect(err).NotTo(o.HaveOccurred())
})
o.Expect(err).NotTo(o.HaveOccurred())
})

g.AfterEach(func() {
err := cli.AdminAuthorizationClient().Authorization().ClusterRoleBindings().Delete(clusterrolebinding.Name, nil)
o.Expect(err).NotTo(o.HaveOccurred())

err = cli.AdminTemplateClient().Template().BrokerTemplateInstances().Delete(instanceID, &metav1.DeleteOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
g.AfterEach(func() {
if g.CurrentGinkgoTestDescription().Failed {
exutil.DumpPodStates(tsbOC)
exutil.DumpPodLogsStartingWith("", tsbOC)
}

err = portForwardCmdClose()
o.Expect(err).NotTo(o.HaveOccurred())
})
err := cli.AdminAuthorizationClient().Authorization().ClusterRoleBindings().Delete(clusterrolebinding.Name, nil)
o.Expect(err).NotTo(o.HaveOccurred())

g.It("should pass bind tests", func() {
svc, err := cli.KubeClient().Core().Services(cli.Namespace()).Get("service", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
err = cli.AdminTemplateClient().Template().BrokerTemplateInstances().Delete(instanceID, &metav1.DeleteOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

bind, err := brokercli.Bind(context.Background(), cliUser, instanceID, bindingID, &api.BindRequest{
ServiceID: serviceID,
PlanID: uuid.NewRandom().String(),
err = portForwardCmdClose()
o.Expect(err).NotTo(o.HaveOccurred())
})
o.Expect(err).NotTo(o.HaveOccurred())

o.Expect(bind.Credentials).To(o.HaveKeyWithValue("configmap-username", "configmap-username"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("secret-username", "secret-username"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("secret-password", "c2VjcmV0LXBhc3N3b3Jk"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("service-uri", "http://"+svc.Spec.ClusterIP+":1234"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("route-uri", "http://host/path"))
g.It("should pass bind tests", func() {
svc, err := cli.KubeClient().Core().Services(cli.Namespace()).Get("service", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

bind, err := brokercli.Bind(context.Background(), cliUser, instanceID, bindingID, &api.BindRequest{
ServiceID: serviceID,
PlanID: uuid.NewRandom().String(),
})
o.Expect(err).NotTo(o.HaveOccurred())

o.Expect(bind.Credentials).To(o.HaveKeyWithValue("configmap-username", "configmap-username"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("secret-username", "secret-username"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("secret-password", "c2VjcmV0LXBhc3N3b3Jk"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("service-uri", "http://"+svc.Spec.ClusterIP+":1234"))
o.Expect(bind.Credentials).To(o.HaveKeyWithValue("route-uri", "http://host/path"))
})
})
})
4 changes: 2 additions & 2 deletions test/extended/testdata/bindata.go

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

0 comments on commit 9776370

Please sign in to comment.