---
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
Title: Polaris Helm Chart
type: docs
weight: 675
---

<!---
  This README.md file was generated with:
  https://github.com/norwoodj/helm-docs
  Do not modify the README.md file directly, please modify README.md.gotmpl instead.
  To re-generate the README.md file, install helm-docs then run from the repo root:
  helm-docs --chart-search-root=helm
-->

{{ template "chart.deprecationWarning" . }}

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}.

{{ template "chart.homepageLine" . }}

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

## Installation

The instructions below are for the local Minikube cluster. They assume Minikube and Helm are installed.

### Installing from the official repository (recommended)

Start the Minikube cluster, add the official Polaris Helm repository, create the target namespace, and install the chart:
```bash
minikube start
helm repo add polaris https://downloads.apache.org/incubator/polaris/helm-chart
helm repo update
kubectl create namespace polaris
helm install polaris polaris/polaris --namespace polaris --devel
```

> [!NOTE]
> The --devel flag is required while Polaris is in the incubation phase.
> Helm treats the -incubating suffix as a pre‑release by SemVer rules, and will skip charts that are not in a stable versioning scheme by default.

Now the cluster should be up and running. You can run the built-in connection test to verify:
```bash
helm test polaris --namespace polaris
```

Default Polaris Helm chart values are for a non-persistent backend. To use a persistent backend, you will need to override default values and create required resources.
Polaris Helm chart package includes a number of files that can be used as a starting point for such configuration. To use them, download the chart into a local directory:
```bash
helm pull polaris \
  --repo https://downloads.apache.org/incubator/polaris/helm-chart \
  --devel \
  --untar \
  --untardir ./helm
```

> [!WARNING]
> The examples below use values files located in the `helm/polaris/ci` directory.
> **These files are intended for testing purposes primarily, and may not be suitable for production use**.
> For production deployments, create your own values files based on the provided examples.

Create required resources:
```bash
kubectl apply --namespace polaris -f helm/polaris/ci/fixtures/
kubectl wait --namespace polaris --for=condition=ready pod --selector=app.kubernetes.io/name=postgres --timeout=120s
```

> [!WARNING]
> The Postgres deployment set up in the fixtures directory is intended for testing purposes only and is not suitable for production use. For production deployments, use a managed Postgres service or a properly configured and secured Postgres instance.

Install the chart with a persistent backend:
```bash
helm upgrade --install --namespace polaris \
  --values helm/polaris/ci/persistence-values.yaml \
  polaris helm/polaris
kubectl wait --namespace polaris --for=condition=ready pod --selector=app.kubernetes.io/name=polaris --timeout=120s
```

Run the catalog bootstrap using the Polaris admin tool to initialize the catalog with the required configuration.
For example, to run it as a new pod in the Minikube cluster (the polaris-admin-tool image will be pulled automatically from Docker Hub):
```bash
kubectl run polaris-bootstrap \
  -n polaris \
  --image=apache/polaris-admin-tool:latest \
  --restart=Never \
  --rm -it \
  --env="quarkus.datasource.username=$(kubectl get secret polaris-persistence -n polaris -o jsonpath='{.data.username}' | base64 --decode)" \
  --env="quarkus.datasource.password=$(kubectl get secret polaris-persistence -n polaris -o jsonpath='{.data.password}' | base64 --decode)" \
  --env="quarkus.datasource.jdbc.url=$(kubectl get secret polaris-persistence -n polaris -o jsonpath='{.data.jdbcUrl}' | base64 --decode)" \
  -- \
  bootstrap -r POLARIS -c POLARIS,root,pass -p
```


### Build and install from source (advanced)

