Skip to content

Commit 2015896

Browse files
Merge pull request #15993 from deads2k/tsb-22-install
Automatic merge from submit-queue move the TSB templates to an install location @ewolinetz @sdodson this separates the templates into 1. apiserver config yaml for substitution by ansible 2. rbac-template to be reconciled 3. apiserver-template to accept the substituted apiserver config.yaml and be oc applied @bparees @jim-minter This is splitting up pieces for ansible to consume @stevekuznetsov Let's say I had this new requirement to synchronize the `install` folder from origin into a directory of @sdodson's choosing in openshift-ansible on every origin merge that changed a file in `install`? This would let ownership of the file be clearly in origin by the developer working on it and @sdodson mentioned a way to actually use these origin files to drive the ansible install in CI, so that we get a matched set.
2 parents 240a531 + bff7e34 commit 2015896

File tree

9 files changed

+185
-93
lines changed

9 files changed

+185
-93
lines changed

hack/update-generated-bindata.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pushd "${OS_ROOT}" > /dev/null
3232
examples/heapster/... \
3333
examples/prometheus/... \
3434
examples/service-catalog/... \
35-
examples/templateservicebroker/... \
35+
install/... \
3636
pkg/image/admission/imagepolicy/api/v1/...
3737

3838
"$(os::util::find::gopath_binary go-bindata)" \
@@ -54,12 +54,12 @@ pushd "${OS_ROOT}" > /dev/null
5454
examples/hello-openshift \
5555
examples/jenkins/... \
5656
examples/quickstarts/cakephp-mysql.json \
57-
examples/templateservicebroker/...
57+
install/...
5858

5959
popd > /dev/null
6060

6161
# If you hit this, please reduce other tests instead of importing more
62-
if [[ "$( cat "${OUTPUT_PARENT}/test/extended/testdata/bindata.go" | wc -c )" -gt 950000 ]]; then
62+
if [[ "$( cat "${OUTPUT_PARENT}/test/extended/testdata/bindata.go" | wc -c )" -gt 1500000 ]]; then
6363
echo "error: extended bindata is $( cat "${OUTPUT_PARENT}/test/extended/testdata/bindata.go" | wc -c ) bytes, reduce the size of the import" 1>&2
6464
exit 1
6565
fi
File renamed without changes.

examples/templateservicebroker/templateservicebroker-template.yaml renamed to install/templateservicebroker/apiserver-template.yaml

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
apiVersion: template.openshift.io/v1
22
kind: Template
33
metadata:
4-
name: template-service-broker
4+
name: template-service-broker-apiserver
55
parameters:
66
- name: IMAGE
77
value: openshift/origin:latest
88
- name: NAMESPACE
99
value: openshift-template-service-broker
10-
- name: KUBE_SYSTEM
11-
value: kube-system
1210
- name: LOGLEVEL
1311
value: "0"
1412
- name: API_SERVER_CONFIG
@@ -100,41 +98,3 @@ objects:
10098
ports:
10199
- port: 443
102100
targetPort: 8443
103-
104-
# to delegate authentication and authorization
105-
- apiVersion: authorization.openshift.io/v1
106-
kind: ClusterRoleBinding
107-
metadata:
108-
name: auth-delegator-${NAMESPACE}
109-
roleRef:
110-
name: system:auth-delegator
111-
subjects:
112-
- kind: ServiceAccount
113-
namespace: ${NAMESPACE}
114-
name: apiserver
115-
116-
# to have the template service broker powers
117-
- apiVersion: authorization.openshift.io/v1
118-
kind: ClusterRoleBinding
119-
metadata:
120-
name: tsb-${NAMESPACE}
121-
roleRef:
122-
name: system:openshift:controller:template-service-broker
123-
subjects:
124-
- kind: ServiceAccount
125-
namespace: ${NAMESPACE}
126-
name: apiserver
127-
128-
# to read the config for terminating authentication
129-
- apiVersion: authorization.openshift.io/v1
130-
kind: RoleBinding
131-
metadata:
132-
namespace: ${KUBE_SYSTEM}
133-
name: extension-apiserver-authentication-reader-${NAMESPACE}
134-
roleRef:
135-
namespace: kube-system
136-
name: extension-apiserver-authentication-reader
137-
subjects:
138-
- kind: ServiceAccount
139-
namespace: ${NAMESPACE}
140-
name: apiserver
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
apiVersion: template.openshift.io/v1
2+
kind: Template
3+
metadata:
4+
name: template-service-broker-rbac
5+
parameters:
6+
- name: NAMESPACE
7+
value: openshift-template-service-broker
8+
- name: KUBE_SYSTEM
9+
value: kube-system
10+
objects:
11+
12+
# to delegate authentication and authorization
13+
- apiVersion: authorization.openshift.io/v1
14+
kind: ClusterRoleBinding
15+
metadata:
16+
name: auth-delegator-${NAMESPACE}
17+
roleRef:
18+
name: system:auth-delegator
19+
subjects:
20+
- kind: ServiceAccount
21+
namespace: ${NAMESPACE}
22+
name: apiserver
23+
24+
# to have the template service broker powers
25+
- apiVersion: authorization.openshift.io/v1
26+
kind: ClusterRoleBinding
27+
metadata:
28+
name: tsb-${NAMESPACE}
29+
roleRef:
30+
name: system:openshift:controller:template-service-broker
31+
subjects:
32+
- kind: ServiceAccount
33+
namespace: ${NAMESPACE}
34+
name: apiserver
35+
36+
# to read the config for terminating authentication
37+
- apiVersion: authorization.openshift.io/v1
38+
kind: RoleBinding
39+
metadata:
40+
namespace: ${KUBE_SYSTEM}
41+
name: extension-apiserver-authentication-reader-${NAMESPACE}
42+
roleRef:
43+
namespace: kube-system
44+
name: extension-apiserver-authentication-reader
45+
subjects:
46+
- kind: ServiceAccount
47+
namespace: ${NAMESPACE}
48+
name: apiserver

