From 8619bb1965dd4fb5aa2df605729ed2feccb71418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Verstraeten?= <1546779+cedricve@users.noreply.github.com> Date: Wed, 4 Nov 2026 10:51:01 +0000 Subject: [PATCH] Use Garage environment secrets and document S3 setup Avoid Garage's root-owned secret-file permission incompatibility with non-root Kubernetes mounts. Validate generated secret formats and document fresh installation, Vault provider configuration and preservation of existing MinIO data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.configure.md | 17 +-- README.k8s.md | 37 +++++-- README.kustomize.md | 12 ++- README.md | 15 ++- README.microk8s.md | 39 +++++-- base/garage/README.md | 102 ++++++++++++++++++ base/garage/garage.yaml | 20 ++-- .../vault-runtime-configuration-secret.yaml | 4 +- scripts/install-garage.sh | 10 +- 9 files changed, 208 insertions(+), 48 deletions(-) create mode 100644 base/garage/README.md diff --git a/README.configure.md b/README.configure.md index 14b1fc3..e74ef32 100644 --- a/README.configure.md +++ b/README.configure.md @@ -24,16 +24,17 @@ With the Vault installed, we can proceed to configure the various components. Cu ![Configure Vault](./assets/images/configure-vault.gif) -- Navigate to the `Storage Providers` menu and select the (+ Add Storage Provider) button. A modal will appear where you can input the required details. After entering the information, click the "Verify" button to ensure the configuration is valid. Once you receive a "Configuration is valid and working" message, click the "Add Storage Provider" button to complete the process. **_(!You are advised to generate more complex access and secret key for Minio, this is just for demo purposes, do not use this in production)_** +- Navigate to the `Storage Providers` menu and select the (+ Add Storage Provider) button. Verify and add the provider using the [Garage setup guide](./base/garage/README.md). These settings apply to the default Kubernetes installation; retain the matching provider settings for an existing MinIO or Docker installation. - - Minio + - MinIO/S3-compatible provider type (Garage backend) - Enabled: true - - Provider name: minio + - Provider name: garage - Bucket name: mybucket - - Region: na - - Hostname: myminio-hl.minio-tenant:9000 - - Access key: minio - - Secret key: minio123 + - Region: garage + - Hostname: garage.garage:3900 + - SSL: false + - Access key: `access-key` from Secret `garage/garage-credentials` + - Secret key: `secret-key` from the same Secret - Navigate to the `Integrations` menu and select the (+ Add Integration) button. A modal will appear where you can input the required details. After entering the information, click the "Verify" button to ensure the configuration is valid. Once you receive a "Configuration is valid and working" message, click the "Add Integration" button to complete the process. **_(!You are advised to generate more complex username and password for RabbitMQ, this is just for demo purposes, do not use this in production)_** @@ -50,7 +51,7 @@ With the Vault installed, we can proceed to configure the various components. Cu - Enabled: true - Account name: myaccount - - Main provider: minio + - Main provider: garage - Day limit: 30 - Integration: rabbitmq - Directory: \* diff --git a/README.k8s.md b/README.k8s.md index 14d2f77..43b2491 100644 --- a/README.k8s.md +++ b/README.k8s.md @@ -116,7 +116,7 @@ When installing the Kerberos.io stack, several dependencies are required for sto ### Clone repository -Next, we will clone this repository to our local environment. This will allow us to execute the necessary configuration files for installing the Minio operator, MongoDB Helm chart, and other required components. +Next, clone this repository for the Garage S3 manifests, MongoDB Helm chart values, and other required components. ```bash git clone https://github.com/kerberos-io/deployment @@ -127,7 +127,21 @@ cd deployment When you create a Kubernetes cluster using `kubeadm` on a bare metal machine -### Object storage: MinIO +### Object storage: Garage (default) + +After creating the `ssd-hostpath` StorageClass for your provisioner, run: + +```sh +bash scripts/install-garage.sh +bash scripts/check-garage.sh +``` + +See the [Garage guide](./base/garage/README.md) for generated credentials, +Vault provider settings, persistence and existing MinIO compatibility. Garage +uses S3 port `3900` internally and NodePort `30090`; it needs no operator. +Skip the following legacy section when using the default installation. + +### Optional legacy object storage: MinIO MinIO is a high-performance, distributed object storage system that is compatible with Amazon S3 cloud storage service. It is designed to handle large-scale data storage and retrieval, making it an ideal choice for modern cloud-native applications. @@ -318,14 +332,19 @@ With the Kerberos Vault installed, we can proceed to configure the various compo - Navigate to the `Storage Providers` menu and select the (+ Add Storage Provider) button. A modal will appear where you can input the required details. After entering the information, click the "Verify" button to ensure the configuration is valid. Once you receive a "Configuration is valid and working" message, click the "Add Storage Provider" button to complete the process. - - Minio + - MinIO/S3-compatible provider type (Garage backend) - Enabled: true - - Provider name: minio + - Provider name: garage - Bucket name: mybucket - - Region: na - - Hostname: myminio-hl.minio-tenant:9000 - - Access key: minio - - Secret key: minio123 + - Region: garage + - Hostname: garage.garage:3900 + - SSL: false + - Access key: `access-key` from Secret `garage/garage-credentials` + - Secret key: `secret-key` from the same Secret + +For the optional legacy MinIO installation, retain that backend's hostname, +credentials and provider name instead. See the [Garage guide](./base/garage/README.md) +before switching an existing installation. - Navigate to the `Integrations` menu and select the (+ Add Integration) button. A modal will appear where you can input the required details. After entering the information, click the "Verify" button to ensure the configuration is valid. Once you receive a "Configuration is valid and working" message, click the "Add Integration" button to complete the process. @@ -342,7 +361,7 @@ With the Kerberos Vault installed, we can proceed to configure the various compo - Enabled: true - Account name: myaccount - - Main provider: minio + - Main provider: garage (or the retained provider for an existing installation) - Day limit: 30 - Integration: rabbitmq - Directory: \* diff --git a/README.kustomize.md b/README.kustomize.md index 5d15b35..8b3ab41 100644 --- a/README.kustomize.md +++ b/README.kustomize.md @@ -86,7 +86,6 @@ microk8s enable dns microk8s enable dashboard microk8s enable nvidia microk8s enable hostpath-storage -microk8s enable minio ``` You can verify the status of the enabled addons by running the following command: @@ -103,7 +102,7 @@ kubectl get po -w -A ### Clone repository -Next, we will clone this repository to our local environment. This will allow us to execute the necessary configuration files for installing the Minio operator, MongoDB Helm chart, and other required components. +Next, clone this repository for the Garage S3 manifests, MongoDB Helm chart values, and other required components. ```bash git clone https://github.com/kerberos-io/deployment @@ -112,6 +111,13 @@ cd deployment ## Kustomize +The default base uses [Garage S3](./base/garage/README.md). Before a native +Kustomize apply, run `bash scripts/install-garage.sh --prepare-only` to create +its namespace and persistent credentials. `configure.sh apply` does this +automatically. Do not enable the MinIO addon for this default stack. Existing +MinIO installations must keep their backend/provider settings until their data +is explicitly migrated; do not prune their storage resources. + In contrast to the detailed installation instructions, as mentioned here, an easier option to install is to use our Kustomize configure. This will allow you to specify and create your own overlays to install all the different components through a single command line. Kustomize uses the concept of `bases` and `overlays`, allowing you to customize the base installation with different settings (an overlay). Before executing the `kustomize` command below, navigate to the `overlays/microk8s/kustomization.yaml` file and modify the `inlineValues` of the Hub to match the IP address of your node. Please note that when using Multipass, WSL, or any other type of virtualization, your IP address will differ from the IP address of your host machine. Verify your IP address using the `ifconfig` command. @@ -185,7 +191,7 @@ namespace/kerberos-agent unchanged namespace/kerberos-factory unchanged namespace/kerberos-hub unchanged namespace/kerberos-vault unchanged -namespace/minio-tenant unchanged +namespace/garage unchanged namespace/mongodb unchanged namespace/rabbitmq unchanged namespace/vernemq unchanged diff --git a/README.md b/README.md index a9f6d91..eea077c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,19 @@ The Kerberos.io stack offers flexible installation options, supporting deploymen This repository continuously tests the Kerberos.io deployment using GitHub Actions across various platforms. Refer to the badges for an overview of the operating systems and Kubernetes distributions we are deploying to. We welcome suggestions for additional automations to consider. +Kubernetes examples and CI now use **Garage S3** for local object storage. +See the [Garage setup guide](./base/garage/README.md) for generated credentials, +Vault configuration, persistence tests and existing MinIO compatibility. +This is a single-node example, not a replicated production storage deployment. +The [MinIO manifests](./base/minio/) remain available; no existing data is +migrated or removed automatically. The Docker guide retains its separate +storage setup. + +Slack notifications are optional. If `SLACK_WEBHOOK_URL` is unavailable (for +example on fork PRs), CI emits a warning and skips delivery without masking +deployment failures. Configured webhook delivery errors still fail the step. +Failed deployment jobs collect pod events and bounded logs for diagnosis. + ### Hardened Hub frontend The promoted frontend image requires Hub chart **0.170.0 or newer**, which @@ -46,7 +59,7 @@ Edge (self-hosted) deployments are typically used for camera processing and edge ![Edge - self-hosted deployment](./assets/images/deployment-self-hosted.svg) -A key aspect of this deployment is the scaling of Agents. Each camera is assigned a dedicated Agent container, which is linked to a central Kerberos Vault. The Kerberos Vault stores metadata in MongoDB, recordings in Minio (or another S3-compliant object storage), and can generate events in a message broker like RabbitMQ. This approach enables you to develop custom applications/logic that can respond to the creation of new recordings. +A key aspect of this deployment is the scaling of Agents. Each camera is assigned a dedicated Agent container, which is linked to a central Kerberos Vault. The Kerberos Vault stores metadata in MongoDB, recordings in Garage (or another S3-compliant object storage), and can generate events in a message broker like RabbitMQ. This approach enables you to develop custom applications/logic that can respond to the creation of new recordings. Based on your technology experience and preferences, you can choose from the following deployment guides: diff --git a/README.microk8s.md b/README.microk8s.md index c74b147..34c49fe 100644 --- a/README.microk8s.md +++ b/README.microk8s.md @@ -96,14 +96,29 @@ kubectl get po -w -A ### Clone repository -Next, we will clone this repository to our local environment. This will allow us to execute the necessary configuration files for installing the Minio operator, MongoDB Helm chart, and other required components. +Next, clone this repository for the Garage S3 manifests, MongoDB Helm chart values, and other required components. ```bash git clone https://github.com/kerberos-io/deployment cd deployment ``` -### Object storage: MinIO +### Object storage: Garage (default) + +Create the `ssd-hostpath` StorageClass backed by MicroK8s hostpath storage: + +```sh +kubectl apply -f base/ssd-hostpath-storageclass.yaml +bash scripts/install-garage.sh +bash scripts/check-garage.sh +``` + +See the [Garage guide](./base/garage/README.md) for generated credentials, +Vault settings and persistence. Garage uses S3 port `3900` internally and +NodePort `30090`; no MinIO operator or addon is required. Skip the following +legacy section when using the default installation. + +### Optional legacy object storage: MinIO MinIO is a high-performance, distributed object storage system that is compatible with Amazon S3 cloud storage service. It is designed to handle large-scale data storage and retrieval, making it an ideal choice for modern cloud-native applications. @@ -299,16 +314,20 @@ With the Vault installed, we can proceed to configure the various components. Cu ![Configure Vault](./assets/images/configure-vault.gif) -- Navigate to the `Storage Providers` menu and select the (+ Add Storage Provider) button. A modal will appear where you can input the required details. After entering the information, click the "Verify" button to ensure the configuration is valid. Once you receive a "Configuration is valid and working" message, click the "Add Storage Provider" button to complete the process. **_(!You are advised to generate more complex access and secret key for Minio, this is just for demo purposes, do not use this in production)_** +- Navigate to the `Storage Providers` menu and select the (+ Add Storage Provider) button. Verify and add the provider using the [Garage setup guide](./base/garage/README.md). - - Minio + - MinIO/S3-compatible provider type (Garage backend) - Enabled: true - - Provider name: minio + - Provider name: garage - Bucket name: mybucket - - Region: na - - Hostname: myminio-hl.minio-tenant:9000 - - Access key: minio - - Secret key: minio123 + - Region: garage + - Hostname: garage.garage:3900 + - SSL: false + - Access key: `access-key` from Secret `garage/garage-credentials` + - Secret key: `secret-key` from the same Secret + +For the optional legacy MinIO installation, retain that backend's hostname, +credentials and provider name instead. - Navigate to the `Integrations` menu and select the (+ Add Integration) button. A modal will appear where you can input the required details. After entering the information, click the "Verify" button to ensure the configuration is valid. Once you receive a "Configuration is valid and working" message, click the "Add Integration" button to complete the process. **_(!You are advised to generate more complex username and password for RabbitMQ, this is just for demo purposes, do not use this in production)_** @@ -325,7 +344,7 @@ With the Vault installed, we can proceed to configure the various components. Cu - Enabled: true - Account name: myaccount - - Main provider: minio + - Main provider: garage (or the retained provider for an existing installation) - Day limit: 30 - Integration: rabbitmq - Directory: \* diff --git a/base/garage/README.md b/base/garage/README.md new file mode 100644 index 0000000..99e38ce --- /dev/null +++ b/base/garage/README.md @@ -0,0 +1,102 @@ +# Garage S3 for local Kubernetes deployments + +The default Kubernetes stack uses [Garage](https://garagehq.deuxfleurs.fr/), +not the MinIO operator. The pinned multi-architecture `dxflrs/garage:v2.5.0` +image runs as a single non-root node with SQLite metadata and object data on +the same 10Gi `ssd-hostpath` PVC. This is a local/edge/CI example with **no +replication or high availability**, not a production multi-node layout. +Use Garage's [production deployment guide](https://garagehq.deuxfleurs.fr/documentation/cookbook/real-world/) +for replicated storage. Choose capacity and a backup policy before storing +recordings; resizing a bound PVC depends on your storage provisioner. + +## Install + +First install your storage provisioner and create the `ssd-hostpath` +StorageClass (the same prerequisite used by MongoDB and RabbitMQ). Run commands +from the deployment repository root: + +```sh +bash scripts/install-garage.sh +bash scripts/check-garage.sh +``` + +The installer generates an RPC secret and S3 credentials in the Kubernetes +Secret `garage/garage-credentials`, and reuses them on subsequent runs. No +credentials are committed to the repository. Garage's `--single-node` and +`--default-bucket` startup flags initialize the layout and `mybucket`. +The installer refuses to generate new credentials if the PVC already exists +but its Secret is missing: restore the original Secret instead. + +For a full Kustomize installation, prepare credentials before applying the +overlay; the default base already includes Garage: + +```sh +bash scripts/install-garage.sh --prepare-only +kubectl kustomize overlays/microk8s --enable-helm --load-restrictor LoadRestrictionsNone | kubectl apply -f - +kubectl -n garage rollout status statefulset/garage --timeout=300s +``` + +The `configure.sh apply` helper also prepares the Secret before applying its +overlay. Back up the Secret and the PVC together. Do not delete the namespace, +Secret or PVC as an upgrade/recovery step. + +## Configure Vault + +Add a storage provider using Vault's existing **MinIO/S3-compatible provider +type**. The provider *name* identifies the instance and is distinct from its +implementation type: + +| Setting | Value | +| --- | --- | +| Provider type | MinIO (`minio`) | +| Provider name | `garage` | +| Bucket | `mybucket` | +| Region | `garage` | +| Internal hostname | `garage.garage:3900` (no URL scheme) | +| SSL | Disabled for this local HTTP example | +| Access key | Secret field `access-key` | +| Secret key | Secret field `secret-key` | + +Retrieve credentials locally when configuring Vault; do not paste them into +logs, issues, or committed values: + +```sh +kubectl -n garage get secret garage-credentials -o jsonpath='{.data.access-key}' | base64 --decode +kubectl -n garage get secret garage-credentials -o jsonpath='{.data.secret-key}' | base64 --decode +``` + +The S3 endpoint is exposed at `http://NODE_IP:30090`. If browsers or remote +clients consume provider-native presigned URLs, configure Vault's external +hostname as `NODE_IP:30090` with external SSL disabled (or a real TLS endpoint). +Cluster-only DNS names cannot be resolved by external clients. Protect exposed +ports with firewall rules and use TLS outside a trusted local network. Garage's +RPC port is bound to loopback; no admin API or web console is exposed. + +Set the Vault account's main provider to `garage`. The supplied Hub values +also use that name for recording, archive, thumbnail and sprite access. +**Vault account credentials are separate from Garage S3 credentials**: keep +the existing Agent/Hub account credentials aligned with the Vault account, +not with the generated S3 key. + +## Verification + +`scripts/check-garage.sh` performs an authenticated AWS Signature V4 PUT/GET +through the Kubernetes Service and compares object bytes. It retains a small, +uniquely named object under `mybucket/ci-smoke/`; it never deletes existing +objects. The optional `--restart` flag restarts the Garage pod between upload +and download to verify persistence; use it only in CI or a maintenance window. +CI also verifies that reinstalling Garage preserves its credential Secret. + +## Existing MinIO installations + +The [MinIO manifests](../minio/) remain available as an explicit legacy option. +This change does **not** copy recordings, modify Vault's stored provider +records, or delete MinIO resources. Do not use prune/apply cleanup to remove +the old backend while it contains recordings. + +When upgrading an existing deployment, keep its existing Vault provider names +in the Hub values (`kerberosvault.provider`, `archive.provider`, +`thumbnail.provider`, `sprite.provider`) until recordings have been explicitly +migrated and reads verified. Add Garage as a separate provider/account as +needed. Treat object migration and retirement of MinIO as a separate, +backed-up operation; this installer only provisions the new backend. diff --git a/base/garage/garage.yaml b/base/garage/garage.yaml index 963065f..a1fa598 100644 --- a/base/garage/garage.yaml +++ b/base/garage/garage.yaml @@ -10,7 +10,6 @@ data: replication_factor = 1 rpc_bind_addr = "127.0.0.1:3901" rpc_public_addr = "127.0.0.1:3901" - rpc_secret_file = "/secrets/rpc-secret" [s3_api] s3_region = "garage" @@ -65,6 +64,11 @@ spec: seccompProfile: type: RuntimeDefault env: + - name: GARAGE_RPC_SECRET + valueFrom: + secretKeyRef: + name: garage-credentials + key: rpc-secret - name: GARAGE_DEFAULT_ACCESS_KEY valueFrom: secretKeyRef: @@ -86,8 +90,8 @@ spec: periodSeconds: 2 failureThreshold: 60 readinessProbe: - tcpSocket: - port: s3 + exec: + command: ["/garage", "health"] livenessProbe: tcpSocket: port: s3 @@ -102,9 +106,6 @@ spec: mountPath: /etc/garage.toml subPath: garage.toml readOnly: true - - name: credentials - mountPath: /secrets - readOnly: true - name: data mountPath: /var/lib/garage - name: tmp @@ -113,13 +114,6 @@ spec: - name: config configMap: name: garage - - name: credentials - secret: - secretName: garage-credentials - defaultMode: 0440 - items: - - key: rpc-secret - path: rpc-secret - name: tmp emptyDir: sizeLimit: 16Mi diff --git a/base/vault/vault-runtime-configuration-secret.yaml b/base/vault/vault-runtime-configuration-secret.yaml index f29b1f3..37b5aad 100644 --- a/base/vault/vault-runtime-configuration-secret.yaml +++ b/base/vault/vault-runtime-configuration-secret.yaml @@ -12,8 +12,8 @@ stringData: MQTT_USERNAME: "" MQTT_PASSWORD: "" VAULT_STORAGE_PROVIDERS: >- - [{"name":"archive","provider":"minio","host":"minio.minio.svc:9000","region":"us-east-1","bucket":"recordings","access_key":"example-key","secret":"example-secret","use_ssl":"false"}] + [{"name":"garage","provider":"minio","host":"garage.garage:3900","region":"garage","bucket":"mybucket","access_key":"replace-with-garage-access-key","secret":"replace-with-garage-secret-key","use_ssl":"false"}] VAULT_INTEGRATIONS: >- [{"name":"events","queue":"rabbitmq","broker":"amqp://rabbitmq.rabbitmq.svc:5672","topic":"recordings","username":"example-user","password":"example-password"}] VAULT_ACCOUNTS: >- - [{"account":"camera-fleet","directory":"fleet","provider":"archive","access_key":"example-account-key","secret_access_key":"example-account-secret","limit":"30","queues":["events"]}] + [{"account":"camera-fleet","directory":"fleet","provider":"garage","access_key":"example-account-key","secret_access_key":"example-account-secret","limit":"30","queues":["events"]}] diff --git a/scripts/install-garage.sh b/scripts/install-garage.sh index 15e6bf0..01ff5e3 100644 --- a/scripts/install-garage.sh +++ b/scripts/install-garage.sh @@ -21,8 +21,14 @@ if [[ -z "$secret" ]]; then --from-literal="secret-key=$(openssl rand -hex 32)" fi -kubectl -n garage get secret garage-credentials -o json | - jq -e '.data | all(."rpc-secret", ."access-key", ."secret-key"; type == "string" and length > 0)' > /dev/null +if ! kubectl -n garage get secret garage-credentials -o json | + jq -e '.data | + (."rpc-secret" | @base64d | test("^[0-9a-f]{64}$")) and + (."access-key" | @base64d | test("^GK[0-9a-f]{32}$")) and + (."secret-key" | @base64d | test("^[0-9a-f]{64}$"))' > /dev/null; then + echo "Garage credentials are missing or invalid; restore a valid garage-credentials Secret." >&2 + exit 1 +fi if [[ $# -eq 1 ]]; then echo "Garage credentials are ready; apply your Kustomize overlay next." exit 0