Building and Deployment
Prerequisites
To build the components of the Polaris project for local development or testing, you need to have the following tools installed:
- Node.JS v18.x+
- Docker 20.10+
- kubectl
Furthermore, you need a Kubernetes cluster, with a running Prometheus instance. For testing locally, e.g., minikube, kind, or MicroK8s can be used. For instructions on setting up a cluster for Polaris, please see our testbed setup guide.
The Polaris Kubernetes controllers should normally run as pods within the Kubernetes cluster. For testing and development, they can also be run as a normal process on your development machine and connect to a local or remote cluster When running Polaris components locally, the current context configured in your KUBECONFIG file is used to connect to the Kubernetes cluster.
Quick Deployment
This section shows you how to quickly deploy the most common Polaris components. To build and run/debug individual components, please see the next section.
- Open a terminal in the main folder of the Polaris repository.
- Run
kubectl apply -f ./deployment
to install the following components:- All Custom Resource Definitions
- Horizontal Elasticity Strategy Controller
- Vertical Elasticity Strategy Controller
Building and Execution Tutorial
This section shows you how to build, run, and debug individual Polaris components.
- Open a terminal in the ts folder of the Polaris repository.
- Install the dependencies:
npm install
- Generate the Custom Resource Definitions and apply them to the Kubernetes cluster:
npm run gen-crds kubectl apply -f ./crds/kubernetes
- Build the component(s) you are interested in using the following command:
# Generic build command npx nx build <component-name> # E.g., build the Horizontal Elasticity Strategy controller npx nx build elasticity-horizontal-elasticity-strategy-controller # Alternatively, you can build the container image npm run docker:build:elasticity-horizontal-elasticity-strategy-controller
- To run the built controller, you need to execute the
main.ts
file in the respective output folder. The build output ofnpx nx build
is placed in thets/dist
folder, which is created during the build process. Make sure that your target Kubernetes cluster is set as the current context in your KUBECONFIG file.# E.g., run the Horizontal Elasticity Strategy controller node ./dist/apps/elasticity/horizontal-elasticity-strategy-controller/main.ts
To debug a controller with Visual Studio Code, open the
ts
folder in VS Code and open a JavaScript Debug Terminal. Then, execute the abovenode
command in that terminal. Additionally, there are some application-specific debug configurations in thets/.vscode
folder, which the the IDE will detect automatically.
If you want to test if all Polaris components build successfully after a change, you can execute the build-all.sh
script in the ts
folder.
For more details, please see the README in the ts folder of the project.
Publishing npm Packages
To publish the Polaris npm packages, do the following:
- Open a terminal in the ts folder of the Polaris repository.
- Remove all existing dependencies (this clears the Nx CLI’s build cache) and build output:
rm -rf ./node_modules ./tmp ./dist
- Reinstall the dependencies:
npm install
- Ensure that you are logged in to npmjs.com or your local registry with a user that has the appropriate permissions.
- Run the build and publish script:
./build-and-publish-npm-packages.sh
Adding an SLO Mapping to the Cluster
Please see the “Generating and Applying an SLO Mapping Instance” step in our SLO tutorials, e.g., here.