pkg/oc/bootstrap/bindata.go

Lines changed: 51 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oc/bootstrap/docker/openshift/templateservicebroker.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ import (
1717
)
1818

1919
const (
20-
tsbNamespace = "openshift-template-service-broker"
21-
tsbTemplateName = "template-service-broker"
22-
tsbTemplateLocation = "examples/templateservicebroker/templateservicebroker-template.yaml"
20+
tsbNamespace = "openshift-template-service-broker"
21+
tsbRBACTemplateName = "template-service-broker-rbac"
22+
tsbAPIServerTemplateName = "template-service-broker-apiserver"
23+
tsbRBACTemplateLocation = "install/templateservicebroker/rbac-template.yaml"
24+
tsbAPIServerTemplateLocation = "install/templateservicebroker/apiserver-template.yaml"
2325
)
2426

2527
// InstallServiceCatalog checks whether the template service broker is installed and installs it if not already installed
@@ -35,20 +37,27 @@ func (h *Helper) InstallTemplateServiceBroker(f *clientcmd.Factory, imageFormat
3537
}
3638

3739
// create the template in the tsbNamespace to make it easy to instantiate
38-
if err := ImportObjects(f, tsbNamespace, tsbTemplateLocation); err != nil {
40+
if err := ImportObjects(f, tsbNamespace, tsbRBACTemplateLocation); err != nil {
41+
return errors.NewError("cannot create template service broker permissions template").WithCause(err)
42+
}
43+
if err := ImportObjects(f, tsbNamespace, tsbAPIServerTemplateLocation); err != nil {
3944
return errors.NewError("cannot create template service broker template").WithCause(err)
4045
}
4146

47+
if err = instantiateTemplate(osClient, clientcmd.ResourceMapper(f), tsbNamespace, tsbRBACTemplateName, tsbNamespace, map[string]string{}, true); err != nil {
48+
return errors.NewError("cannot instantiate template service broker permissions").WithCause(err)
49+
}
50+
4251
// create the actual resources required
4352
imageTemplate := variable.NewDefaultImageTemplate()
4453
imageTemplate.Format = imageFormat
4554
imageTemplate.Latest = false
4655

47-
if err = instantiateTemplate(osClient, clientcmd.ResourceMapper(f), tsbNamespace, tsbTemplateName, tsbNamespace, map[string]string{
56+
if err = instantiateTemplate(osClient, clientcmd.ResourceMapper(f), tsbNamespace, tsbAPIServerTemplateName, tsbNamespace, map[string]string{
4857
"IMAGE": imageTemplate.ExpandOrDie(""),
4958
"LOGLEVEL": fmt.Sprint(serverLogLevel),
5059
}, true); err != nil {
51-
return errors.NewError("cannot instantiate logger accounts").WithCause(err)
60+
return errors.NewError("cannot instantiate template service broker resources").WithCause(err)
5261
}
5362

5463
// Wait for the apiserver endpoint to become available

test/extended/templates/helpers.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,20 @@ func setUser(cli *exutil.CLI, user *userapi.User) {
124124
// speak to it and a close method which provides the proxy. The caller must
125125
// call the close method, usually done in AfterEach
126126
func EnsureTSB(tsbOC *exutil.CLI) (osbclient.Client, func() error) {
127-
configPath := exutil.FixturePath("..", "..", "examples", "templateservicebroker", "templateservicebroker-template.yaml")
127+
{
128+
configPath := exutil.FixturePath("..", "..", "install", "templateservicebroker", "rbac-template.yaml")
129+
stdout, _, err := tsbOC.WithoutNamespace().Run("process").Args("-f", configPath, "-p", "NAMESPACE="+tsbOC.Namespace()).Outputs()
130+
if err != nil {
131+
e2e.Logf("Error processing TSB template at %s: %v \n", configPath, err)
132+
}
133+
err = tsbOC.WithoutNamespace().AsAdmin().Run("create").Args("-f", "-").InputString(stdout).Execute()
134+
if err != nil {
135+
// If template tests run in parallel this could be created twice, we don't really care.
136+
e2e.Logf("Error creating TSB resources: %v \n", err)
137+
}
138+
}
139+
140+
configPath := exutil.FixturePath("..", "..", "install", "templateservicebroker", "apiserver-template.yaml")
128141

129142
err := tsbOC.AsAdmin().Run("new-app").Args(configPath, "-p", "LOGLEVEL=4", "-p", "NAMESPACE="+tsbOC.Namespace()).Execute()
130143
o.Expect(err).NotTo(o.HaveOccurred())

0 commit comments

Comments
 (0)