Skip to content

Commit 7484c0d

Browse files
committed
Break Provisioning into Steps
Allows service instances to be broken down into steps, allowing once service to be provisioned, waited for it to start, before provisioning the next. Implements #72
1 parent 23484a7 commit 7484c0d

File tree

8 files changed

+417
-71
lines changed

8 files changed

+417
-71
lines changed

crds/servicebroker.couchbase.com_servicebrokerconfigs.yaml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ spec:
144144
description: Name is a unique name for the readiness
145145
check for debugging purposes.
146146
type: string
147+
timeout:
148+
default: 1m
149+
description: Timeout is the timeout durations for
150+
this check.
151+
type: string
147152
required:
148153
- name
149154
type: object
@@ -175,9 +180,108 @@ spec:
175180
x-kubernetes-list-map-keys:
176181
- name
177182
x-kubernetes-list-type: map
183+
steps:
184+
description: Steps allows a service instance or binding
185+
deployment to be split into steps. A steps will block
186+
until the readiness check, if defined, passes, before
187+
continuing on to the next one. Steps cannot be used at
188+
the same time as templates and readiness checks.
189+
items:
190+
description: ServiceBrokerTemplateListStep allows a service
191+
instance to be provisioned in steps blocking until a
192+
readiness check has completed before moving on to the
193+
next one.
194+
properties:
195+
name:
196+
description: Name of the step for logging and debugging
197+
purposes.
198+
type: string
199+
readinessChecks:
200+
description: ReadinessChecks defines a set of tests
201+
that define whether a step is complete. These checks
202+
have no affect on the aysnchronous polling at the
203+
service broker API level, as such it's common to
204+
define these between steps only, and have a top
205+
level readiness check for service availability.
206+
items:
207+
description: ConfigurationReadinessCheck is a readiness
208+
check to perform on a service instance or binding
209+
before declaring it ready and provisioning has
210+
completed.
211+
properties:
212+
condition:
213+
description: Condition allows the service broker
214+
to poll well-formed status conditions in order
215+
to determine whether a specific resource is
216+
ready.
217+
properties:
218+
apiVersion:
219+
description: APIVersion is the resource
220+
api version e.g. "apps/v1"
221+
type: string
222+
kind:
223+
description: Kind is the resource kind to
224+
poll e.g. "Deployment"
225+
type: string
226+
name:
227+
description: Name is the resource name to
228+
poll.
229+
type: string
230+
namespace:
231+
description: Namespace is the namespace
232+
the resource resides in.
233+
type: string
234+
status:
235+
description: Status is the status of the
236+
condition that must match e.g. "True"
237+
type: string
238+
type:
239+
description: Type is the type of the condition
240+
to look for e.g. "Available"
241+
type: string
242+
required:
243+
- apiVersion
244+
- kind
245+
- name
246+
- namespace
247+
- status
248+
- type
249+
type: object
250+
name:
251+
description: Name is a unique name for the readiness
252+
check for debugging purposes.
253+
type: string
254+
timeout:
255+
default: 1m
256+
description: Timeout is the timeout durations
257+
for this check.
258+
type: string
259+
required:
260+
- name
261+
type: object
262+
type: array
263+
x-kubernetes-list-map-keys:
264+
- name
265+
x-kubernetes-list-type: map
266+
templates:
267+
description: Templates defines all the templates that
268+
will be created, in order, by the service broker
269+
for this operation.
270+
items:
271+
type: string
272+
type: array
273+
x-kubernetes-list-type: set
274+
required:
275+
- name
276+
type: object
277+
type: array
278+
x-kubernetes-list-map-keys:
279+
- name
280+
x-kubernetes-list-type: map
178281
templates:
179282
description: Templates defines all the templates that will
180283
be created, in order, by the service broker for this operation.
284+
This field is deprecated, use steps instead.
181285
items:
182286
type: string
183287
type: array
@@ -237,6 +341,11 @@ spec:
237341
description: Name is a unique name for the readiness
238342
check for debugging purposes.
239343
type: string
344+
timeout:
345+
default: 1m
346+
description: Timeout is the timeout durations for
347+
this check.
348+
type: string
240349
required:
241350
- name
242351
type: object
@@ -268,9 +377,108 @@ spec:
268377
x-kubernetes-list-map-keys:
269378
- name
270379
x-kubernetes-list-type: map
380+
steps:
381+
description: Steps allows a service instance or binding
382+
deployment to be split into steps. A steps will block
383+
until the readiness check, if defined, passes, before
384+
continuing on to the next one. Steps cannot be used at
385+
the same time as templates and readiness checks.
386+
items:
387+
description: ServiceBrokerTemplateListStep allows a service
388+
instance to be provisioned in steps blocking until a
389+
readiness check has completed before moving on to the
390+
next one.
391+
properties:
392+
name:
393+
description: Name of the step for logging and debugging
394+
purposes.
395+
type: string
396+
readinessChecks:
397+
description: ReadinessChecks defines a set of tests
398+
that define whether a step is complete. These checks
399+
have no affect on the aysnchronous polling at the
400+
service broker API level, as such it's common to
401+
define these between steps only, and have a top
402+
level readiness check for service availability.
403+
items:
404+
description: ConfigurationReadinessCheck is a readiness
405+
check to perform on a service instance or binding
406+
before declaring it ready and provisioning has
407+
completed.
408+
properties:
409+
condition:
410+
description: Condition allows the service broker
411+
to poll well-formed status conditions in order
412+
to determine whether a specific resource is
413+
ready.
414+
properties:
415+
apiVersion:
416+
description: APIVersion is the resource
417+
api version e.g. "apps/v1"
418+
type: string
419+
kind:
420+
description: Kind is the resource kind to
421+
poll e.g. "Deployment"
422+
type: string
423+
name:
424+
description: Name is the resource name to
425+
poll.
426+
type: string
427+
namespace:
428+
description: Namespace is the namespace
429+
the resource resides in.
430+
type: string
431+
status:
432+
description: Status is the status of the
433+
condition that must match e.g. "True"
434+
type: string
435+
type:
436+
description: Type is the type of the condition
437+
to look for e.g. "Available"
438+
type: string
439+
required:
440+
- apiVersion
441+
- kind
442+
- name
443+
- namespace
444+
- status
445+
- type
446+
type: object
447+
name:
448+
description: Name is a unique name for the readiness
449+
check for debugging purposes.
450+
type: string
451+
timeout:
452+
default: 1m
453+
description: Timeout is the timeout durations
454+
for this check.
455+
type: string
456+
required:
457+
- name
458+
type: object
459+
type: array
460+
x-kubernetes-list-map-keys:
461+
- name
462+
x-kubernetes-list-type: map
463+
templates:
464+
description: Templates defines all the templates that
465+
will be created, in order, by the service broker
466+
for this operation.
467+
items:
468+
type: string
469+
type: array
470+
x-kubernetes-list-type: set
471+
required:
472+
- name
473+
type: object
474+
type: array
475+
x-kubernetes-list-map-keys:
476+
- name
477+
x-kubernetes-list-type: map
271478
templates:
272479
description: Templates defines all the templates that will
273480
be created, in order, by the service broker for this operation.
481+
This field is deprecated, use steps instead.
274482
items:
275483
type: string
276484
type: array

