cloud-operators
cloud-operators copied to clipboard
Rename binding keys
Is there a way to select a name for the keys that get returned in a binding? For example, i have an application that uses 2 separate cloudants. If that application were to use the bindings from those 2 separate cloudants as env vars, the keys would clash as they would be the exact same for both cloudant bindings.
@werne2j yes, when you specify the Bindings resources, there is an optional SecretName
field, which can help in differentiating the names.
Does that help differentiate the keys? Since both bindings because environment variables, there would be an overwrite of the url key for example? Or does it add a prefix based on the secret name?
For example..
apiVersion: ibmcloud.ibm.com/v1
kind: Binding
metadata:
name: cloudant-binding-1
spec:
serviceName: cloudant1
secretName: cloudant1
and
apiVersion: ibmcloud.ibm.com/v1
kind: Binding
metadata:
name: cloudant-binding-2
spec:
serviceName: cloudant2
secretName: cloudant2
And then in my kubernetes deployment
envFrom:
- secretRef:
name: cloudant1
- secretRef:
name: cloudant2
Since both have the same format...
{
"username": "...",
"password": "...",
"host": "...",
"port": ...,
"url": "..."
}
The keys would collide in the container as environment variables
@werne2j for your use case I think that it's best use valueFrom
for each individual env var so you avoid collisions.
- name: <Your Key name 1>
valueFrom:
secretKeyRef:
name: cloudant1
key: password
- name: <Your Key name 2>
valueFrom:
secretKeyRef:
name: cloudant2
key: password
......
Would it be a worth while addition to be able to do something like...
apiVersion: ibmcloud.ibm.com/v1
kind: Binding
metadata:
name: cloudant-binding-1
spec:
serviceName: cloudant1
secretName: cloudant1
keys:
url1: <path-to-url>
As a simplistic example