### Install httpbin Example Application Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Apply this manifest to install the httpbin example application on your Kubernetes cluster for testing route configurations. ```bash kubectl apply -f https://raw.githubusercontent.com/apache/apisix-ingress-controller/refs/heads/v2.1.0/examples/httpbin/deployment.yaml ``` -------------------------------- ### Install APISIX Ingress Controller using Installer Source: https://github.com/apache/apisix-ingress-controller/blob/master/README.md Applies the generated 'install.yaml' file to install the APISIX Ingress Controller project into the cluster. ```sh kubectl apply -f dist/install.yaml ``` -------------------------------- ### Example Load Balancing Output Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/load-balancing.md Example output showing the distribution of requests between two backend services. ```text httpbin.org: 23, mock.api7.ai: 27 ``` -------------------------------- ### Launch kind Cluster for E2E Tests Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Starts a local Kubernetes cluster using kind, which is required for running end-to-end tests. Ensure kind is installed. ```shell make kind-up ``` -------------------------------- ### Example Response from httpbin Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md This is an example of the JSON response you should receive from the httpbin service after successfully sending a request to the configured route. ```json { "origin": "127.0.0.1" } ``` -------------------------------- ### Install APISIX and APISIX Ingress Controller Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/install.md This command installs both APISIX and the APISIX Ingress Controller into the 'ingress-apisix' namespace. It enables the ingress controller and configures the gateway proxy to create a default service. ```bash helm install apisix \ --namespace ingress-apisix \ --create-namespace \ --set ingress-controller.enabled=true \ --set ingress-controller.apisix.adminService.namespace=ingress-apisix \ --set ingress-controller.gatewayProxy.createDefault=true \ apisix/apisix ``` -------------------------------- ### Build APISIX Ingress Controller Installer Source: https://github.com/apache/apisix-ingress-controller/blob/master/README.md Builds the installer for the APISIX Ingress Controller image, generating an 'install.yaml' file in the 'dist' directory. ```sh make build-installer # IMG=apache/apisix-ingress-controller:dev ``` -------------------------------- ### Install APISIX Ingress Controller Standalone Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/install.md This command installs only the APISIX Ingress Controller, configuring it to use a specific admin service and setting a default admin key. The gateway proxy is also configured to create a default service. ```bash # Set the access address and adminkey for apisix helm install apisix-ingress-controller \ --create-namespace \ -n ingress-apisix \ --set gatewayProxy.createDefault=true \ --set gatewayProxy.provider.controlPlane.auth.adminKey.value=edd1c9f034335f136f87ad84b625c8f1 \ --set apisix.adminService.namespace=apisix-ingress \ --set apisix.adminService.name=apisix-admin \ --set apisix.adminService.port=9180 \ apisix/apisix-ingress-controller ``` -------------------------------- ### Install APISIX and APISIX Ingress Controller (Standalone API-driven mode) Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/install.md Installs APISIX in 'traditional' mode with 'yaml' configuration provider and the APISIX Ingress Controller in API-driven mode. It disables Etcd and ensures the gateway proxy creates a default service. ```bash helm install apisix \ --namespace ingress-apisix \ --create-namespace \ --set apisix.deployment.role=traditional \ --set apisix.deployment.role_traditional.config_provider=yaml \ --set etcd.enabled=false \ --set ingress-controller.enabled=true \ --set ingress-controller.config.provider.type=apisix-standalone \ --set ingress-controller.apisix.adminService.namespace=ingress-apisix \ --set ingress-controller.gatewayProxy.createDefault=true \ apisix/apisix ``` -------------------------------- ### Install APISIX and APISIX Ingress Controller with Helm Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/get-apisix-ingress-controller.md Installs APISIX and the APISIX Ingress Controller in standalone API-driven mode using Helm. This command configures APISIX to use YAML for configuration, disables etcd, enables the ingress controller, and sets the provider type to 'apisix-standalone'. It also ensures the APISIX admin service is in the correct namespace and creates a default Gateway API proxy. ```bash helm repo add apisix https://apache.github.io/apisix-helm-chart helm repo update helm install apisix \ --namespace ingress-apisix \ --create-namespace \ --set apisix.deployment.role=traditional \ --set apisix.deployment.role_traditional.config_provider=yaml \ --set etcd.enabled=false \ --set ingress-controller.enabled=true \ --set ingress-controller.config.provider.type=apisix-standalone \ --set ingress-controller.apisix.adminService.namespace=ingress-apisix \ --set ingress-controller.gatewayProxy.createDefault=true \ apisix/apisix ``` -------------------------------- ### Configure Global Plugin with Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use Gateway API to configure global plugins. This example shows how to set up the clickhouse-logger plugin. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: GatewayProxy metadata: namespace: ingress-apisix name: apisix-config spec: provider: type: ControlPlane controlPlane: # add your control plane connection configuration here # .... plugins: - name: clickhouse-logger config: endpoint_addr: http://clickhouse-clickhouse-installation.apisix.svc.cluster.local:8123 user: quickstart-user password: quickstart-pass logtable: test database: quickstart_db ``` -------------------------------- ### Add and Update Helm Repositories Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/install.md Before installing, ensure your Helm repositories are up-to-date by adding the APISIX chart repository and the Bitnami chart repository, then running 'helm repo update'. ```bash helm repo add apisix https://apache.github.io/apisix-helm-chart helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update ``` -------------------------------- ### Configure Plugin Metadata with Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use Gateway API to configure plugin metadata. This example sets up opentelemetry tracing configuration. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: GatewayProxy metadata: namespace: ingress-apisix name: apisix-config spec: provider: type: ControlPlane controlPlane: # add your control plane connection configuration here # .... pluginMetadata: opentelemetry: { "trace_id_source": "x-request-id", "resource": { "service.name": "APISIX" }, "collector": { "address": "simplest-collector:4318", "request_timeout": 3, "request_headers": { "Authorization": "token" } }, "batch_span_processor": { "drop_on_queue_full": false, "max_queue_size": 1024, "batch_timeout": 2, "inactive_timeout": 1, "max_export_batch_size": 16 }, "set_ngx_var": true } ``` -------------------------------- ### Configure Route Priority and Matching (Gateway API) Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Configure route priority and matching conditions for a route using the Gateway API. This example sets a priority and defines two variable-based match conditions. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: HTTPRoutePolicy metadata: namespace: ingress-apisix name: http-route-policy spec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: httpbin priority: 10 vars: - - http_x_test_name - == - new_name - - arg_test - == - test_name ``` -------------------------------- ### Configure Global Plugin with APISIX CRD Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use APISIX CRD to configure global plugins. This example demonstrates enabling and configuring the clickhouse-logger plugin. ```yaml apiVersion: apisix.apache.org/v2 kind: ApisixGlobalRule metadata: namespace: ingress-apisix name: apisix-global-rule-logging spec: ingressClassName: apisix plugins: - name: clickhouse-logger enable: true config: endpoint_addr: http://clickhouse-clickhouse-installation.apisix.svc.cluster.local:8123 user: quickstart-user password: quickstart-pass logtable: test database: quickstart_db ``` -------------------------------- ### Install CRDs and Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/README.md Installs the Custom Resource Definitions (CRDs) and Gateway API resources into the Kubernetes cluster. ```sh make install ``` -------------------------------- ### Configure Route Priority and Matching (APISIX CRD) Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Configure route priority and matching conditions for a route using the APISIX CRD. This example defines path matching and two expression-based matches for headers and query parameters. ```yaml apiVersion: apisix.apache.org/v2 kind: ApisixRoute metadata: namespace: ingress-apisix name: httpbin spec: ingressClassName: apisix http: - name: httpbin match: paths: - /* exprs: - subject: scope: Header name: X-Test-Name op: Equal value: new_name - subject: scope: Query name: test op: Equal value: test_name backends: - serviceName: httpbin servicePort: 80 ``` -------------------------------- ### Create Consumer with Direct Key-Auth (APISIX CRD) Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Configure a consumer using the APISIX CRD and specify the authentication key directly in the consumer's configuration. This method is suitable for simpler setups. ```yaml apiVersion: apisix.apache.org/v2 kind: ApisixConsumer metadata: namespace: ingress-apisix name: alice spec: ingressClassName: apisix authParameter: keyAuth: value: key: alice-primary-key ``` -------------------------------- ### Removed Legacy APISIX Configuration in v2.0.0 Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/upgrade-guide.md This example shows legacy APISIX configuration fields that have been removed in v2.0.0. These include settings related to the Admin API version, default cluster configuration, and static Admin API configuration. ```yaml apisix: admin_api_version: v3 default_cluster_base_url: "http://127.0.0.1:9180/apisix/admin" default_cluster_admin_key: "" default_cluster_name: "default" ``` -------------------------------- ### Expected Rate Limiting Results Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/rate-limiting.md Example output showing the expected distribution of status codes after simulating traffic. This indicates that a small number of requests were successful, while the majority were rate-limited. ```text "200": 2, "429": 48 ``` -------------------------------- ### Apply Route Configuration Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Apply the created Kubernetes manifest file (e.g., httpbin-route.yaml) to your cluster to create the route. ```bash kubectl apply -f httpbin-route.yaml ``` -------------------------------- ### Configure GatewayClass for APISIX Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Define the GatewayClass resource for APISIX Ingress Controller when using Gateway API. Ensure the controllerName matches your installation. ```yaml apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: namespace: ingress-apisix name: apisix spec: controllerName: apisix.apache.org/apisix-ingress-controller ``` -------------------------------- ### Create a kind Kubernetes cluster Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/get-apisix-ingress-controller.md Use this command to create a local Kubernetes cluster using kind. Ensure Docker is running. ```shell kind create cluster ``` -------------------------------- ### Configure IngressClass for APISIX Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Define the IngressClass resource for APISIX Ingress Controller when using Ingress or APISIX CRD resources. This is typically applied during installation. ```yaml apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: apisix spec: controller: apisix.apache.org/apisix-ingress-controller parameters: apiGroup: apisix.apache.org kind: GatewayProxy name: apisix-config namespace: ingress-apisix scope: Namespace ``` -------------------------------- ### Generate Release Notes Content Source: https://github.com/apache/apisix-ingress-controller/blob/master/releases/README.md Use the `release-tool` to generate the content for release notes. Specify the desired version and output file. ```sh release-tool -l -d -n -t 1.0.0 releases/v1.0.0.toml ``` -------------------------------- ### Build APISIX Ingress Controller from Source Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Compiles the APISIX Ingress controller from its source code. This command should be run from the root of the project directory. ```shell make build ``` -------------------------------- ### Configure Gateway for APISIX Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Set up the Gateway resource for APISIX, specifying the GatewayClass and listener configuration. The port should match the APISIX configuration. ```yaml apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: namespace: ingress-apisix name: apisix spec: gatewayClassName: apisix listeners: - name: http protocol: HTTP port: 80 infrastructure: parametersRef: group: apisix.apache.org kind: GatewayProxy name: apisix-config ``` -------------------------------- ### Run APISIX Ingress Controller Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Executes the compiled APISIX Ingress controller binary. Use the appropriate binary name based on your system's architecture (e.g., _amd64 or _arm64). ```shell ./bin/apisix-ingress-controller_amd64 version ``` -------------------------------- ### Apply Kubernetes Manifests Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/load-balancing.md Apply the created Kubernetes manifest file to your cluster using kubectl. ```shell kubectl apply -f lb-route.yaml ``` -------------------------------- ### Load Docker Images into kind Cluster Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Builds the APISIX Ingress controller Docker image and loads it into the running kind cluster. This is a prerequisite for running end-to-end tests. ```shell make build-image make kind-load-images ``` -------------------------------- ### Configure Route using Ingress Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Create an Ingress resource to route requests to the httpbin service on the /ip path, specifying the APISIX ingressClassName. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: namespace: ingress-apisix name: getting-started-ip spec: ingressClassName: apisix rules: - http: paths: - backend: service: name: httpbin port: number: 80 path: /ip pathType: Exact ``` -------------------------------- ### Create Consumer with Direct Key-Auth (Gateway API) Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use this snippet to create a consumer and directly embed the authentication key within the consumer's configuration. Ensure the consumer and gateway are in the same namespace. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: Consumer metadata: namespace: ingress-apisix name: alice spec: gatewayRef: name: apisix credentials: - type: key-auth name: primary-key config: key: alice-primary-key ``` -------------------------------- ### Gateway API: Apply Configurations Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/key-authentication.md Apply the consumer and route configurations to your Kubernetes cluster using kubectl. ```shell kubectl apply -f consumer.yaml -f httpbin-route.yaml ``` -------------------------------- ### Configure Key-Auth Plugin with Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use a PluginConfig resource to define the key-auth plugin and reference it in an HTTPRoute's filters. Ensure the PluginConfig is in the same namespace as the HTTPRoute. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: PluginConfig metadata: namespace: ingress-apisix name: auth-plugin-config spec: plugins: - name: key-auth config: _meta: disable: false --- apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: namespace: ingress-apisix name: get-ip spec: parentRefs: - name: apisix rules: - matches: - path: type: Exact value: /ip filters: - type: ExtensionRef extensionRef: group: apisix.apache.org kind: PluginConfig name: auth-plugin-config backendRefs: - name: httpbin port: 80 ``` -------------------------------- ### Configure Rate Limiting Plugin on Consumer (Gateway API) Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use this to configure the limit-count plugin for a consumer using the Gateway API. Ensure the consumer and gateway are correctly set up. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: Consumer metadata: namespace: ingress-apisix name: alice spec: gatewayRef: name: apisix credentials: - type: key-auth name: alice-key config: key: alice-key plugins: - name: limit-count config: count: 3 time_window: 60 key: remote_addr key_type: var policy: local rejected_code: 429 rejected_msg: Too many requests show_limit_quota_header: true allow_degradation: false ``` -------------------------------- ### Build Docker Image for APISIX Ingress Controller Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Creates a Docker image for the APISIX Ingress controller. Specify the desired image name and tag using the IMG environment variable. ```shell make build-image IMG=apache/apisix-ingress-controller:dev ``` -------------------------------- ### Plugin Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/api-reference.md Represents a plugin and its configuration. ```APIDOC ## Plugin ### Description Represents a plugin and its configuration. ### Fields - `name` (string) - Name is the name of the plugin. - `config` (JSON) - Config is plugin configuration details. ``` -------------------------------- ### Build APISIX Ingress Controller Image Source: https://github.com/apache/apisix-ingress-controller/blob/master/README.md Builds the Docker image for the APISIX Ingress Controller. Ensure your personal registry is specified and accessible. ```sh make build-image ``` -------------------------------- ### Run Unit Tests Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Executes the unit tests for the APISIX Ingress controller. This helps verify individual components of the controller. ```shell make unit-test ``` -------------------------------- ### Gateway API: Configure GatewayClass and Gateway Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/load-balancing.md Configure GatewayClass and Gateway resources when using Gateway API. Ensure APISIX is configured to listen on the desired port. ```yaml apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: namespace: ingress-apisix name: apisix spec: controllerName: apisix.apache.org/apisix-ingress-controller --- apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: namespace: ingress-apisix name: apisix spec: gatewayClassName: apisix listeners: - name: http protocol: HTTP port: 80 infrastructure: parametersRef: group: apisix.apache.org kind: GatewayProxy name: apisix-config ``` -------------------------------- ### Send Requests and Count Responses Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/load-balancing.md Generate 50 requests to a route and count responses from each backend service to observe load balancing. ```shell resp=$(seq 50 | xargs -I{} curl "http://127.0.0.1:9080/headers" -sL) && \ count_httpbin=$(echo "$resp" | grep "httpbin.org" | wc -l) && \ count_mockapi7=$(echo "$resp" | grep "mock.api7.ai" | wc -l) && \ echo httpbin.org: $count_httpbin, mock.api7.ai: $count_mockapi7 ``` -------------------------------- ### Attach Plugin Configuration to Ingress Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/annotations.md Associate a predefined APISIX plugin configuration with an Ingress resource using the `k8s.apisix.apache.org/plugin-config-name` annotation. This allows for reusable plugin settings. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-plugin-config annotations: k8s.apisix.apache.org/plugin-config-name: "rate-limit-config" spec: ingressClassName: apisix rules: - http: paths: - path: "/" pathType: Prefix backend: service: name: httpbin port: number: 80 --- apiVersion: apisix.apache.org/v2 kind: ApisixPluginConfig metadata: name: rate-limit-config spec: ingressClassName: apisix plugins: - name: limit-count enable: true config: count: 2 time_window: 10 rejected_code: 429 ``` -------------------------------- ### Configure Weighted Services with Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Use this snippet to create a route that proxies traffic to upstream services with specified weights using the Gateway API. Ensure your services are correctly named and ports are specified. ```yaml apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: namespace: ingress-apisix name: httpbin spec: parentRefs: - name: apisix rules: - matches: - path: type: Exact value: /ip backendRefs: - name: httpbin-1 port: 80 weight: 3 - name: httpbin-2 port: 80 weight: 7 ``` -------------------------------- ### Create Kubernetes namespace Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/get-apisix-ingress-controller.md Creates a new Kubernetes namespace named 'ingress-apisix' for APISIX resources. ```shell kubectl create namespace ingress-apisix ``` -------------------------------- ### Check Kubernetes Resource Status Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/get-apisix-ingress-controller.md Use this command to list all resources in the current namespace and verify that pods and deployments are running. ```shell kubectl get all ``` -------------------------------- ### Gateway API: Define HTTPRoute with Key Authentication Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/key-authentication.md Configure an HTTPRoute to proxy requests to httpbin.org and enable key authentication using a PluginConfig. ```yaml apiVersion: v1 kind: Service metadata: namespace: ingress-apisix name: httpbin-external-domain spec: type: ExternalName externalName: httpbin.org --- apiVersion: apisix.apache.org/v1alpha1 kind: PluginConfig metadata: namespace: ingress-apisix name: auth-plugin-config spec: plugins: - name: key-auth config: _meta: disable: false --- apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: namespace: ingress-apisix name: getting-started-ip spec: parentRefs: - name: apisix rules: - matches: - path: type: Exact value: /ip filters: - type: ExtensionRef extensionRef: group: apisix.apache.org kind: PluginConfig name: auth-plugin-config backendRefs: - name: httpbin-external-domain port: 80 ``` -------------------------------- ### View All Synchronized APISIX Configurations Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/troubleshoot.md Send a `curl` request to the APISIX Admin API to view all configurations synchronized to the gateway. Ensure you replace `${ADMIN_API_KEY}` with your actual API key. ```shell curl "http://127.0.0.1:9180/apisix/admin/configs" -H "X-API-KEY: ${ADMIN_API_KEY}" ``` -------------------------------- ### Configure Route using Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/configure-routes.md Create an HTTPRoute resource using Gateway API to forward requests to the httpbin service on the /ip path. ```yaml apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: namespace: ingress-apisix name: getting-started-ip spec: parentRefs: - name: apisix rules: - matches: - path: type: Exact value: /ip backendRefs: - name: httpbin port: 80 ``` -------------------------------- ### APISIX Ingress Controller Configuration Options Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/configuration-file.md This snippet outlines all available configuration options for the APISIX Ingress Controller, including log level, controller name, leader election settings, metrics and probe addresses, HTTP/2 enablement, and provider-specific configurations like sync periods. ```yaml log_level: "info" # The log level of the APISIX Ingress Controller. # The default value is "info". controller_name: apisix.apache.org/apisix-ingress-controller # The controller name of the APISIX Ingress Controller, # which is used to identify the controller in the GatewayClass. # The default value is "apisix.apache.org/apisix-ingress-controller". leader_election_id: "apisix-ingress-controller-leader" # The leader election ID for the APISIX Ingress Controller. # The default value is "apisix-ingress-controller-leader". leader_election: lease_duration: 30s # lease_duration is the duration that non-leader candidates will wait # after observing a leadership renewal until attempting to acquire leadership of a # leader election. renew_deadline: 20s # renew_deadline is the time in seconds that the acting controller # will retry refreshing leadership before giving up. retry_period: 2s # retry_period is the time in seconds that the acting controller # will wait between tries of actions with the controller. disable: false # Whether to disable leader election. metrics_addr: ":8080" # The address the metrics endpoint binds to. # The default value is ":8080". enable_http2: false # Whether to enable HTTP/2 for the server. # The default value is false. probe_addr: ":8081" # The address the probe endpoint binds to. # The default value is ":8081". secure_metrics: false # The secure metrics configuration. # The default value is "" (empty). exec_adc_timeout: 15s # The timeout for the ADC to execute. # The default value is 15 seconds. listener_port_match_mode: "auto" # Mode for injecting server_port route vars from Gateway listener ports. # - "auto": inject when parentRefs explicitly target listeners (sectionName/port) or when multiple listener ports are matched. # - "explicit": inject only when parentRefs explicitly target listeners. # - "off": never inject server_port vars. # The default value is "auto". provider: type: "apisix" # Provider type. # Value can be "apisix" or "apisix-standalone". sync_period: 1h # The period between two consecutive syncs. # The default value is 1 hour, which means the controller will not sync. # If you want to enable the sync, set it to a positive value. init_sync_delay: 20m # The initial delay before the first sync, only used when the controller is started. # The default value is 20 minutes. ``` -------------------------------- ### Enable APISIX Standalone API-Driven Mode Source: https://github.com/apache/apisix-ingress-controller/blob/master/CHANGELOG.md Configure the APISIX Ingress Controller to use the standalone API-driven provider by specifying 'apisix-standalone' in the configuration file. This mode removes the need for ETCD. ```yaml provider: type: "apisix-standalone" ``` -------------------------------- ### Deploy APISIX Ingress Controller Manager Source: https://github.com/apache/apisix-ingress-controller/blob/master/README.md Deploys the APISIX Ingress Controller manager to the cluster using the specified image. RBAC errors may require cluster-admin privileges. ```sh make deploy #IMG=apache/apisix-ingress-controller:dev ``` -------------------------------- ### ApisixGlobalRule Resource Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/api-reference.md Defines configuration for global plugins. ```APIDOC ## ApisixGlobalRule ApisixGlobalRule defines configuration for global plugins. | Field | Description | | --- | --- | | `apiVersion` _string_ | `apisix.apache.org/v2` | | `kind` _string_ | `ApisixGlobalRule` | | `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)_ | Please refer to the Kubernetes API documentation for details on the `metadata` field. | | `spec` _[ApisixGlobalRuleSpec](#apisixglobalrulespec)_ | ApisixGlobalRuleSpec defines the global plugin configuration. | ``` -------------------------------- ### Deploy APISIX Ingress Controller to Kubernetes Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Deploys the APISIX Ingress controller to your Kubernetes cluster using a specified Docker image. Ensure your Kubernetes context is correctly set. ```shell make deploy IMG=apache/apisix-ingress-controller:dev ``` -------------------------------- ### Gateway API PluginConfig and HTTPRoute Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md This snippet demonstrates creating a PluginConfig resource and referencing it within an HTTPRoute using the Gateway API. Ensure the PluginConfig and HTTPRoute are in the same namespace. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: PluginConfig metadata: namespace: ingress-apisix name: example-plugin-config spec: plugins: - name: response-rewrite enable: true config: headers: X-Plugin-Config: "example-response-rewrite" X-Plugin-Test: "enabled" --- apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: namespace: ingress-apisix name: httpbin spec: parentRefs: - name: apisix rules: - matches: - path: type: Exact value: /ip filters: - type: ExtensionRef extensionRef: group: apisix.apache.org kind: PluginConfig name: example-plugin-config backendRefs: - name: httpbin port: 80 ``` -------------------------------- ### Configure Forward Auth Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/annotations.md Sets up an external authentication service for request validation. Configure the auth URI, SSL verification, and header forwarding. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-forward-auth annotations: k8s.apisix.apache.org/auth-uri: "https://auth.example.com/verify" k8s.apisix.apache.org/auth-ssl-verify: "true" k8s.apisix.apache.org/auth-request-headers: "Authorization" k8s.apisix.apache.org/auth-upstream-headers: "X-User-ID,X-User-Role" k8s.apisix.apache.org/auth-client-headers: "X-Auth-Status" spec: ingressClassName: apisix rules: - http: paths: - path: / pathType: Prefix backend: service: name: httpbin port: number: 80 ``` -------------------------------- ### Define Gateway using Gateway API Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/example.md Specify the controller responsible for handling resources before applying further configurations using the Gateway API. Ensure APISIX is configured to listen on the specified port. ```yaml apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: namespace: ingress-apisix name: apisix spec: controllerName: "apisix.apache.org/apisix-ingress-controller" # 1 --- apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: namespace: ingress-apisix name: apisix spec: gatewayClassName: apisix listeners: - name: http protocol: HTTP port: 80 # 2 infrastructure: parametersRef: group: apisix.apache.org # 3 kind: GatewayProxy # 4 name: apisix-config # 5 ``` -------------------------------- ### Enable RegEx Route Matching Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/annotations.md Use the `k8s.apisix.apache.org/use-regex` annotation to enable regular expression matching for Ingress paths. Ensure `pathType` is set to `ImplementationSpecific` when using this annotation. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-regex annotations: k8s.apisix.apache.org/use-regex: "true" spec: ingressClassName: apisix rules: - http: paths: - path: "/users/[0-9]+" pathType: ImplementationSpecific # should use ImplementationSpecific with use-regex backend: service: name: user-service port: number: 80 ``` -------------------------------- ### Send Request With Correct API Key Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/key-authentication.md Send a request to the /ip endpoint with the correct 'apikey' header to test successful authentication. Expect an HTTP 200 OK response. ```shell curl -i "http://127.0.0.1:9080/ip" -H 'apikey: secret-key' ``` -------------------------------- ### Consumer Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/api-reference.md Consumer defines configuration for a consumer. ```APIDOC ## Consumer ### Description Consumer defines configuration for a consumer. ### Kind Consumer ### API Version apisix.apache.org/v1alpha1 ### Fields - `apiVersion` (string) - `apisix.apache.org/v1alpha1` - `kind` (string) - `Consumer` - `metadata` ([ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#objectmeta-v1-meta)) - Please refer to the Kubernetes API documentation for details on the `metadata` field. - `spec` ([ConsumerSpec](#consumerspec)) - ConsumerSpec defines configuration for a consumer, including consumer name, authentication credentials, and plugin settings. ``` -------------------------------- ### Configure Key Authentication Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/reference/annotations.md Apply `keyAuth` authentication to an Ingress resource using the `k8s.apisix.apache.org/auth-type` annotation. Define the authentication key in an `ApisixConsumer` resource. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-key-auth annotations: k8s.apisix.apache.org/auth-type: "keyAuth" spec: ingressClassName: apisix rules: - http: paths: - path: / pathType: Prefix backend: service: name: httpbin port: number: 80 --- apiVersion: apisix.apache.org/v2 kind: ApisixConsumer metadata: name: john spec: ingressClassName: apisix authParameter: keyAuth: value: key: john-key ``` -------------------------------- ### Set Kubernetes context to the new namespace Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/get-apisix-ingress-controller.md Configures kubectl to use the 'ingress-apisix' namespace by default for subsequent commands. ```shell kubectl config set-context --current --namespace=ingress-apisix ``` -------------------------------- ### Gateway API: Define Consumer Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/getting-started/key-authentication.md Create a Kubernetes manifest to define a consumer named 'tom' with a 'key-auth' credential and a 'secret-key'. ```yaml apiVersion: apisix.apache.org/v1alpha1 kind: Consumer metadata: namespace: ingress-apisix name: tom spec: gatewayRef: name: apisix credentials: - type: key-auth name: primary-key config: key: secret-key ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/apache/apisix-ingress-controller/blob/master/docs/en/latest/developer-guide.md Executes the end-to-end tests against the APISIX Ingress controller running in a kind cluster. This verifies the controller's behavior in a simulated production environment. ```shell make e2e-test ```