Skip to content

Commit 1e3af14

Browse files
authored
doc: add usage and concept documents (#50)
1 parent bf94229 commit 1e3af14

File tree

12 files changed

+459
-48
lines changed

12 files changed

+459
-48
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ uninstall-gateway-api: ## Uninstall Gateway API CRDs from the K8s cluster specif
194194
kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/$(GATEAY_API_VERSION)/standard-install.yaml
195195

196196
.PHONY: install
197-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
197+
install: manifests kustomize install-gateway-api ## Install CRDs into the K8s cluster specified in ~/.kube/config.
198198
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
199199

200200
.PHONY: uninstall

README.md

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1-
# api7-ingress
2-
// TODO(user): Add simple overview of use/purpose
1+
# api7-ingress-controller
32

43
## Description
5-
// TODO(user): An in-depth paragraph about your project and overview of use
4+
5+
The API7 Ingress Controller allows you to run the API7 Gateway as a Kubernetes Ingress to handle inbound traffic for a Kubernetes cluster. It dynamically configures and manages the API7 Gateway using Gateway API resources.
6+
7+
## Document
8+
9+
* [Quickstart](./docs/quickstart.md)
10+
* [Concepts](./docs/concepts.md)
11+
* [Configuration](./docs/configuration.md)
12+
* [Gateway API](./docs/gateway-api.md)
613

714
## Getting Started
815

916
### Prerequisites
10-
- go version v1.22.0+
11-
- docker version 17.03+.
12-
- kubectl version v1.11.3+.
13-
- Access to a Kubernetes v1.11.3+ cluster.
17+
18+
* go version v1.22.0+
19+
* docker version 17.03+.
20+
* kubectl version v1.11.3+.
21+
* Access to a Kubernetes v1.11.3+ cluster.
1422

1523
### To Deploy on the cluster
24+
1625
**Build and push your image to the location specified by `IMG`:**
1726

1827
```sh
19-
make docker-build docker-push IMG=<some-registry>/api7-ingress:tag
28+
make build-image
2029
```
2130

2231
**NOTE:** This image ought to be published in the personal registry you specified.
2332
And it is required to have access to pull the image from the working environment.
2433
Make sure you have the proper permission to the registry if the above commands don’t work.
2534

26-
**Install the CRDs into the cluster:**
35+
**Install the CRDs & Gateway API into the cluster:**
2736

2837
```sh
2938
make install
@@ -32,28 +41,12 @@ make install
3241
**Deploy the Manager to the cluster with the image specified by `IMG`:**
3342

3443
```sh
35-
make deploy IMG=<some-registry>/api7-ingress:tag
44+
make deploy #IMG=api7/api7-ingress-controller:dev
3645
```
3746

3847
> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin
3948
privileges or be logged in as admin.
4049

41-
**Create instances of your solution**
42-
You can apply the samples (examples) from the config/sample:
43-
44-
```sh
45-
kubectl apply -k config/samples/
46-
```
47-
48-
>**NOTE**: Ensure that the samples has default values to test it out.
49-
50-
### To Uninstall
51-
**Delete the instances (CRs) from the cluster:**
52-
53-
```sh
54-
kubectl delete -k config/samples/
55-
```
56-
5750
**Delete the APIs(CRDs) from the cluster:**
5851

5952
```sh
@@ -73,7 +66,7 @@ Following are the steps to build the installer and distribute this project to us
7366
1. Build the installer for the image built and published in the registry:
7467

7568
```sh
76-
make build-installer IMG=<some-registry>/api7-ingress:tag
69+
make build-installer # IMG=api7/api7-ingress-controller:dev
7770
```
7871

7972
NOTE: The makefile target mentioned above generates an 'install.yaml'
@@ -86,16 +79,9 @@ its dependencies.
8679
Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:
8780

8881
```sh
89-
kubectl apply -f https://raw.githubusercontent.com/<org>/api7-ingress/<tag or branch>/dist/install.yaml
82+
kubectl apply -f dist/install.yaml
9083
```
9184

92-
## Contributing
93-
// TODO(user): Add detailed information on how you would like others to contribute to this project
94-
95-
**NOTE:** Run `make help` for more information on all potential `make` targets
96-
97-
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
98-
9985
## License
10086

10187
Copyright 2024.
@@ -111,4 +97,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
11197
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11298
See the License for the specific language governing permissions and
11399
limitations under the License.
114-

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: api7/api7-ingress-controller
8-
newTag: dev
8+
newTag: dev4

config/samples/config.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
log_level: "info"
1+
log_level: "info" # The log level of the API7 Ingress Controller.
2+
# the default value is "info".
23

3-
controller_name: gateway.api7.io/api7-ingress-controller
4+
controller_name: gateway.api7.io/api7-ingress-controller # The controller name of the API7 Ingress Controller,
5+
# which is used to identify the controller in the GatewayClass.
6+
# The default value is "gateway.api7.io/api7-ingress-controller".
47

5-
leader_election_id: "api7-ingress-controller-leader"
8+
leader_election_id: "api7-ingress-controller-leader" # The leader election ID for the API7 Ingress Controller.
9+
# The default value is "api7-ingress-controller-leader".
610

7-
8-
gateway_configs:
9-
- name: api7
11+
gateway_configs: # The configuration of the API7 Gateway.
12+
- name: api7 # The name of the Gateway in the Gateway API.
1013
control_plane:
11-
admin_key: "a7adm-Bu1gnDLqhX1EBF5x1Tjd5zfqiN8AxZ2niZ0coJ5V9A5bI5ghFI-91cb232c6b3a4b2f940f240fc4fbea4e"
12-
endpoints:
13-
- "http://172.18.0.3:7080/apisix/admin"
14+
admin_key: "${ADMIN_KEY}" # The admin key of the control plane.
15+
endpoints:
16+
- ${ENDPOINT}/apisix/admin # The endpoint of the control plane.
1417
tls_verify: false
1518
addresses: # record the status address of the gateway-api gateway
16-
- "172.18.0.4"
19+
- "172.18.0.4" # The LB IP of the gateway service.
370 KB
Loading

docs/concepts.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Concepts
2+
3+
The API7 Ingress Controller is used to manage the API7 Gateway as either a standalone application or a Kubernetes-based application. It dynamically configures and manages the API7 Gateway using Gateway API resources.
4+
5+
## Architecture
6+
7+
![API7 Ingress Controller Architecture](./assets/images/api7-ingress-controller-architecture.png)
8+
9+
## Kubernetes Resources
10+
11+
### Service
12+
13+
In Kubernetes, a Service is a method to expose network applications running on a set of Pods as network services.
14+
15+
When proxying ingress traffic, API7 Gateway by default directs traffic directly to the Pods instead of through kube-proxy.
16+
17+
### EndpointSlicea
18+
19+
EndpointSlice objects represent subsets (slices) of backend network endpoints for a Service.
20+
21+
The API7 Ingress Controller continuously tracks matching EndpointSlice objects, and whenever the set of Pods in a Service changes, the set of Pods proxied by the API7 Gateway will also update accordingly.
22+
23+
## Gateway API
24+
25+
Gateway API is an official Kubernetes project focused on L4 and L7 routing in Kubernetes. This project represents the next generation of Kubernetes Ingress, Load Balancing, and Service Mesh APIs.
26+
27+
For more information on supporting Gateway API, please refer to [Gateway API](./gateway-api.md).

docs/configure.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Configure
2+
3+
The API7 Ingress Controller is a Kubernetes Ingress Controller that implements the Gateway API. This document describes how to configure the API7 Ingress Controller.
4+
5+
## Example
6+
7+
```yaml
8+
log_level: "info" # The log level of the API7 Ingress Controller.
9+
# the default value is "info".
10+
11+
controller_name: gateway.api7.io/api7-ingress-controller # The controller name of the API7 Ingress Controller,
12+
# which is used to identify the controller in the GatewayClass.
13+
# The default value is "gateway.api7.io/api7-ingress-controller".
14+
15+
leader_election_id: "api7-ingress-controller-leader" # The leader election ID for the API7 Ingress Controller.
16+
# The default value is "api7-ingress-controller-leader".
17+
18+
gateway_configs: # The configuration of the API7 Gateway.
19+
- name: api7 # The name of the Gateway in the Gateway API.
20+
control_plane:
21+
admin_key: "${ADMIN_KEY}" # The admin key of the control plane.
22+
endpoints:
23+
- ${ENDPOINT}/apisix/admin # The endpoint of the control plane.
24+
tls_verify: false
25+
addresses: # record the status address of the gateway-api gateway
26+
- "172.18.0.4" # The LB IP of the gateway service.
27+
```
28+
29+
### Controller Name
30+
31+
The `controller_name` field is used to identify the `controllerName` in the GatewayClass.
32+
33+
```yaml
34+
apiVersion: gateway.networking.k8s.io/v1
35+
kind: GatewayClass
36+
metadata:
37+
name: api7
38+
spec:
39+
controllerName: "gateway.api7.io/api7-ingress-controller"
40+
```
41+
42+
### Addresses
43+
44+
The `addresses` field records the status address of the Gateway.
45+
46+
```yaml
47+
apiVersion: gateway.networking.k8s.io/v1
48+
kind: Gateway
49+
metadata:
50+
name: gateway1
51+
spec:
52+
gatewayClassName: api7
53+
listeners:
54+
- name: http
55+
port: 80
56+
protocol: HTTP
57+
status:
58+
addresses:
59+
- type: IPAddress
60+
value: 172.18.0.4
61+
```

docs/gateway-api.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
# Gateway API
3+
4+
Gateway API is dedicated to achieving expressive and scalable Kubernetes service networking through various custom resources.
5+
6+
By supporting Gateway API, the API7 Ingress controller can realize richer functions, including Gateway management, multi-cluster support, and other features. It is also possible to manage running instances of the API7 gateway through Gateway API resource management.
7+
8+
## Concepts
9+
10+
- **GatewayClass**: Defines a set of Gateways that share a common configuration and behavior. Each GatewayClass is handled by a single controller, although controllers may handle more than one GatewayClass.
11+
- **Gateway**: A resource in Kubernetes that describes how traffic can be translated to services within the cluster.
12+
- **HTTPRoute**: Can be attached to a Gateway to configure HTTP
13+
14+
For more information about Gateway API, please refer to [Gateway API](https://gateway-api.sigs.k8s.io/).
15+
16+
## Gateway API Support Level
17+
18+
| Resource | Core Support Level | Extended Support Level | Implementation-Specific Support Level | API Version |
19+
| ---------------- | ------------------- | ---------------------- | ------------------------------------- | ----------- |
20+
| GatewayClass | Supported | N/A | Not supported | v1 |
21+
| Gateway | Partially supported | Partially supported | Not supported | v1 |
22+
| HTTPRoute | Supported | Partially supported | Not supported | v1 |
23+
| GRPCRoute | Not supported | Not supported | Not supported | v1 |
24+
| ReferenceGrant | Not supported | Not supported | Not supported | v1beta1 |
25+
| TLSRoute | Not supported | Not supported | Not supported | v1alpha2 |
26+
| TCPRoute | Not supported | Not supported | Not supported | v1alpha2 |
27+
| UDPRoute | Not supported | Not supported | Not supported | v1alpha2 |
28+
| BackendTLSPolicy | Not supported | Not supported | Not supported | v1alpha3 |
29+
30+
## HTTPRoute
31+
32+
The HTTPRoute resource allows users to configure HTTP routing by matching HTTP traffic and forwarding it to Kubernetes backends. Currently, the only backend supported by API7 Gateway is the Service resource.
33+
34+
### Example
35+
36+
The following example demonstrates how to configure an HTTPRoute resource to route traffic to the `httpbin` service:
37+
38+
```yaml
39+
apiVersion: gateway.networking.k8s.io/v1
40+
kind: GatewayClass
41+
metadata:
42+
name: api7
43+
spec:
44+
controllerName: "gateway.api7.io/api7-ingress-controller"
45+
46+
---
47+
48+
apiVersion: gateway.networking.k8s.io/v1
49+
kind: Gateway
50+
metadata:
51+
name: api7ee
52+
namespace: default
53+
spec:
54+
gatewayClassName: api7
55+
listeners:
56+
- name: http
57+
protocol: HTTP
58+
port: 80
59+
60+
---
61+
62+
apiVersion: gateway.networking.k8s.io/v1
63+
kind: HTTPRoute
64+
metadata:
65+
name: httpbin
66+
spec:
67+
parentRefs:
68+
- name: api7ee
69+
hostnames:
70+
- backends.example
71+
rules:
72+
- matches:
73+
- path:
74+
type: Exact
75+
value: /get
76+
- path:
77+
type: Exact
78+
value: /headers
79+
backendRefs:
80+
- name: httpbin
81+
port: 80
82+
```

docs/quickstart.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Quickstart
2+
3+
This quickstart guide will help you get started with API7 Ingress Controller in a few simple steps.
4+
5+
## Prerequisites
6+
7+
* Kubernetes
8+
* API7 Dashboard
9+
* API7 Gateway
10+
11+
Please ensure you have deployed the API7 Dashboard control plane.
12+
13+
Note: Refer to the [Gateway API Release Changelog](https://github.com/kubernetes-sigs/gateway-api/releases/tag/v1.0.0), it is recommended to use Kubernetes version 1.25+.
14+
15+
## Installation
16+
17+
Install the Gateway API CRDs:
18+
19+
```shell
20+
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml
21+
22+
```
23+
24+
Install The API7 Ingress Controller:
25+
26+
```shell
27+
kubectl apply -f https://github.com/api7/api7-ingress-controller/releases/download/install.yaml
28+
29+
```
30+
31+
## Test HTTP Routing
32+
33+
Install the GatewayClass, Gateway, HTTPRoute and httpbin example app:
34+
35+
```shell
36+
kubectl apply -f https://github.com/api7/api7-ingress-controller/blob/release-v2-dev/examples/quickstart.yaml
37+
```
38+
39+
Requests will be forwarded by the gateway to the httpbin application:
40+
41+
```shell
42+
curl http://{api7_gateway_loadbalancer_ip}/headers
43+
```
44+
45+
:::Note If the API7 Gateway service without loadbalancer
46+
47+
You can forward the local port to the API7 Gateway service with the following command:
48+
49+
```shell
50+
# Listen on port 9080 locally, forwarding to 80 in the pod
51+
kubectl port-forward svc/${api7-gateway-svc} 9080:80 -n ${api7_gateway_namespace}
52+
```
53+
54+
Now you can send HTTP requests to access it:
55+
56+
```shell
57+
curl http://localhost:9080/headers
58+
```
59+
60+
:::

0 commit comments

Comments
 (0)