Here it is assumed that you have cloned the Polaris Git repository and set up prerequisites to build the project (see [Quickstart Guide](https://polaris.apache.org/in-dev/unreleased/getting-started/install-dependencies/) for details).

Start the Minikube cluster, then build and load the image into the Minikube cluster:

```bash
minikube start
eval $(minikube docker-env)

./gradlew \
  :polaris-server:assemble \
  :polaris-server:quarkusAppPartsBuild --rerun \
  :polaris-admin:assemble \
  :polaris-admin:quarkusAppPartsBuild --rerun \
  -Dquarkus.container-image.build=true
```

Create the target namespace:
```bash
kubectl create namespace polaris
```

Create all the required resources in the `polaris` namespace. This usually includes a Postgres
database, Kubernetes secrets, and service accounts. The Polaris chart does not create
these resources automatically, as they are not required for all Polaris deployments. The chart will
fail if these resources are not created beforehand. You can find some examples in the
`helm/polaris/ci/fixtures` directory, but beware that these are primarily intended for tests. For example, you can run the following commands:
```bash
kubectl apply --namespace polaris -f helm/polaris/ci/fixtures/
kubectl wait --namespace polaris --for=condition=ready pod --selector=app.kubernetes.io/name=postgres --timeout=120s
```

Below are two sample deployment models for installing the chart: one with a non-persistent backend and another with a persistent backend.

> [!WARNING]
> The examples below use values files located in the `helm/polaris/ci` directory.
> **These files are intended for testing purposes primarily, and may not be suitable for production use**.
> For production deployments, create your own values files based on the provided examples.

#### Non-persistent backend

Install the chart with a non-persistent backend. From the Polaris repo root:
```bash
helm upgrade --install --namespace polaris \
  polaris helm/polaris
```

#### Persistent backend

> [!WARNING]
> The Postgres deployment set up in the fixtures directory is intended for testing purposes only and is not suitable for production use. For production deployments, use a managed Postgres service or a properly configured and secured Postgres instance.

Install the chart with a persistent backend. From the Polaris repo root:
```bash
helm upgrade --install --namespace polaris \
  --values helm/polaris/ci/persistence-values.yaml \
  polaris helm/polaris
kubectl wait --namespace polaris --for=condition=ready pod --selector=app.kubernetes.io/name=polaris --timeout=120s
```

To access Polaris and Postgres locally, set up port forwarding for both services (this is needed for bootstrap processes):
```bash
kubectl port-forward -n polaris $(kubectl get pod -n polaris -l app.kubernetes.io/name=polaris -o jsonpath='{.items[0].metadata.name}') 8181:8181 &

kubectl port-forward -n polaris $(kubectl get pod -n polaris -l app.kubernetes.io/name=postgres -o jsonpath='{.items[0].metadata.name}') 5432:5432 &
```

Run the catalog bootstrap using the Polaris admin tool. This step initializes the catalog with the required configuration:
```bash
container_envs=$(kubectl exec -it -n polaris $(kubectl get pod -n polaris -l app.kubernetes.io/name=polaris -o jsonpath='{.items[0].metadata.name}') -- env)
export QUARKUS_DATASOURCE_USERNAME=$(echo "$container_envs" | grep quarkus.datasource.username | awk -F '=' '{print $2}' | tr -d '\n\r')
export QUARKUS_DATASOURCE_PASSWORD=$(echo "$container_envs" | grep quarkus.datasource.password | awk -F '=' '{print $2}' | tr -d '\n\r')
export QUARKUS_DATASOURCE_JDBC_URL=$(echo "$container_envs" | grep quarkus.datasource.jdbc.url | sed 's/postgres/localhost/2' | awk -F '=' '{print $2}' | tr -d '\n\r')

java -jar runtime/admin/build/quarkus-app/quarkus-run.jar bootstrap -c POLARIS,root,pass -r POLARIS
```

### Uninstalling

```bash
helm uninstall --namespace polaris polaris

kubectl delete --namespace polaris -f helm/polaris/ci/fixtures/

kubectl delete namespace polaris
```

## Development & Testing

This section is intended for developers who want to run the Polaris Helm chart tests.

### Prerequisites

The following tools are required to run the tests:

* [Helm Unit Test](https://github.com/helm-unittest/helm-unittest)
* [Chart Testing](https://github.com/helm/chart-testing)
* [yamllint](https://github.com/adrienverge/yamllint)

Quick installation instructions for these tools:
```bash
helm plugin install https://github.com/helm-unittest/helm-unittest.git
brew install chart-testing
brew install yamllint
```

The integration tests also require some fixtures to be deployed. The `ci/fixtures` directory
contains the required resources. To deploy them, run the following command:
```bash
kubectl apply --namespace polaris -f helm/polaris/ci/fixtures/
kubectl wait --namespace polaris --for=condition=ready pod --selector=app.kubernetes.io/name=postgres --timeout=120s
```

The `helm/polaris/ci` directory contains a number of values files that will be used to install the chart with
different configurations.

### Running the unit tests

Helm unit tests do not require a Kubernetes cluster. To run the unit tests, execute Helm Unit from
the Polaris repo root:
```bash
helm unittest helm/polaris
```

You can also lint the chart using the Chart Testing tool, with the following command:

```bash
ct lint --charts helm/polaris
```

### Running the integration tests

Integration tests require a Kubernetes cluster. See installation instructions above for setting up
a local cluster.

Integration tests are run with the Chart Testing tool:
```bash
ct install --namespace polaris --charts ./helm/polaris
```

{{ template "chart.valuesSection" . }}
