# VIPR Frontend Helm Chart

This chart deploys the VIPR Frontend application onto Kubernetes. It provides:

- A `Deployment` with an HTTP `Service`
- Optional Ingress or Gateway API HTTPRoute exposure
- Configurable resources, probes, autoscaling, and scheduling

The container exposes the environment variable `NUXT_PUBLIC_API_URL` which is sourced from the chart value `apiUrl`.

<!-- TOC -->
* [VIPR Frontend Helm Chart](#vipr-frontend-helm-chart)
  * [Requirements](#requirements)
  * [Quick start](#quick-start)
  * [Parameters](#parameters)
    * [Common parameters](#common-parameters)
    * [Image parameters](#image-parameters)
    * [Configuration parameters](#configuration-parameters)
    * [Deployment parameters](#deployment-parameters)
    * [Other Parameters](#other-parameters)
    * [Traffic Exposure Parameters](#traffic-exposure-parameters)
  * [Exposing the service](#exposing-the-service)
<!-- TOC -->

## Requirements

- Kubernetes 1.16+
- Helm 3.8+
- Optional: Gateway API CRDs if using `httpRoute.enabled`

Notes about optional features (may require newer cluster components or extra CRDs):

- Gateway API HTTPRoute: requires Gateway API CRDs installed and a compatible controller. The template uses `gateway.networking.k8s.io/v1`; verify your Gateway implementation’s compatibility matrix for supported Kubernetes versions.
- HorizontalPodAutoscaler: uses `autoscaling/v2` (supported in Kubernetes ≥1.23). Ensure your cluster metrics pipeline is configured (e.g., metrics-server or Prometheus adapter).
- Ingress: uses `networking.k8s.io/v1` (requires Kubernetes ≥1.19) and an Ingress controller.
- Storage for scaling: if you scale replicas that share `/app/storage`, prefer a ReadWriteMany (RWX) capable storage class.


## Quick start

1. Install:

```bash
helm install vipr-frontend oci://registry.hzdr.de/vipr/vipr-framework/vipr-frontend \
  --set apiUrl="https://api.example.tld"
```

2. Uninstall:

```bash
helm uninstall vipr-frontend
```

## Parameters

### Common parameters
| Key                                        | Type   | Default                                | Description                                         |
|--------------------------------------------|--------|----------------------------------------|-----------------------------------------------------|
| nameOverride                               | string | `""`                                   | Override chart name                                 |
| fullnameOverride                           | string | `""`                                   | Override full release name                          |

### Image parameters
| Key                                        | Type   | Default                                | Description                                         |
|--------------------------------------------|--------|----------------------------------------|-----------------------------------------------------|
| image.repository                           | string | `registry.hzdr.de/vipr/vipr-frontend`  | Container image repository                          |
| image.pullPolicy                           | string | `IfNotPresent`                         | Image pull policy                                   |
| image.tag                                  | string | `""` (defaults to `appVersion`)        | Image tag                                           |
| imagePullSecrets                           | list   | `[]`                                   | Secrets for private registry pulls                  |

### Configuration parameters
| Key                                        | Type   | Default                                | Description                                         |
|--------------------------------------------|--------|----------------------------------------|-----------------------------------------------------|
| apiUrl                                     | string | `""`                                   | Public API base URL passed as `NUXT_PUBLIC_API_URL` |

### Deployment parameters

| Key                                        | Type   | Default                                | Description                                         |
|--------------------------------------------|--------|----------------------------------------|-----------------------------------------------------|
| replicaCount                               | int    | `1`                                    | Number of pods if autoscaling is disabled           |
| podAnnotations                             | map    | `{}`                                   | Pod annotations                                     |
| podLabels                                  | map    | `{}`                                   | Additional pod labels                               |
| podSecurityContext                         | map    | `{}`                                   | Pod-level securityContext                           |
| securityContext                            | map    | `{}`                                   | Container-level securityContext                     |
| resources                                  | map    | `{}`                                   | Pod resource requests/limits                        |
| livenessProbe                              | map    | see `values.yaml`                      | Liveness probe configuration                        |
| readinessProbe                             | map    | see `values.yaml`                      | Readiness probe configuration                       |
| nodeSelector                               | map    | `{}`                                   | Node selector                                       |
| tolerations                                | list   | `[]`                                   | Tolerations                                         |
| affinity                                   | map    | `{}`                                   | Affinity rules                                      |

### Other Parameters
| Key                                        | Type   | Default                                | Description                                         |
|--------------------------------------------|--------|----------------------------------------|-----------------------------------------------------|
| serviceAccount.create                      | bool   | `true`                                 | Create a ServiceAccount                             |
| serviceAccount.automount                   | bool   | `true`                                 | Automount SA token                                  |
| serviceAccount.annotations                 | map    | `{}`                                   | Annotations for the ServiceAccount                  |
| serviceAccount.name                        | string | `""`                                   | Use an existing ServiceAccount name                 |
| autoscaling.enabled                        | bool   | `false`                                | Enable HPA                                          |
| autoscaling.minReplicas                    | int    | `1`                                    | Minimum replicas                                    |
| autoscaling.maxReplicas                    | int    | `100`                                  | Maximum replicas                                    |
| autoscaling.targetCPUUtilizationPercentage | int    | `80`                                   | Target CPU utilization                              |

### Traffic Exposure Parameters
| Key                                        | Type   | Default                                | Description                                         |
|--------------------------------------------|--------|----------------------------------------|-----------------------------------------------------|
| service.type                               | string | `ClusterIP`                            | Service type                                        |
| service.port                               | int    | `5000`                                 | Service port and container port                     |
| ingress.enabled                            | bool   | `false`                                | Enable Ingress                                      |
| ingress.className                          | string | `""`                                   | Ingress class name                                  |
| ingress.annotations                        | map    | `{}`                                   | Ingress annotations                                 |
| ingress.hosts                              | list   | `[chart-example.local]`                | Ingress hosts and paths                             |
| ingress.tls                                | list   | `[]`                                   | Ingress TLS configuration                           |
| httpRoute.enabled                          | bool   | `false`                                | Enable Gateway API HTTPRoute                        |
| httpRoute.annotations                      | map    | `{}`                                   | HTTPRoute annotations                               |
| httpRoute.parentRefs                       | list   | `[{name: gateway, sectionName: http}]` | Parent Gateways                                     |
| httpRoute.hostnames                        | list   | `[chart-example.local]`                | Hostnames for HTTPRoute                             |
| httpRoute.rules                            | list   | see `values.yaml`                      | Route match and filters                             |

## Exposing the service

- Service: ClusterIP on port 8080 by default.
- Ingress: enable with `ingress.enabled=true` and set hosts/tls.
- Gateway API: enable with `httpRoute.enabled=true` and adjust `parentRefs`, `hostnames`, and `rules`.

Example (Ingress):

```bash
helm install vipr-frontend registry.hzdr.de/vipr/vipr-frontend \
  --set ingress.enabled=true \
  --set ingress.className=nginx \
  --set ingress.hosts[0].host=vipr.example.org
```
