Skip to the content.


The Polaris CLI is implemented as a plugin for the Nx CLI, which is exposed through a Polaris-specific wrapper application. It has the following prerequisites:

To install the Polaris CLI execute the following command:

npm install -g @polaris-sloc/cli

Now, the Polaris CLI is available globally, as polaris-cli.

Commands Overview

The Polaris CLI supports the following commands:

Command Purpose
polaris-cli init <name> Creates a new Nx workspace for creating Polaris projects.
polaris-cli generate <type> <name> Generates a new Polaris project/component [alias: g]
polaris-cli serialize-slo-mapping <slo-mapping-path> Serializes an SLO Mapping instance from a .ts file to Kubernetes YAML. [alias: serialize]
polaris-cli build <name> Builds a Polaris project.
polaris-cli docker-build <name> Builds the Docker container image for a Polaris controller project.
polaris-cli deploy <name> Deploys a Polaris project or an SLO Mapping to an orchestrator.
polaris-cli generate-crds <project> Generates a Custom Resource Definition (CRD) for an existing Polaris ApiObject type. [alias: gen-crds]

Create a New Workspace

  1. Open a terminal at the location, where you would like to create your new workspace.
  2. Create the workspace:
     polaris-cli init <workspace-name>

Generate a Component

The polaris-cli generate <type> <name> command allows generating new polaris components. If supports the following types:

SLO Mapping Type

To generate a new SLO Mapping, use the following command:

polaris-cli g slo-mapping-type <name> --project=<dest-project> --createLibProject=<true|false> --importPath=<npm-package-name-of-dest-project>


SLO Mapping

To generate an instance of an existing SLO Mapping for applying it to a workload, use the following command:

polaris-cli g slo-mapping <name> --sloMappingTypePkg=<slo-mapping-type-npm-package> --sloMappingType=<slo-mapping-type-name> --directory=<subdirectory>

All SLO Mapping instances are placed in the slo-mappings directory of your workspace.


SLO Controller

To generate a controller for an existing SLO Mapping, use the following command:

polaris-cli g slo-controller <name> --sloMappingTypePkg=<slo-mapping-type-npm-package> --sloMappingType=<slo-mapping-type-name>


Elasticity Strategy

To generate a new Elasticity Strategy type, use the following command:

polaris-cli g elasticity-strategy <name> --project=<dest-project> --createLibProject=<true|false> --importPath=<npm-package-name-of-dest-project>


Elasticity Strategy Controller

To generate a controller for an existing Elasticity Strategy type, use the following command:

polaris-cli g elasticity-strategy-controller <name> --eStratTypePkg=<elasticity-strat-type-npm-package> --eStratType=<elasticity-strat-type-name>


Composed Metric Type

To generate a new Composed Metric type, use the following command:

polaris-cli g composed-metric-type <name> --project=<dest-project> --createLibProject=<true|false> --importPath=<npm-package-name-of-dest-project>


Composed Metrics Controller

To generate a controller for an existing Composed Metric type, use the following command:

polaris-cli g composed-metric-controller <name> --compMetricTypePkg=<composed-metric-type-npm-package> --compMetricType=<composed-metric-type-name>


Metrics Dashboard Generation

The CLI provides means to generate metrics dashboards from scratch that display relevant metrics. The CLI will scrape from the connected Kubernetes instance all SloMappings that correspond to the given Composed Metric Type and will automatically create for each property an own panel. Further, the current implementation is configured to work with Grafana but we work on modularizing the internals to allow support for other implementations/dashboards.


Dashboards can either be exported to a JSON file or uploaded directly to your Grafana Dashboard.

The following parameters can be used (but only name is mandatory, in which case the dashboard will be exported to a file).

Dhe dashboard will be exported to <name>.json, in case directory is set.

Example usage (pushes dashboard to Grafana instance):

polaris-cli g metrics-dashboard test-dash 

Metrics Alert Generation

The CLI also provides means to add alerts to the dashboard. The current implementation targets the Grafana platform and therefore parameters orient towards this dashboard software.

The following parameters are available (name/dashboardId, and panel are mandatory - the defaults are taken from a default Grafana installation)

Example usage:

polaris-cli g metrics-alert wPD1Cn4nz --panel='"Process CPU seconds total"'

Predicted Metric Controller

The CLI additionally allows to generate a component (Predicted Metric Controller) publishes predictions into the monitoring system. The component consists of two programs that are scaffolded by the CLI and deployed in an atomic unit.

The first one is a Composed Metric Controller that calls the second component, the AI Proxy via REST to fetch the next prediction and transforms it into the selected Composed Metric Type.

The AI Proxy queries raw data from the monitoring system, preprocesses it and calls an external AI service (i.e., TF Serving) and returns the prediction.

The scaffolded code provides a basic implementation but leaves two main parts empty for custom logic:

  1. In the Composed Metric Controller: the mapping of the AI prediction into the Composed Metric Type
  2. In the AI Proxy:
    1. The metrics that should be fetched
    2. The preprocessing of the raw data into a format that is suitable for the deployed AI model

To generate a Predicted Metric Controller, the CLI offers the following parameters: