Skip to content

Commit c6c1f25

Browse files
authored
Merge pull request #74 from k8s-service-bindings/reconcileDuties
Ability to split reconciler duties Signed-off-by: Ben Hale <[email protected]>
2 parents a512818 + b78f549 commit c6c1f25

File tree

1 file changed

+102
-2
lines changed

1 file changed

+102
-2
lines changed

README.md

+102-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ The pattern of Service Binding has prior art in non-Kubernetes platforms. Herok
3535
- [Mappings Example Resource](#mappings-example-resource)
3636
- [Environment Variables Example Resource](#environment-variables-example-resource)
3737
- [Reconciler Implementation](#reconciler-implementation)
38+
- [Ready Condition Status](#ready-condition-status)
3839
- [Extensions](#extensions)
40+
- [Custom Projection](#custom-projection)
41+
- [Requesting Custom Projection Example Resource](#requesting-custom-projection-example-resource)
42+
- [Custom Projection Definition](#custom-projection-definition)
43+
- [Generated Custom Projection Example Resource](#generated-custom-projection-example-resource)
3944
- [Binding `Secret` Generation Strategies](#binding-secret-generation-strategies)
4045
- [OLM Operator Descriptors](#olm-operator-descriptors)
4146
- [Descriptor Examples](#descriptor-examples)
@@ -175,7 +180,7 @@ A Service Binding Resource **MAY** define a `.spec.mappings` which is an array o
175180

176181
A Service Binding Resource **MAY** define a `.spec.env` which is an array of `EnvVar`. An `EnvVar` object **MUST** define `name` and `key` entries. The `key` of an `EnvVar` **MUST** refer to a binding `Secret` key name including any key defined by a `Mapping`. The value of this `Secret` entry **MUST** be configured as an environment variable on the resource represented by `application`.
177182

178-
A Service Binding resource **MUST** define a `.status.conditions` which is an array of `Condition` objects. A `Condition` object **MUST** define `type`, `status`, and `lastTransitionTime` entries. At least one condition containing a `type` of `Ready` **MUST** be defined. The `status` of the `Ready` condition **MUST** have a value of `True`, `False`, or `Unknown`. The `lastTransitionTime` **MUST** contain the last time that the condition transitioned from one status to another. A Service Binding resource **MAY** define `reason` and `message` entries to describe the last `status` transition. As label selectors are inherently queries that return zero-to-many resources, it is **RECOMMENDED** that `ServiceBinding` authors use a combination of labels that yield a single resource, but implementors **MUST** handle each matching resource as if it was specified by name in a distinct `ServiceBinding` resource. Partial failures **MUST** be aggregated and reported on the binding status's `Ready` condition. A Service Binding resource **MAY** reflect the secret projected into the application as `.status.binding.name`.
183+
A Service Binding resource **MUST** define a `.status.conditions` which is an array of `Condition` objects. A `Condition` object **MUST** define `type`, `status`, and `lastTransitionTime` entries. At least one condition containing a `type` of `Ready` **MUST** be defined. The `status` of the `Ready` condition **MUST** have a value of `True`, `False`, or `Unknown`. The `lastTransitionTime` **MUST** contain the last time that the condition transitioned from one status to another. A Service Binding resource **MAY** define `reason` and `message` entries to describe the last `status` transition. As label selectors are inherently queries that return zero-to-many resources, it is **RECOMMENDED** that `ServiceBinding` authors use a combination of labels that yield a single resource, but implementors **MUST** handle each matching resource as if it was specified by name in a distinct `ServiceBinding` resource. Partial failures **MUST** be aggregated and reported on the binding status's `Ready` condition. A Service Binding resource **SHOULD** reflect the secret projected into the application as `.status.binding.name`.
179184

180185
[crd]: service.binding_servicebindings.yaml
181186
[ls]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
@@ -352,7 +357,7 @@ status:
352357
353358
## Reconciler Implementation
354359
355-
A Reconciler implementation for the `ServiceBinding` type is responsible for binding the Provisioned Service binding `Secret` into an Application. The `Secret` referred to by `.status.binding.name` on the resource represented by `service` **MUST** be mounted as a volume on the resource represented by `application`. If the `application` resource is managed by another Reconciler, a `ServiceBinding` Implementations **SHOULD** ensure that the `Secret` volume mount configuration remains after the other Reconciler completes.
360+
A Reconciler implementation for the `ServiceBinding` type is responsible for binding the Provisioned Service binding `Secret` into an Application. The `Secret` referred to by `.status.binding.name` on the resource represented by `service` **MUST** be mounted as a volume on the resource represented by `application`.
356361

357362
If a `.spec.name` is set, the directory name of the volume mount **MUST** be its value. If a `.spec.name` is not set, the directory name of the volume mount **SHOULD** be the value of `.metadata.name`.
358363

@@ -362,12 +367,107 @@ The `$SERVICE_BINDING_ROOT` environment variable **MUST NOT** be reset if it is
362367

363368
If a `.spec.type` is set, the `type` entry in the binding `Secret` **MUST** be set to its value overriding any existing value. If a `.spec.provider` is set, the `provider` entry in the binding `Secret` **MUST** be set to its value overriding any existing value.
364369

370+
### Ready Condition Status
371+
365372
If the modification of the Application resource is completed successfully, the `Ready` condition status **MUST** be set to `True`. If the modification of the Application resource is not completed successfully the `Ready` condition status **MUST NOT** be set to `True`.
366373

367374
# Extensions
368375

369376
Extensions are optional additions to the core specification as defined above. Implementation and support of these specifications are not required in order for a platform to be considered compliant. However, if the features addressed by these specifications are supported a platform **MUST** be in compliance with the specification that governs that feature.
370377

378+
## Custom Projection
379+
380+
There are scenarios where the Reconciler that processes a `ServiceBinding` (hereinafter referred to as `Reconciler A`) is different than the Reconciler that will project the binding into the Application (hereinafter referred to as `Reconciler B`). To transfer the projection responsibility from Reconciler A to Reconciler B the `ServiceBinding` CR author **MUST** set the `projection.service.binding/type` annotation to `Custom`.
381+
382+
Reconciler A reacts to this annotation by creating a new `ServiceBindingProjection` CR which includes the necessary information for Reconciler B, who is watching and takes responsibility for the new `ServiceBindingProjection` resource (see the [Custom Projection Definition](#custom-projection-definition) section below), to carry out the projection. Reconciler A is responsible for updating `ServiceBindingProjection`'s spec upon corresponding changes to `ServiceBinding`.
383+
384+
Reconciler B **MUST** set the `ServiceBindingProjection`'s `Ready` condition according to the rules set in [Ready Condition Status](#ready-condition-status), while Reconciler A **MUST** reflect `ServiceBindingProjection`'s `Ready` condition in a new `ProjectionReady` condition inside `ServiceBinding`. The `Ready` condition of `ServiceBinding` **MUST NOT** be set to `True` if its `ProjectionReady` condition is not `True`.
385+
386+
387+
### Requesting Custom Projection Example Resource
388+
389+
```yaml
390+
apiVersion: service.binding/v1alpha2
391+
kind: ServiceBinding
392+
metadata:
393+
name: account-service
394+
annotations:
395+
projection.service.binding/type: "Custom"
396+
spec:
397+
application:
398+
apiVersion: apps/v1
399+
kind: Deployment
400+
name: online-banking
401+
402+
service:
403+
apiVersion: com.example/v1alpha1
404+
kind: AccountService
405+
name: prod-account-service
406+
407+
status:
408+
binding:
409+
name: prod-account-service-projection
410+
conditions:
411+
- type: Ready
412+
status: 'True'
413+
- type: ProjectionReady
414+
status: 'True'
415+
```
416+
417+
### Custom Projection Definition
418+
419+
```yaml
420+
apiVersion: internal.service.binding/v1alpha2
421+
kind: ServiceBindingProjection
422+
metadata:
423+
name: # string
424+
generation: # int64, defined by the Kubernetes control plane
425+
...
426+
spec:
427+
name: # string
428+
binding: # LocalObjectReference
429+
application: # ObjectReference-like
430+
apiVersion: # string
431+
kind: # string
432+
name: # string, mutually exclusive with selector
433+
selector: # metav1.LabelSelector, mutually exclusive with name
434+
containers: # []intstr.IntOrString, optional
435+
436+
env: # []EnvVar, optional
437+
- name: # string
438+
key: # string
439+
440+
status:
441+
conditions: # []Condition containing at least one entry for `Ready`
442+
- type: # string
443+
status: # string
444+
lastTransitionTime: # Time
445+
reason: # string
446+
message: # string
447+
observedGeneration: # int64
448+
```
449+
450+
### Generated Custom Projection Example Resource
451+
452+
```yaml
453+
apiVersion: internal.service.binding/v1alpha2
454+
kind: ServiceBindingProjection
455+
metadata:
456+
name: account-service
457+
spec:
458+
binding: prod-account-service-projection
459+
460+
application:
461+
apiVersion: apps/v1
462+
kind: Deployment
463+
name: online-banking
464+
465+
status:
466+
conditions:
467+
- type: Ready
468+
status: 'True'
469+
```
470+
371471
## Binding `Secret` Generation Strategies
372472

373473
Many services, especially initially, will not be Provisioned Service-compliant. These services will expose the appropriate binding `Secret` information, but not in the way that the specification or applications expect. Users should have a way of describing a mapping from existing data associated with arbitrary resources and CRDs to a representation of a binding `Secret`.

0 commit comments

Comments
 (0)