Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Service binding

The service-binding trait populates environment variables with information extracted from Kubernetes secrets. These secrets can be created using the storage trait, by using a k8s-object component to render the secret, or directly with creating the Secret kubernetes entities with kubectl or with a deploy operation.

The following snippet describes an application with a component that populates environemnt variables from an existing secret.


apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: my-app
spec:
  components:
    - name: mysql
        type: worker
        properties:
        image: my-app-image:v1.0.0 
        traits:
        - type: service-binding # Set to service-binding
          properties:
            envMappings:
              ENV_1: # environment variable
                 secret: secret-name # secret name
                 key: key1  #key
              ENV_2: # environment variable
                 secret: secret-name # secret name
                 key: key2  #key