BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Score Provides a Workflow Centric Approach to Container Workload Management

Score Provides a Workflow Centric Approach to Container Workload Management

Bookmarks

Score is designed to reduce the complexity and duplication required to run workloads across multiple cloud environments. Score defines workloads in a platform-agnostic fashion via YAML. At the time of release, the Score supports three platforms: Helm, Docker Compose, and Humanitec.

Score has three core components: the Score Specification, the Score Implementation, and a platform-specific configuration file. The Score Specification is a developer-centric workload definition that describes how to run a workload. It is written in YAML and meant to be platform-agnostic. As described by Susa Tünker, technical product manager at Humanitec, it "presents the single source of truth on a workloads profile of requirements and works to utilise any container orchestration platform and tool."

The core components of Score

The core components of Score (credit: Score)

 

The Score Specification takes a workload-centric approach by holding the definition of what the workload requires to run successfully. An example workload may require a singular container connecting to a database via a TCP port. The specific details around which TCP port, how many database replicas are needed, or how to provision the database are left out of the Score definition. Those instead are the responsibility of the platform in the target environment to define.

The Score Implementation is a CLI tool which the Score Specification is executed against. It is associated with a specific platform and generates platform-specific configuration files based on the Score Specification. This platform-specific configuration file can then be combined with environment-specific parameters and run in the target environment.

The following Score file creates a simple service based on busybox:

apiVersion: score.dev/v1b1

metadata:
  name: hello-world

containers:
  hello:
    image: busybox
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo Hello World!; sleep 5; done"]

This can be translated into a Docker compose file using the run command:

score-compose run -f ./score.yaml -o ./compose.yaml
services:
  hello-world:
    command:
      - -c
      - while true; do echo Hello World!; sleep 5; done
    entrypoint:
      - /bin/sh
    image: busybox

To create a Helm file the same run command can be used with score-helm. A Humanitec Delta file can be created by calling score-humanitec run -f ./score.yaml --env test-env. In both cases, the same input Score YAML file can be used.

Score is not meant to be a configuration management tool for environments. Tünker states that "it is not recommended to store configuration values and secrets directly in score.yaml". Instead, those values should be declared as a workload dependency in the Score file. Variables can be referenced within the Score Specification file and then loaded in when the file is implemented:

apiVersion: score.dev/v1b1

metadata:
  name: service-a

containers:
  service-a:
    image: busybox
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo service-a: Hello $${FRIEND}! Connecting to ${CONNECTION_STRING}...; sleep 10; done"]
    variables:
      FRIEND: ${resources.env.NAME}
      CONNECTION_STRING: postgresql://${resources.db.user}:${resources.db.password}@${resources.db.host}:${resources.db.port}/${resources.db.name}

Assuming the necessary variables are defined in the .env file, the above Score Specification file can be converted into a Compose file by calling run:

score-compose run -f ./service-a.yaml -o ./service-a.compose.yaml --env-file ./.env

As opposed to existing tools in this space such as HashiCorp Waypoint or Kompose, Score does not provide a build or deployment workflow. Whereas Kompose will generate a Helm chart from the Docker Compose file, Score assumes that the chart is already present and only generates a values.yaml file as input to that chart.

Score is open-source and available under the Apache License 2.0. More details about Score can be found in the release blog post or in the GitHub repo.

About the Author

Rate this Article

Adoption
Style

BT