Score

Capability

Environment Variables

Define environment variables for a container. There are two ways to configure them.

  1. Via the Score file

    The Score specification supports placeholder references to the Workload metadata or Resources named in the Score file. The syntax and supported values are different in Score compared to the Platform Orchestrator, and the Platform Orchestrator will automatically convert Score references to native placeholders when deploying a Score file. Variables will be mapped into the container through a ConfigMap or Secret .

    The Platform Orchestrator supports an environment resource for accessing the shared values in the application environment:

    apiVersion: score.dev/v1b1
    metadata:
      name: example
    containers:
      main:
        image: example
        variables:
          KEY_ONE: hello-world
          KEY_TWO: ${resources.env.VALUE}
    resources:
      env:
        type: environment
    
  2. Via the Score extensions file

    Score extensions files contain Platform Orchestrator specific content allowing the workload profile or deployment options to be configured along with overrides to the resulting workloads. The Score extensions file supports the use of Score placeholder references and native placeholders when escaped with a $.

    apiVersion: humanitec.org/v1b1
    spec:
      containers:
        main:
          variables:
            KEY_THREE: $${values.VALUE}
            KEY_FOUR: goodbye
    

humanitec.score.yaml ( view on GitHub ) :

apiVersion: humanitec.org/v1b1

spec:
  containers:
    demo:
      variables:
        SOME: VARIABLE
        SHARED_VALUE: $${values.SOMETHING}

score.yaml ( view on GitHub ) :

apiVersion: score.dev/v1b1
metadata:
  name: my-workload

containers:
  demo:
    image: registry/my-image:1.0.0
    variables:
      API_KEY: "${resources.env.API_KEY}"
resources:
  env:
    # The type "environment" is available per the Score specification.
    type: environment
Top