documentation/modules/ROOT/pages/concepts/bindings.adoc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ Unsurprisingly, given a service plan name is unique within its parent service of
2525
Configuration bindings use this unique identifier to map from a service plan to a configuration binding.
2626
This is a one-to-one mapping and every plan must have a binding.
2727

28-
=== Templates
29-
30-
Configuration bindings can be thought of as lists of Kubernetes resources.
31-
In our example this would be a `ServiceAccount`, `Role` and all the other resources required to create our service instance in Kubernetes.
32-
33-
In reality, the resources the binding refers to are all templates--a base Kubernetes resource that can be modified dynamically based on request parameters.
34-
Templates are covered in more detail in the next section.
35-
3628
=== Registry Definitions
3729

3830
Configuration bindings may also contain lists of registry definitions.
@@ -41,7 +33,15 @@ These are simple functions--based on Go language templates--that accept inputs f
4133
These are covered in more detail in a xref:concepts/dynamic-attributes.adoc[later section], however we will mention that registry entries defined in the configuration binding may be used to generate values that can used as inputs to template rending later.
4234
Such values can be shared resource names, passwords and even TLS configuration.
4335

44-
=== Readiness Checks
36+
=== Steps
37+
38+
When provisioning a service instance, it's possible that you may be provisioning a logical set of services.
39+
For this reason provisioning is divided into steps.
40+
41+
Each step contains templates that represent a logical service, and a set of readiness gates.
42+
Readiness checks act as blocking barriers between steps, so you can ensure one service is running, before starting a dependent service.
43+
44+
==== Readiness Checks
4545

