Skip to content

Commit ba97b08

Browse files
committed
cluster up support for N-1 clusters
1 parent 4b6f7f5 commit ba97b08

File tree

5 files changed

+485
-71
lines changed

5 files changed

+485
-71
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
apiVersion: template.openshift.io/v1
2+
kind: Template
3+
metadata:
4+
name: template-service-broker-apiserver
5+
parameters:
6+
- name: IMAGE
7+
value: openshift/origin:latest
8+
- name: NAMESPACE
9+
value: openshift-template-service-broker
10+
- name: LOGLEVEL
11+
value: "0"
12+
- name: API_SERVER_CONFIG
13+
value: |
14+
kind: TemplateServiceBrokerConfig
15+
apiVersion: config.templateservicebroker.openshift.io/v1
16+
templateNamespaces:
17+
- openshift
18+
- name: NODE_SELECTOR
19+
value: "{}"
20+
objects:
21+
22+
# to create the tsb server
23+
- apiVersion: extensions/v1beta1
24+
kind: DaemonSet
25+
metadata:
26+
namespace: ${NAMESPACE}
27+
name: apiserver
28+
labels:
29+
apiserver: "true"
30+
spec:
31+
template:
32+
metadata:
33+
name: apiserver
34+
labels:
35+
apiserver: "true"
36+
spec:
37+
serviceAccountName: apiserver
38+
containers:
39+
- name: c
40+
image: ${IMAGE}
41+
imagePullPolicy: IfNotPresent
42+
command:
43+
- "/usr/bin/openshift"
44+
- "start"
45+
- "template-service-broker"
46+
- "--secure-port=8443"
47+
- "--audit-log-path=-"
48+
- "--tls-cert-file=/var/serving-cert/tls.crt"
49+
- "--tls-private-key-file=/var/serving-cert/tls.key"
50+
- "--loglevel=${LOGLEVEL}"
51+
- "--config=/var/apiserver-config/apiserver-config.yaml"
52+
ports:
53+
- containerPort: 8443
54+
volumeMounts:
55+
- mountPath: /var/serving-cert
56+
name: serving-cert
57+
- mountPath: /var/apiserver-config
58+
name: apiserver-config
59+
readinessProbe:
60+
httpGet:
61+
path: /healthz
62+
port: 8443
63+
scheme: HTTPS
64+
nodeSelector: "${{NODE_SELECTOR}}"
65+
volumes:
66+
- name: serving-cert
67+
secret:
68+
defaultMode: 420
69+
secretName: apiserver-serving-cert
70+
- name: apiserver-config
71+
configMap:
72+
defaultMode: 420
73+
name: apiserver-config
74+
75+
# to create the config for the TSB
76+
- apiVersion: v1
77+
kind: ConfigMap
78+
metadata:
79+
namespace: ${NAMESPACE}
80+
name: apiserver-config
81+
data:
82+
apiserver-config.yaml: ${API_SERVER_CONFIG}
83+
84+
# to be able to assign powers to the process
85+
- apiVersion: v1
86+
kind: ServiceAccount
87+
metadata:
88+
namespace: ${NAMESPACE}
89+
name: apiserver
90+
91+
# to be able to expose TSB inside the cluster
92+
- apiVersion: v1
93+
kind: Service
94+
metadata:
95+
namespace: ${NAMESPACE}
96+
name: apiserver
97+
annotations:
98+
service.alpha.openshift.io/serving-cert-secret-name: apiserver-serving-cert
99+
spec:
100+
selector:
101+
apiserver: "true"
102+
ports:
103+
- name: https
104+
port: 443
105+
targetPort: 8443
106+
107+
# This service account will be granted permission to call the TSB.
108+
# The token for this SA will be provided to the service catalog for
109+
# use when calling the TSB.
110+
- apiVersion: v1
111+
kind: ServiceAccount
112+
metadata:
113+
namespace: ${NAMESPACE}
114+
name: templateservicebroker-client
115+
116+
# This secret will be populated with a copy of the templateservicebroker-client SA's
117+
# auth token. Since this secret has a static name, it can be referenced more
118+
# easily than the auto-generated secret for the service account.
119+
- apiVersion: v1
120+
kind: Secret
121+
metadata:
122+
namespace: ${NAMESPACE}
123+
name: templateservicebroker-client
124+
annotations:
125+
kubernetes.io/service-account.name: templateservicebroker-client
126+
type: kubernetes.io/service-account-token

pkg/oc/bootstrap/bindata.go

+148
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oc/bootstrap/docker/up.go

