Hello World with score-helm

Overview

The primary goal of the Score Specification is to quickly and easily describe how to run a Workload. The following covers what you need to know to compose your first score.yaml file and run it with score-helm.

Building blocks

At it’s core, the Score file needs a name and a container to run.

In the following example, the Score tab shows the minimum configuration needed to run a Workload and the Docker Compose tab shows the output of the score-helm run command.

The score.yaml file contains a Workload named hello-world and specifies a container image as busybox.

The following is the minimum configuration needed to run a Workload.

apiVersion: score.dev/v1b1
metadata:
  name: hello-world

containers:
  container-id:
    image: busybox

The output of score-helm run -f ./score.yaml -o ./values.yaml.

containers:
  container-id:
    image:
      name: busybox

The following is a description of the previous command.

  • run tells the CLI to translate the Score file to a Helm values.yaml file.
  • -f is the path to the Score file.
  • -o specifies the path to the values.yaml file.

Containers

In the following example, we’ll create a simple service based on busybox using the containers definition.

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"]

The output of score-helm run -f ./score.yaml -o ./values.yaml.

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

Deploy to Helm

The following steps are specific to deploying via Helm.

Initialize the Workload Helm Chart Repository

Run the following command to initialize the Workload Helm chart repository.

helm repo add score-helm-charts https://score-spec.github.io/score-helm-charts

Once this is installed, you will be able to use the default score-helm-charts/workload Helm chart (you can adapt it for your own use case, find the source code here).

Install Helm values.yaml

Run the following command to deploy the score-helm-charts/workload Helm chart with the Helm values.yaml file generated previously.

helm install hello score-helm-charts/workload --values ./values.yaml

The following are the outputs of the previous command.

NAME: hello
LAST DEPLOYED: Thu Nov  01 00:00:00 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

The following is the generated Kubernetes deployment object.

---
# Source: workload/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
  labels:
    helm.sh/chart: workload-0.3.0
    app.kubernetes.io/name: hello
    app.kubernetes.io/instance: hello
    app.kubernetes.io/version: "0.3.0"
    app.kubernetes.io/managed-by: Helm
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: hello
      app.kubernetes.io/instance: hello
  template:
    metadata:
      labels:
        app.kubernetes.io/name: hello
        app.kubernetes.io/instance: hello
    spec:
      containers:
        - name: hello
          image: "busybox"
          command:
            - /bin/sh
          args:
            - -c
            - while true; do echo Hello World!; sleep 5; done

Results You’ve successfully defined a Hello World Workload in score.yaml and created a deployment.yaml file for Kubernetes through the score-helm Implementation.