The following examples assume existence of Secret
db-cred
:
Secret db-cred
apiVersion: v1
kind: Secret
metadata:
name: db-cred
data:
password: "foo"
username: "guest"
ConfigMap db-conf
apiVersion: v1
kind: ConfigMap
metadata:
name: db-conf
data:
timeout: 10s
database: db1
Expose constant value as the binding item
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding/type": "foo" (1)
spec:
...
1 |
exposed binding type with value foo |
Expose all secret entries as binding data
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding": "path={.status.data.dbCredentials},objectType=Secret"
spec:
...
status:
data:
dbCredentials: db-cred (1)
Expose all entries from a secret not referred by the service
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: db
annotations:
"service.binding": "path={.metadata.name}-cred,objectType=Secret" (1)
spec:
...
1 |
Secret name is constructed from {.metadata.name}-cred template that resolved to db-cred eventually.
Multiple JSONPath can be contained in the template. |
Exposing username
entry from a Secret as user
binding item
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding/user": "path={.status.data.dbCredentials},objectType=Secret,sourceKey=username"
spec:
...
status:
data:
dbCredentials: db-cred (1)
Expose all entries from ConfigMap
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding": "path={.status.data.dbConfiguration},objectType=ConfigMap"
spec:
...
status:
data:
dbConfiguration: db-conf (1)
Exposing db_timeout
entry from a ConfigMap as timeout
binding
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding/timeout": "path={.status.data.dbConfiguration},objectType=ConfigMap,sourceKey=db_timeout"
spec:
...
status:
data:
dbConfiguration: db-conf (1)
Expose status.data.connectionURL
resource value as uri
binding item
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding/uri": "path={.status.data.connectionURL}"
spec:
...
status:
data:
connectionURL: "http://guest:secret123@192.168.1.29/db"
Exposing the collection entries as the binding data by selecting the key and value from each entry
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding/uri": "path={.status.connections},elementType=sliceOfMaps,sourceKey=type,sourceValue=url"
spec:
...
status:
connections:
- type: primary (1)
url: primary.example.com
- type: secondary (2)
url: secondary.example.com
- type: '404' (3)
url: black-hole.example.com
1 |
exposed as uri_primary with value primary.example.com |
2 |
exposed as uri_secondary with value secondary.example.com |
3 |
exposed as uri_404 with value black-hole.example.com |
Exposing the collection of strings
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
annotations:
"service.binding/tags": "path={.spec.tags},elementType=sliceOfStrings"
spec:
tags:
- knowledge (1)
- is (2)
- power (3)
1 |
exposed as tags_0 with value knowledge |
2 |
exposed as tags_1 with value is |
3 |
exposed as tags_2 with value power |