4646
The Service Broker, in simple terms, creates Kubernetes resources.
4747
This operation is almost instantaneous, however, Kubernetes is an eventually-consistent system.
@@ -52,6 +52,14 @@ These allow you to poll resources created as part of a service instance for actu
5252
For example a Kubernetes `Deployment` will report as available only when all of its pods are ready.
5353
Readiness checks allow the Service Broker API to declare a service instance creation as successful only when its underlying resources are available to be consumed by a client.
5454

55+
==== Templates
56+
57+
Configuration bindings can be thought of as lists of Kubernetes resources.
58+
In our example this would be a `ServiceAccount`, `Role` and all the other resources required to create our service instance in Kubernetes.
59+
60+
In reality, the resources the binding refers to are all templates--a base Kubernetes resource that can be modified dynamically based on request parameters.
61+
Templates are covered in more detail in the next section.
62+
5563
=== Processing Rules
5664

5765
Service instances and service bindings have their own separate lists of templates and parameters for each service plan.

examples/configurations/couchbase-server/broker.yaml

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -463,24 +463,41 @@ spec:
463463
value: '{{ generatePrivateKey "RSA" "PKCS#1" 2048 }}'
464464
- name: server-cert
465465
value: '{{ generateCertificate (registry "server-key") "Couchbase Server" "87600h" "Server" (list (printf "DNS:%s-srv" (registry "instance-name")) (printf "DNS:%s-srv.%s" (registry "instance-name") (registry "namespace")) (printf "DNS:%s-srv.%s.svc" (registry "instance-name") (registry "namespace")) (printf "DNS:*.%s-srv.%s.svc.cluster.local" (registry "instance-name") (registry "namespace")) (printf "DNS:*.%s" (registry "instance-name")) (printf "DNS:*.%s.%s" (registry "instance-name") (registry "namespace")) (printf "DNS:*.%s.%s.svc" (registry "instance-name") (registry "namespace")) (printf "DNS:*.%s.%s.svc.cluster.local" (registry "instance-name") (registry "namespace")) "DNS:localhost") (registry "ca-key") (registry "ca-cert") }}'
466-
templates:
467-
- couchbase-operator-serviceaccount
468-
- couchbase-operator-role
469-
- couchbase-operator-rolebinding
470-
- couchbase-operator-deployment
471-
- couchbase-admin-secret
472-
- couchbase-operator-tls-secret
473-
- couchbase-server-tls-secret
474-
- couchbase-developer-private
475-
readinessChecks:
476-
- name: couchbase-cluster-available
477-
condition:
478-
apiVersion: couchbase.com/v2
479-
kind: CouchbaseCluster
480-
namespace: '{{ registry "namespace" }}'
481-
name: '{{ registry "instance-name" }}'
482-
type: Available
483-
status: "True"
466+
steps:
467+
- name: couchbase-operator
468+
templates:
469+
- couchbase-operator-serviceaccount
470+
- couchbase-operator-role
471+
- couchbase-operator-rolebinding
472+
- couchbase-operator-deployment
473+
# Readiness checks act as a barrier between one step and the next
474+
# and acts as a fail fast trigger.
475+
readinessChecks:
476+
- name: couchbase-operator-available
477+
timeout: 1m
478+
condition:
479+
apiVersion: apps/v1
480+
kind: Deployment
481+
namespace: '{{ registry "namespace" }}'
482+
name: couchbase-operator
483+
type: Available
484+
status: "True"
485+
- name: couchbase-cluster
486+
templates:
487+
- couchbase-admin-secret
488+
- couchbase-operator-tls-secret
489+
- couchbase-server-tls-secret
490+
- couchbase-developer-private
491+
readinessChecks:
492+
- name: couchbase-cluster-available
493+
timeout: 5m
494+
condition:
495+
apiVersion: couchbase.com/v2
496+
kind: CouchbaseCluster
497+
namespace: '{{ registry "namespace" }}'
498+
name: '{{ registry "instance-name" }}'
499+
type: Available
500+
status: "True"
484501
serviceBinding:
485502
registry:
486503
- name: binding-name

0 commit comments

Comments
 (0)