This document defines an extension to the Service Binding Specification for Kubernetes ("Service Binding spec" for short henceforth). This extension specifies generating a Kubernetes Secret resource that can be consumed by any Service Binding spec compliant implementation. The Secret resource is generated from one of these sources:
- Operator Lifecycle Manager Descriptors
- Custom Resource Definition Annotations
- Custom Resource Annotations
This document is a pre-release, working draft of the Secret Generation extension for Service Binding, representing the collective efforts of the community. It is published for early implementors and users to provide feedback. Any part of this document may change before the extension reaches 1.0 with no promise of backwards compatibility.
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
.
To handle the majority of existing resources and CRDs, Secret
generation needs to support the following behaviors:
- Extract a string from a resource
- Extract an entire
ConfigMap
/Secret
refrenced from a resource - Extract a specific entry in a
ConfigMap
/Secret
referenced from a resource - Extract entries from a collection of objects, mapping keys and values from entries in a
ConfigMap
/Secret
referenced from a resource - Exctact a collection of specific entry values in a resource's collection of objects
- Map each value to a specific key
- Map each value of a collection to a key with generated name
While the syntax of the generation strategies are specific to the system they are annotating, they are based on a common data model.
Model | Description |
---|---|
path |
A template represention of the path to an element in a Kubernetes resource. The value of path is specified as JSONPath. Required. |
objectType |
Specifies the type of the object selected by the path . One of ConfigMap , Secret , or string (default). |
elementType |
Specifies the type of object in an array selected by the path . One of sliceOfMaps , sliceOfStrings , string (default). |
sourceKey |
Specifies a particular key to select if a ConfigMap or Secret is selected by the path . Specifies a value to use for the key for an entry in a binding Secret when elementType is sliceOfMaps . |
sourceValue |
Specifies a particular value to use for the value for an entry in a binding Secret when elementType is sliceOfMaps or sliceOfStrings . |
OLM Operators are configured by setting the specDescriptor
and statusDescriptor
entries in the ClusterServiceVersion with mapping descriptors.
The following examples refer to this resource definition.
apiVersion: apps.kube.io/v1beta1
kind: Database
metadata:
name: my-cluster
spec:
tags:
- Brno
- PWR
- stage
...
status:
bootstrap:
- type: plain
url: myhost2.example.com
name: hostGroup1
- type: tls
url: myhost1.example.com:9092,myhost2.example.com:9092
name: hostGroup2
data:
dbConfiguration: database-config # ConfigMap
dbCredentials: database-cred-Secret # Secret
url: db.stage.ibm.com
-
Mount an entire
Secret
as the bindingSecret
- path: data.dbCredentials x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - service.binding
-
Mount an entire
ConfigMap
as the bindingSecret
- path: data.dbConfiguration x-descriptors: - urn:alm:descriptor:io.kubernetes:ConfigMap - service.binding
-
Mount an entry from a
ConfigMap
into the bindingSecret
- path: data.dbConfiguration x-descriptors: - urn:alm:descriptor:io.kubernetes:ConfigMap - service.binding:certificate:sourceKey=certificate
-
Mount an entry from a
ConfigMap
into the bindingSecret
with a different key- path: data.dbConfiguration x-descriptors: - urn:alm:descriptor:io.kubernetes:ConfigMap - service.binding:timeout:sourceKey=db_timeout
-
Mount a resource definition value into the binding
Secret
- path: data.uri x-descriptors: - service.binding:uri
-
Mount a resource definition value into the binding
Secret
with a different key- path: data.connectionURL x-descriptors: - service.binding:uri
-
Mount the entries of a collection into the binding
Secret
selecting the key and value from each entry- path: bootstrap x-descriptors: - service.binding:endpoints:elementType=sliceOfMaps:sourceKey=type:sourceValue=url
-
Mount the items of a collection into the binding
Secret
with one key per item- path: spec.tags x-descriptors: - service.binding:tags:elementType=sliceOfStrings
-
Mount the values of collection entries into the binding
Secret
with one key per entry value- path: bootstrap x-descriptors: - service.binding:endpoints:elementType=sliceOfStrings:sourceValue=url
Non-OLM Operators are configured by adding annotations to the Operator's CRD with mapping configuration. All Kubernetes resources are configured by adding annotations to the resource.
The following examples refer to this resource definition.
apiVersion: apps.kube.io/v1beta1
kind: Database
metadata:
name: my-cluster
spec:
tags:
- Brno
- PWR
- stage
...
status:
bootstrap:
- type: plain
url: myhost2.example.com
name: hostGroup1
- type: tls
url: myhost1.example.com:9092,myhost2.example.com:9092
name: hostGroup2
data:
dbConfiguration: database-config # ConfigMap
dbCredentials: database-cred-Secret # Secret
url: db.stage.ibm.com
- Mount an entire
Secret
as the bindingSecret
“service.binding": ”path={.status.data.dbCredentials},objectType=Secret”
- Mount an entire
ConfigMap
as the bindingSecret
service.binding”: "path={.status.data.dbConfiguration},objectType=ConfigMap”
- Mount an entry from a
ConfigMap
into the bindingSecret
“service.binding/certificate”: "path={.status.data.dbConfiguration},objectType=ConfigMap,sourceKey=certificate"
- Mount an entry from a
ConfigMap
into the bindingSecret
with a different key“service.binding/timeout”: “path={.status.data.dbConfiguration},objectType=ConfigMap,sourceKey=db_timeout”
- Mount a resource definition value into the binding
Secret
“service.binding/uri”: "path={.status.data.url}"
- Mount a resource definition value into the binding
Secret
with a different key“service.binding/uri": "path={.status.data.connectionURL}”
- Mount the entries of a collection into the binding
Secret
selecting the key and value from each entry“service.binding/endpoints”: "path={.status.bootstrap},elementType=sliceOfMaps,sourceKey=type,sourceValue=url"
- Mount the items of a collection into the binding
Secret
with one key per item"service.binding/tags": "path={.spec.tags},elementType=sliceOfStrings
- Mount the values of collection entries into the binding
Secret
with one key per entry value“service.binding/endpoints”: "path={.status.bootstrap},elementType=sliceOfStrings,sourceValue=url"