Apache APISIX Dashboard Documentation
repository·master·Indexed 22 days ago
https://github.com/apache/apisix-dashboardA web-based management interface for Apache APISIX that provides a visual way to configure and operate the API gateway. The documentation covers development environment setup using VS Code Dev Containers, running the server with pnpm, E2E testing with Playwright, ESLint configurations for React and i18n, and the use of specialized React hooks for managing APISIX resources such as Upstreams, Routes, and Services.
What's inside Apache APISIX Dashboard
- Apache APISIX Dashboard provides a frontend user interface designed to simplify the operation and management of Apache APISIX. It allows users to interact with APISIX features through a visual interface rather than relying solely on APIs or configuration files.
Version Compatibility for Apache APISIX Dashboard
masterWhen deploying the dashboard, ensure version alignment between the dashboard and the APISIX gateway:
- Use the
masterversion of the dashboard with themasterversion of Apache APISIX. - The dashboard is not released as an independent product; instead, it uses fixed git tags that correspond to specific Apache APISIX releases.
- Use the
Run the development server
masterOnce the Dev Container environment is ready, you can start the development server to enable real-time code modification and browser preview.
- Open a new Terminal within the VS Code Dev Container.
- Execute the following command:
pnpm dev
pnpm devSet up the development environment using Dev Containers
masterThe recommended way to develop Apache APISIX Dashboard is using
VS Codewith theDev Containersextension. This approach provides a pre-configured environment containinggit,node,pnpm,apisix, andetcdvia the.devcontainerconfiguration.Prerequisites
- Install
VS Code. - Install the
Dev Containersextension in VS Code.
Setup Steps
- Clone the repository:
git clone https://github.com/apache/apisix-dashboard.git cd apisix-dashboard code . - Reopen in Container:
- When VS Code opens, click the
Reopen in Containerprompt in the bottom right corner. - If no prompt appears, open the
Command Palette(Ctrl+Shift+P or Cmd+Shift+P), typereopen, and selectDev Containers: Reopen in Container.
- When VS Code opens, click the
- Wait for build:
Wait for the environment to build. You will see confirmation in the
TERMINALtab once it is ready.
git clone https://github.com/apache/apisix-dashboard.git cd apisix-dashboard code .- Install
Run APISIX and etcd via Docker Compose
masterThe
e2e/server/docker-compose.ymlfile provides a configuration for orchestrating a local development or end-to-end testing environment consisting of the APISIX service and anetcdinstance.Key components:
- apisix: Built from the repository root using the Dockerfile located at
e2e/server/Dockerfile. It relies on a localapisix_conf.ymlmounted as a read-only volume to/usr/local/apisix/conf/config.yaml. It exposes port9180. - etcd: Uses the
bitnamilegacy/etcd:3.5image. It is configured with etcd v2 enabled and no authentication required for testing purposes. Data is persisted in theetcd_datavolume. - Network: Both services communicate over a bridge network named
apisix.
services: apisix: build: context: ../.. dockerfile: e2e/server/Dockerfile restart: always volumes: - ./apisix_conf.yml:/usr/local/apisix/conf/config.yaml:ro ports: - '9180:9180' depends_on: - etcd networks: - apisix etcd: image: bitnamilegacy/etcd:3.5 restart: always volumes: - etcd_data:/bitnami/etcd environment: ETCD_ENABLE_V2: 'true' ALLOW_NONE_AUTHENTICATION: 'yes' ETCD_ADVERTISE_CLIENT_URLS: 'http://etcd:2379' ETCD_LISTEN_CLIENT_URLS: 'http://0.0.0.0:2379' networks: - apisix networks: apisix: driver: bridge volumes: etcd_data:- apisix: Built from the repository root using the Dockerfile located at
Configure Playwright for E2E testing
masterThe project uses Playwright for end-to-end (E2E) testing. The configuration is defined in
playwright.config.tsand uses the following key settings:- Test Directory: Tests are located in
./e2e/tests. - Output Directory: Test results are stored in
./test-results. - Execution Mode: Tests run in
fullyParallelmode. - CI Behavior:
forbidOnlyis enabled whenprocess.env.CIis present.retriesis set to2in CI, otherwise0.workersis limited to1in CI to ensure stability.
- Reporters: Uses
html,list, and@estruyf/github-actions-reporter(withuseDetails: trueandshowError: true). - Base URL: The
baseURLis dynamically set from theE2E_TARGET_URLenvironment variable. - Tracing: Traces are captured
on-first-retry.
import { defineConfig, devices } from '@playwright/test'; import { env } from './e2e/utils/env'; export default defineConfig({ testDir: './e2e/tests', outputDir: './test-results', fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, reporter: [ ['html'], ['list'], ['@estruyf/github-actions-reporter', { useDetails: true, showError: true }], ], use: { baseURL: env.E2E_TARGET_URL, trace: 'on-first-retry', }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'], viewport: { width: 1920, height: 1080 }, permissions: ['clipboard-read'], }, }, ], });- Test Directory: Tests are located in
ESLint Configuration for Apache APISIX Dashboard
masterThe project uses a flat configuration system via
typescript-eslintto enforce code quality across different file types. The configuration is divided into several specialized rule sets:- Common Rules: Applies to all files. Includes recommended JS and TypeScript rules, enforces single quotes, and requires Apache Software Foundation (ASF) license headers (sourced from
.actions/ASFLicenseHeader.txt). - Import Rules: Enforces strict import sorting and manages unused imports. Unused variables/arguments starting with an underscore (
^_) are ignored. - E2E Rules: Targets
e2e/**/*.tsande2e/**/*.spec.tsfiles, incorporating Playwright recommended configurations. - i18n Rules: Targets
src/**/*.{ts,tsx,js}. Enforces internationalization best practices usingi18nextand@m6web/eslint-plugin-i18n. It specifically checks for unknown keys, prevents raw text as children (except for specific patterns), and restricts text in certain attributes likealtandtitle. - Source Rules: Targets
src/**/*.{ts,tsx}andeslint.config.ts. Enforces React best practices, React Hooks rules, and React Refresh requirements for Fast Refresh support.
- Common Rules: Applies to all files. Includes recommended JS and TypeScript rules, enforces single quotes, and requires Apache Software Foundation (ASF) license headers (sourced from
Locate the Admin Key for development
masterIf you need to find the admin key for testing or configuration during development, it is located in the following file:
e2e/server/apisix_conf.ymlUpdate a secret
masterUse
putSecretReqto update an existing secret. The function extracts themanagerandidfrom the provided data object to construct the URL path (${API_SECRETS}/${manager}/${id}) and sends the remaining properties in the request body.// req: AxiosInstance, data: APISIXType['Secret'] const updatedSecret = await putSecretReq(axiosInstance, { id: 'my-secret-id', manager: 'etcd', value: 'new-secret-value', // ... other secret properties });Retrieve plugins filtered by subsystem and schema
masterUse
getPluginsListWithSchemaQueryOptionsto fetch plugins that contain a specific schema key (e.g.,'schema') and belong to a specificsubsystem. This is useful for filtering plugins available for specific APISIX components.Parameters:
subsystem: The APISIX subsystem to filter by.schema: The schema key to check for existence in the plugin configuration (defaults to'schema').
import { useQuery } from '@tanstack/react-query'; import { getPluginsListWithSchemaQueryOptions } from '@/apis/plugins'; const { data } = useQuery( getPluginsListWithSchemaQueryOptions({ subsystem: 'some-subsystem', schema: 'schema' }) ); // data shape: { names: string[], originObj: Record<string, any> }Retrieve a specific secret detail
masterUse
getSecretReqto fetch the details of a single secret. You must provide both theidand themanagertype.Parameters:
req: AnAxiosInstance.props: An object containing{ id: string, manager: string }.
// req: AxiosInstance, props: { id: string, manager: string } const secret = await getSecretReq(axiosInstance, { id: 'my-secret-id', manager: 'etcd' });Retrieve a list of secrets
masterUse
getSecretListReqto fetch a paginated list of secrets. The function automatically appliespreParseSecretItemto each item in the list to separate themanagerand theidfrom the composite identifier.// req: AxiosInstance, params: PageSearchType const response = await getSecretListReq(axiosInstance, { page: 1, pageSize: 10 }); // response.list contains items with parsed 'manager' and 'id' fields