+38-10
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,27 @@ var (
114114
"jenkins pipeline persistent": "examples/jenkins/jenkins-persistent-template.json",
115115
"sample pipeline": "examples/jenkins/pipeline/samplepipeline.yaml",
116116
}
117-
// serviceCatalogTemplateLocations are templates that will be registered in an internal namespace
118-
// when the service catalog is requested
119-
serviceCatalogTemplateLocations = map[string]string{
117+
// internalTemplateLocations are templates that will be registered in an internal namespace
118+
// when the service catalog is requested. These templates are compatible with both vN and vN-1
119+
// clusters. If they are not, they should be moved into the internalCurrent and internalPrevious maps.
120+
internalTemplateLocations = map[string]string{
120121
"service catalog": "examples/service-catalog/service-catalog.yaml",
121-
"template service broker apiserver": "install/templateservicebroker/apiserver-template.yaml",
122122
"template service broker rbac": "install/templateservicebroker/rbac-template.yaml",
123123
"template service broker registration": "install/service-catalog-broker-resources/template-service-broker-registration.yaml",
124124
}
125+
// internalCurrentTemplateLocations are templates that will be registered in an internal namespace
126+
// when the service catalog is requested. These templates are for the current version of openshift
127+
// (vN), for when the client version matches the cluster version.
128+
internalCurrentTemplateLocations = map[string]string{
129+
"template service broker apiserver": "install/templateservicebroker/apiserver-template.yaml",
130+
}
131+
// internalPreviousTemplateLocations are templates that will be registered in an internal namespace
132+
// when the service catalog is requested, these templates are for the previous version of openshift
133+
// (vN-1) to provide N-1 support for older clusters from a newer client.
134+
internalPreviousTemplateLocations = map[string]string{
135+
"template service broker apiserver": "install/templateservicebroker/previous/apiserver-template.yaml",
136+
}
137+
125138
// loggingTemplateLocations are templates that will be registered in an internal namespace
126139
// when logging is requested
127140
loggingTemplateLocations = map[string]string{
@@ -411,9 +424,7 @@ func (c *ClientStartConfig) Complete(f *osclientcmd.Factory, cmd *cobra.Command)
411424
c.addTask(conditionalTask("Importing templates", c.ImportTemplates, c.ShouldInitializeData))
412425

413426
// Import catalog templates
414-
c.addTask(conditionalTask("Importing service catalog templates", c.ImportServiceCatalogTemplates, func() bool {
415-
return c.ShouldInstallServiceCatalog && c.ShouldInitializeData()
416-
}))
427+
c.addTask(conditionalTask("Importing internal catalog templates", c.ImportInternalTemplates, c.ShouldInitializeData))
417428

418429
// Import logging templates
419430
c.addTask(conditionalTask("Importing logging templates", c.ImportLoggingTemplates, func() bool {
@@ -989,11 +1000,24 @@ func (c *ClientStartConfig) ImportTemplates(out io.Writer) error {
9891000
return nil
9901001
}
9911002

992-
// ImportServiceCatalogTemplates imports service catalog templates into the server
993-
func (c *ClientStartConfig) ImportServiceCatalogTemplates(out io.Writer) error {
994-
if err := c.importObjects(out, openshift.OpenshiftInfraNamespace, serviceCatalogTemplateLocations); err != nil {
1003+
// ImportInternalTemplates imports internal system templates into the server
1004+
func (c *ClientStartConfig) ImportInternalTemplates(out io.Writer) error {
1005+
if err := c.importObjects(out, openshift.OpenshiftInfraNamespace, internalTemplateLocations); err != nil {
1006+
return err
1007+
}
1008+
version, err := c.OpenShiftHelper().ServerVersion()
1009+
if err != nil {
9951010
return err
9961011
}
1012+
if shouldImportCurrentTemplates(version) {
1013+
if err := c.importObjects(out, openshift.OpenshiftInfraNamespace, internalCurrentTemplateLocations); err != nil {
1014+
return err
1015+
}
1016+
} else {
1017+
if err := c.importObjects(out, openshift.OpenshiftInfraNamespace, internalPreviousTemplateLocations); err != nil {
1018+
return err
1019+
}
1020+
}
9971021
return nil
9981022
}
9991023

@@ -1009,6 +1033,10 @@ func shouldImportAdminTemplates(v semver.Version) bool {
10091033
return v.GTE(openshiftVersion36)
10101034
}
10111035

1036+
func shouldImportCurrentTemplates(v semver.Version) bool {
1037+
return v.GT(openshiftVersion37)
1038+
}
1039+
10121040
func useAnsible(v semver.Version) bool {
10131041
return v.GTE(openshiftVersion36)
10141042
}

0 commit comments

Comments
 (0)