Skip to main content

Installation and Build Guide

At the moment, the Tharsis API does not provide any binaries. However, it is possible to run it locally with the following instructions.

Build and run locally (Docker)

tip

Even easier, use the provided Docker images. Learn more.

Requirements

  • Go
  • Make
  • Optional Go packages for linting and testing:
    go install golang.org/x/lint/golint@latest
    go install github.com/vektra/mockery/v2@latest

Build from source (Docker)

Git clone the project to the local machine
git clone https://gitlab.com/infor-cloud/martian-cloud/tharsis/tharsis-api.git
Start the PostgreSQL database
cd <project-directory>
make db-start
Prepare the database
make migrate
Build the API binary
make build-api
Build the API Docker image and run it
make build-api-docker
make run-api-docker

Environment variables

Expand for a list and explanation
NameGeneric ValueDescription
THARSIS_OAUTH_PROVIDERS_0_ISSUER_URL-Configured OIDC provider's issuer URL.
THARSIS_OAUTH_PROVIDERS_0_CLIENT_ID-Client ID for identity provider.
THARSIS_OAUTH_PROVIDERS_0_USERNAME_CLAIM-Supported username claim.
THARSIS_OAUTH_PROVIDERS_0_SCOPE-OAuth scopes used by the Tharsis UI.
THARSIS_OAUTH_PROVIDERS_0_LOGOUT_URL-Logout URL for the Tharsis UI.
THARSIS_TFE_LOGIN_ENABLEDtrueBoolean specifying if Terraform Login is enabled.
THARSIS_TFE_LOGIN_CLIENT_ID-Client ID for Terraform login.
THARSIS_TFE_LOGIN_SCOPES-Login scopes for Terraform login.
THARSIS_ADMIN_USER_EMAIL-Email for the default API admin user if one is to be created.
THARSIS_DB_PASSWORDpostgresThe clear-text password for the PostgreSQL database.
THARSIS_DB_USERNAMEpostgresThe username for the PostgreSQL database.
THARSIS_DB_PASSWORD_CRYPT-Encrypted version of the password for the PostgreSQL database.
THARSIS_DB_PASSWORD_ARNnoneThe Amazon Resource Number (ARN) where DB password is stored.
THARSIS_DB_NAMEtharsisUsername for PostgreSQL database.
THARSIS_DB_HOSTlocalhostHost address the database container binds to.
THARSIS_DB_PORT5432Port number where API connects with the database.
THARSIS_DB_SSL_MODEfalseBoolean indicating if database uses SSL.
THARSIS_OBJECT_STORE_PLUGIN_TYPEaws_s3Object store plugin type.
THARSIS_OBJECT_STORE_PLUGIN_DATA_BUCKET-Name of the bucket where objects will be stored.
THARSIS_OBJECT_STORE_PLUGIN_DATA_REGION-Region where the object store is hosted.
THARSIS_OBJECT_STORE_PLUGIN_DATA_AWS_ACCESS_KEY_ID-AWS access key ID used to access the object store.
THARSIS_OBJECT_STORE_PLUGIN_DATA_AWS_SECRET_ACCESS_KEY-AWS secret access key used to access the object store.
THARSIS_OBJECT_STORE_PLUGIN_DATA_ENDPOINThttp://localhost:9000URL to the object store.
THARSIS_JWS_PROVIDER_PLUGIN_TYPE-JSON Web Signature (JWS) provider plugin type.
THARSIS_JWS_PROVIDER_PLUGIN_DATA_KEY_ID-JWS provider key ID.
THARSIS_JWS_PROVIDER_PLUGIN_DATA_REGION-Region where plugin is hosted.
THARSIS_JOB_DISPATCHER_PLUGIN_TYPEdockerType of job executor plugin: kubernetes, ecs, docker, local.
THARSIS_JOB_DISPATCHER_PLUGIN_DATA_API_URLhttp://localhost:8000Job dispatcher API URL.
THARSIS_JOB_DISPATCHER_PLUGIN_DATA_HOSTunix:///var/run/docker.sockHost for the job dispatcher.
THARSIS_JOB_DISPATCHER_PLUGIN_DATA_EXTRA_HOSTS-Extra hosts for job executor docker configuration.
THARSIS_JOB_DISPATCHER_PLUGIN_DATA_IMAGE-Docker image used for the job executor.
THARSIS_JOB_DISPATCHER_PLUGIN_DATA_LOCAL_IMAGEtrueBoolean specifying if job executor image is using a local image.
THARSIS_API_URLhttp://localhost:8000Endpoint where the Tharsis API will be accessible.
THARSIS_SERVICE_ACCOUNT_ISSUER_URLhttp://localhost:8000Issuer URL for Tharsis service account authentication.
THARSIS_OTEL_TRACE_ENABLEDtrueBoolean specifying whether tracing is enabled.
THARSIS_OTEL_TRACE_TYPEotlp or xrayType of tracing data to send.
THARSIS_OTEL_TRACE_HOST-Host name or IP address to send trace data to.
THARSIS_OTEL_TRACE_PORT4317Port to send trace data to.
HTTP_RATE_LIMIT60HTTP requests per second allowed by the rate limiter
note

If running within WSL using Docker Desktop it might be necessary to change: THARSIS_DB_HOST=kubernetes.docker.internal.

Supported databases

The Tharsis API requires a database to store persistent information such as, groups, workspaces, users, etc. It currently supports PostgreSQL.

Open Telemetry (OTel) tracing

The Tharsis API supports Open Telemetry (OTel) tracing. To enable it, set the following environment variables. The list above has more information about the variables.

  • THARSIS_OTEL_TRACE_ENABLED
  • THARSIS_OTEL_TRACE_TYPE
  • THARSIS_OTEL_TRACE_HOST
  • THARSIS_OTEL_TRACE_PORT

Rate limit

The Tharsis API rate limits inbound HTTP requests for GraphQL queries and mutations. Environment variable HTTP_RATE_LIMIT specifies the number of requests per second allowed by the rate limiter. The default is 60.

Resource limits

The Tharsis API limits the numbers of certain resources in order to avoid performance breakdown or other problems. The default values are intended to not be overly restrictive. The current active limit values can be seen via this GraphQL query:

query AllResourceLimits {
resourceLimits {
id
name
value
}
}

A specific limit's value can be modified via a GraphQL mutation similar to this:

mutation UpdateResourceLimit {
updateResourceLimit(
input: {
name: "ResourceLimitAssignedManagedIdentitiesPerWorkspace"
value: 45
}
) {
clientMutationId
resourceLimit {
id
name
value
}
}
}