|
| 1 | +# VMS deployment |
| 2 | + |
| 3 | +The **`charts/helmfile`** directory is a [Helmfile](https://github.com/helmfile/helmfile) environment that installs: |
| 4 | + |
| 5 | +| Chart | Role | |
| 6 | +| ----- | ---- | |
| 7 | +| **cert-manager** | Jetstack OCI chart (`v1.20.0`) — TLS issuers / certificates (optional). | |
| 8 | +| **postgresql** | Bitnami `postgresql` `18.3.0` — application database; schema from `resources/db-setup.sql`. | |
| 9 | +| **management-server** | Local chart at `../management-server` — VMS management controller. This chart can be deployed/managed by itself with standard Helm commands. | |
| 10 | + |
| 11 | +Helmfile uses your **current** `kubectl` context. Namespace behavior is described below. |
| 12 | + |
| 13 | +Keycloak is **not** installed here. Supply the controller with a **`keycloak-config`** Secret as in [Keycloak adapter](#keycloak-adapter). |
| 14 | + |
| 15 | +## Layout under `charts/` |
| 16 | + |
| 17 | +``` |
| 18 | +charts/ |
| 19 | +├── helmfile/ # This README |
| 20 | +│ ├── helmfile.yaml.gotmpl |
| 21 | +│ ├── values/ |
| 22 | +│ │ ├── common.yaml # postgres.* + releases.* |
| 23 | +│ │ ├── postgres.yaml.gotmpl |
| 24 | +│ │ └── management-server.yaml.gotmpl |
| 25 | +│ └── resources/ |
| 26 | +│ ├── db-setup.sql # Applied to Postgres on init (via ConfigMap) |
| 27 | +│ └── drop.sql # Optional manual teardown helper (not used by Helmfile) |
| 28 | +└── management-server/ # Helm chart for the management controller |
| 29 | +``` |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +- **[kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)** (1.15+). |
| 34 | + |
| 35 | +- **[Helm](https://helm.sh/docs/intro/install/)** and **[Helmfile](https://github.com/helmfile/helmfile)** on your `PATH`. |
| 36 | + |
| 37 | +- **[helm-diff](https://github.com/databus23/helm-diff)**: |
| 38 | + |
| 39 | + ```shell |
| 40 | + helm plugin install https://github.com/databus23/helm-diff |
| 41 | + ``` |
| 42 | + |
| 43 | +- Keycloak instance running and configured (see [Keycloak Setup](/docs/notes/keycloak-setup.md)). |
| 44 | + |
| 45 | +## Credentials (Kubernetes Secrets) |
| 46 | + |
| 47 | +Passwords are **not** stored in `values/common.yaml`. Create Secrets **before** install; names and keys come from **`postgres.credentialsSecret`** (defaults below). |
| 48 | + |
| 49 | +### PostgreSQL + management-server |
| 50 | + |
| 51 | +Create **`postgres-credentials`** (default name from `common.yaml`) in: |
| 52 | + |
| 53 | +1. The **same namespace as the PostgreSQL release**. |
| 54 | +2. The **same namespace as the management-server release**. |
| 55 | + |
| 56 | +If Postgres and management-server run in different namespaces, duplicate the Secret in both with identical keys. |
| 57 | + |
| 58 | +| Key (defaults in `common.yaml`) | Purpose | |
| 59 | +| ------------------------------- | ------- | |
| 60 | +| `postgres-password` | Bitnami superuser (`auth.secretKeys.adminPasswordKey`). | |
| 61 | +| `app-user-password` | `db-setup.sql` and management controller `APP_USER_PASSWORD`. | |
| 62 | +| `app-system-password` | `db-setup.sql` and management controller `APP_SYSTEM_PASSWORD`. | |
| 63 | + |
| 64 | +Example: |
| 65 | + |
| 66 | +```shell |
| 67 | +kubectl create secret generic postgres-credentials \ |
| 68 | + --from-literal=postgres-password='REPLACE_SUPERUSER_PASSWORD' \ |
| 69 | + --from-literal=app-user-password='REPLACE_APP_USER_PASSWORD' \ |
| 70 | + --from-literal=app-system-password='REPLACE_APP_SYSTEM_PASSWORD' \ |
| 71 | + -n <namespace> |
| 72 | +``` |
| 73 | + |
| 74 | +## Keycloak adapter |
| 75 | + |
| 76 | +The **management-server** chart expects a Secret **`keycloak-config`** with key **`keycloak.json`**. Helmfile does not create it. |
| 77 | + |
| 78 | +1. Create a Keycloak instance that the management-controller can connect to. |
| 79 | +2. Configure the client per [Keycloak setup guide](/docs/notes/keycloak-setup.md). |
| 80 | +3. Create the Secret in the management-server namespace: |
| 81 | + |
| 82 | + ```shell |
| 83 | + kubectl create secret generic keycloak-config \ |
| 84 | + --from-file=/path/to/your-keycloak.json \ |
| 85 | + -n <management-server-namespace> |
| 86 | + ``` |
| 87 | + |
| 88 | +## Configuration (`values/common.yaml`) |
| 89 | + |
| 90 | +### `releases` |
| 91 | + |
| 92 | +Toggles and PostgreSQL namespace (from inline comments in `common.yaml`): |
| 93 | + |
| 94 | +| Key | Purpose | |
| 95 | +| --- | ------- | |
| 96 | +| `releases.certManager.enabled` | Install Jetstack cert-manager into namespace **`cert-manager`** (created if missing). | |
| 97 | +| `releases.postgresql.enabled` | Install Bitnami PostgreSQL. | |
| 98 | +| `releases.postgresql.namespace` | If **non-empty**, PostgreSQL is installed in that namespace (`createNamespace: true`). If **empty**, the release uses the current namespace used when running the helmfile command. | |
| 99 | +| `releases.managementServer.enabled` | Install `../management-server`. Namespace follows Helmfile’s default unless you set release-level namespace in `helmfile.yaml.gotmpl`. | |
| 100 | + |
| 101 | +### `postgres` |
| 102 | + |
| 103 | +Used by **`values/postgres.yaml.gotmpl`** for Bitnami auth, persistence, and init SQL env vars. Passed through **`values/management-server.yaml.gotmpl`** as `PGHOST`, `PGPORT`, `PGDATABASE`, and `credentialsSecret` for app role passwords. |
| 104 | + |
| 105 | +Set **`postgres.host`** / **`postgres.port`** to a hostname and port reachable from management-server pods (for example `postgresql` or `postgresql.<namespace>.svc.cluster.local`). |
| 106 | + |
| 107 | +## Database init hook |
| 108 | + |
| 109 | +Before sync, Helmfile runs a **`presync`** hook that applies ConfigMap **`db-init-configmap`** from **`resources/db-setup.sql`**. The `kubectl` command passes **`-n <namespace>`** when **`releases.postgresql.namespace`** is set; otherwise it uses your current kubectl namespace context—align that with where PostgreSQL is installed so the ConfigMap lands in the correct namespace. |
| 110 | + |
| 111 | +## Components (Helm releases) |
| 112 | + |
| 113 | +| Release | Source | Installed when | |
| 114 | +| ------- | ------ | -------------- | |
| 115 | +| `cert-manager` | `oci://quay.io/jetstack/charts/cert-manager` | `releases.certManager.enabled` | |
| 116 | +| `postgresql` | `bitnami/postgresql` `18.3.0` | `releases.postgresql.enabled` | |
| 117 | +| `management-server` | `../management-server` | `releases.managementServer.enabled` | |
| 118 | + |
| 119 | +Select a specific release to manage with **`helmfile -l component=<label>`** (labels are `cert-manager`, `postgresql`, `management-server` in `helmfile.yaml.gotmpl`). |
| 120 | + |
| 121 | +## Deploying |
| 122 | + |
| 123 | +1. Edit **`values/common.yaml`**: **`releases.*`**, **`postgres.*`**. |
| 124 | +2. Create **`postgres-credentials`** (and **`keycloak-config`** when ready) in the required namespaces. |
| 125 | +3. From **`charts/helmfile`**: |
| 126 | + |
| 127 | + ```shell |
| 128 | + cd charts/helmfile |
| 129 | + helmfile sync |
| 130 | + ``` |
| 131 | + |
| 132 | +Use **`helmfile apply`** for incremental diffs. To release an individual chart, run `helmfile -l component=<label> apply`. |
| 133 | + |
| 134 | +## Teardown |
| 135 | + |
| 136 | +To destroy all resources created by the Helmfile releases (including the management server, PostgreSQL, and cert-manager, if installed), use: |
| 137 | + |
| 138 | +```shell |
| 139 | +helmfile destroy |
| 140 | +``` |
| 141 | + |
| 142 | +You can selectively destroy a single release (component) using the label, just like for deploys. For example, to tear down only the Bitnami PostgreSQL release: |
| 143 | + |
| 144 | +```shell |
| 145 | +helmfile -l component=postgresql destroy |
| 146 | +``` |
| 147 | + |
| 148 | +Or, for cert-manager: |
| 149 | + |
| 150 | +```shell |
| 151 | +helmfile -l component=cert-manager destroy |
| 152 | +``` |
| 153 | + |
| 154 | +This will remove the resources managed by the specified release from your cluster. Double-check your namespace/context to ensure the correct resources are modified. |
| 155 | + |
| 156 | +## Related documentation |
| 157 | + |
| 158 | +- **[getting-started](/docs/notes/getting-started.md)** — broader VMS setup. This file documents only **`charts/helmfile`** and the **`management-server`** chart path used from it. |
0 commit comments