diff --git a/CloudronPackages/APISIX/APISIX-BuildNotes.md b/CloudronPackages/APISIX/APISIX-BuildNotes.md new file mode 100644 index 0000000..c5063ad --- /dev/null +++ b/CloudronPackages/APISIX/APISIX-BuildNotes.md @@ -0,0 +1,61 @@ +# Apache APISIX Cloudron Package - Build Notes + +## Overview +This document outlines the steps and considerations for packaging Apache APISIX for the Cloudron platform. + +## Package Components +- `CloudronManifest.json`: Defines application metadata, addons (etcd), and environment variables. +- `Dockerfile`: Builds the APISIX container image based on `apache/apisix:3.6.0-debian`. +- `start.sh`: Script to dynamically configure APISIX and start the service. +- `logo.png`: Application icon. + +## Configuration Details + +### Admin API Key +The APISIX Admin API key is securely managed using Cloudron's secret mechanism. The `CLOUDRON_APP_SECRET` environment variable is used to inject a unique, strong key into APISIX's `config.yaml` at startup. This replaces the default `changeme` value. + +**To access the Admin API:** +1. Retrieve the `CLOUDRON_APP_SECRET` from your Cloudron instance's environment variables for the APISIX app. +2. Use this key in the `X-API-KEY` header when making requests to the APISIX Admin API (e.g., `http://your-domain/apisix/admin`). + +### Etcd Integration +APISIX is configured to use Cloudron's managed etcd addon. The `start.sh` script dynamically sets the etcd host and port using `CLOUDRON_ETCD_HOST` and `CLOUDRON_ETCD_PORT` environment variables. + +### Health Check +Cloudron's health check for the APISIX application is currently configured to probe the `/health` path. While APISIX primarily uses its Control API (`/v1/healthcheck`) for monitoring *upstream services*, `/health` is a common convention for application liveness probes. If issues arise with Cloudron's health monitoring, further investigation into a more specific APISIX health endpoint or a custom health check script may be required. + +## Post-Installation Steps + +1. **Accessing the Admin API**: As mentioned above, use the `CLOUDRON_APP_SECRET` as the `X-API-KEY` header to interact with the APISIX Admin API. +2. **Initial Configuration**: After installation, you may need to use the Admin API to configure routes, upstreams, and plugins for your specific use case. + +## Local Testing + +To test the package locally: + +1. **Build the Docker image**: + ```bash + docker build -t cloudron-apisix:latest CloudronPackages/APISIX/ + ``` +2. **Run the container (with mock etcd environment variables)**: + ```bash + docker run -it --rm -p 9080:9080 -p 9443:9443 \ + -e CLOUDRON_ETCD_HOST=localhost -e CLOUDRON_ETCD_PORT=2379 \ + -e CLOUDRON_APP_SECRET=your_test_admin_key \ + cloudron-apisix:latest + ``` + *Note: Replace `localhost` and `2379` with actual etcd host/port if running a local etcd instance. `your_test_admin_key` should be a temporary key for local testing.* + +3. **Verify APISIX status (once running)**: + ```bash + curl -i http://localhost:9080/status + ``` + This should return APISIX status information. + +4. **Test Admin API (replace with your test key)**: + ```bash + curl -i -X GET "http://localhost:9080/apisix/admin/routes" -H "X-API-KEY: your_test_admin_key" + ``` + +## Known Issues / Limitations +- The `/health` endpoint for Cloudron's health check might not be ideal for APISIX's internal state. Monitor closely. diff --git a/CloudronPackages/APISIX/CloudronManifest.json b/CloudronPackages/APISIX/CloudronManifest.json index b1e9d39..d179abb 100644 --- a/CloudronPackages/APISIX/CloudronManifest.json +++ b/CloudronPackages/APISIX/CloudronManifest.json @@ -22,7 +22,10 @@ "load-balancer" ], "env": { - "APISIX_ADMIN_KEY": "changeme" + "APISIX_ADMIN_KEY": { + "description": "Admin API key for APISIX. Change this to a strong, unique value.", + "type": "secret" + } }, "configurePath": "/", "minBoxVersion": "7.0.0", diff --git a/CloudronPackages/APISIX/logo.png b/CloudronPackages/APISIX/logo.png new file mode 100644 index 0000000..f99e43f --- /dev/null +++ b/CloudronPackages/APISIX/logo.png @@ -0,0 +1 @@ +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII= \ No newline at end of file diff --git a/CloudronPackages/APISIX/start.sh b/CloudronPackages/APISIX/start.sh index 2899aa8..0786290 100644 --- a/CloudronPackages/APISIX/start.sh +++ b/CloudronPackages/APISIX/start.sh @@ -13,6 +13,12 @@ apisix: - "http://${CLOUDRON_ETCD_HOST}:${CLOUDRON_ETCD_PORT}" prefix: "/apisix" timeout: 30 +deployment: + admin: + admin_key: + - name: admin + key: ${CLOUDRON_APP_SECRET} + role: admin # Other APISIX configuration can go here if needed