Deploy LabelStudio with TrueFoundry

1. Deploy the helm chart for LabelStudio

  1. New Deployment > Helm > Choose a workspace
  2. Helm repo: https://charts.heartex.com
    1. Chart name: label-studio
    2. Version: 1.1.9
    3. You can leave the values field empty or configure it as per these. Leaving it empty will bring up the app, a Postgres database and persistent volume to store artefacts.
    4. If you want to connect to an already existing Postgres database, you can find the instructions in another sections of this document.
Deploying the LabelStudio helm chart

Deploying the LabelStudio helm chart

2. Setup a VirtualService to expose this endpoint

To expose the helm chart, let’s deploy a VirtualService. We can use the helm chart deployment of in TrueFoundry:

  1. New Deployment > Helm > Choose the same workspace
  2. Helm repo: https://truefoundry.github.io/infra-charts
  3. Chart name: tfy-manifests-template (This is an empty template where you can pass a list of K8 manifests to apply to the cluster directly)
  4. Version: 0.2.0
  5. In the values field, fill the following. Remember to replace <label-studio-app-name> with the name of the LabelStudio app you deployed and <workspace-name> with the name of your workspace. Edit the hosts field to add your desired host. Make sure it works with the cluster base domain.
manifests:
  - apiVersion: networking.istio.io/v1alpha3 
    kind: VirtualService
    metadata:
      name: labelstudio-vs
    spec:
      http:
        - route:
            - destination:
                host: <label-studio-app-name>-ls-app.<workspace-name>.svc.cluster.local
                port:
                  number: 80
			hosts:
        - ds.organization.com/labelstudio
      gateways:
        - istio-system/tfy-wildcard

Now the LabelStudio UI should be accessible at ds.organization.com/labelstudio or the host that you provided.

3. [Optional] Connecting to an existing Postgres database instead

The deployment above will bring up a a Postgres database on the cluster. If you already have a running DB, you can choose to connect to it instead.

Create a secret storing the password for the Postgres DB

We’ll use the tfy-manifests-template used above to create a secret on the cluster.

  1. New Deployment > Helm > Choose the same workspace
    1. Helm repo: https://truefoundry.github.io/infra-charts
    2. Chart name: tfy-manifests-template
    3. Set values to the following. The password value is base64 encoded:
manifests:
  - data:
      password: cGFzc3dvcmQ=
    kind: Secret
    metadata:
      name: postgresql-vrs
    apiVersion: v1

Update the values of LabelStudio helm chart

global:
  pgConfig:
    host: postgresql.ci-cd-demo.svc.cluster.local
    port: 5432
    dbName: postgres
    password:
      secretName: postgresql
      secretKey: password
    userName: user
postgresql:
  enabled: false

4 [Optional] Using another persistent storage (instead of a volume)

By default, the application provisions a Persistent Volume on your cluster and uses it to store the images and other artefacts. This is separate from the database used to store metadata. But you can replace this volume storage with other storage. For example:

global:
  persistence:
    type: azure
    config:
      azure:
        storageAccountName: ""  # Azure Storage Account Name to use to access Azure Blob Storage
        storageAccountKey: ""  # Azure Storage Account Key to use to access Azure Blob Storage
        storageAccountNameExistingSecret: ""  # Existing Secret name to extract Azure Storage Account Name from to access Azure Blob Storage
        storageAccountNameExistingSecretKey: ""  # Existing Secret key to extract Azure Storage Account Name from to use to access Azure Blob Storage
        storageAccountKeyExistingSecret: ""  # Existing Secret name to extract Azure Storage Account Key from to access Azure Blob Storage
        storageAccountKeyExistingSecretKey: ""  # Existing Secret key to extract Azure Storage Account Key from to use to access Azure Blob Storage
        containerName: ""  # Azure Storage container name
        folder: ""  # Azure Storage folder name
        urlExpirationSecs: 86400  # The number of seconds that a presigned URL is valid for