tao12345666333 commented on code in PR #994: URL: https://github.com/apache/apisix-ingress-controller/pull/994#discussion_r874998170
########## docs/en/latest/practices/how-to-use-go-plugin-runner-in-apisix-ingress.md: ########## @@ -0,0 +1,215 @@ +--- +title: How to use go-plugin-runner with APISIX Ingress +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## Proposal Description Review Comment: This is not a proposal, right? ########## docs/en/latest/practices/how-to-use-go-plugin-runner-in-apisix-ingress.md: ########## @@ -0,0 +1,215 @@ +--- +title: How to use go-plugin-runner with APISIX Ingress +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## Proposal Description + +Based on version 0.3 of the go-plugin-runner plugin and version 1.4.0 of APISIX Ingress, this article goes through steps as follows: + +1. Prepare the environment (example as follows); +2. Create the cluster; +3. Build a container image that includes the go-plugin-runner; +4. Customize the helm chart package; +5. Install and Deploy; +6. Verify the function. + +It is guaranteed that the final result can be derived in full based on this environment example as follows: + +```bash +go-plugin-runner: 0.3 +APISIX Ingress: 1.4.0 +kind: v0.12.0 +kubectl version(Client/Server): v1.23.5/v1.23.4 +golang: 1.18 +``` + +## Begin + +### Build a cluster environment + +Select `kind` to build a local cluster environment. The command is as follows: + +```bash +cat <<EOF | kind create cluster --config=- +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP +EOF +``` + +### Build the go-plugin-runner executable + +Choose a folder address `/home/chever/api7/cloud_native/tasks/plugin-runner` and place our `apisix-go-plugin-runner` project in this folder. Then you need to go to the `apisix-go-plugin-runner/cmd/go-runner/plugins` directory and write the plugins you need in that directory. + +After writing the plugins, start compiling the executable formally, and note here that you should build **static executables**, not dynamic ones. + +The package compile command is as follows. + +```bash +CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' . +``` + +This successfully packages a statically compiled `go-runner` executable in the `apisix-go-plugin-runner/cmd/go-runner/` directory. + +Please remember the path `apisix-go-plugin-runner/cmd/go-runner/go-runner`, we will use it later. + +### Build Docker Image + +The image is built here in preparation for installing APISIX later using `helm`. + +#### Write Dockerfile + +Return to the path `/home/chever/api7/cloud_native/tasks/plugin-runner` and create a Dockerfile in that directory, a demonstration of which is given here. + +```dockerfile +# DockerfileForRunner +FROM apache/apisix:2.13.1-alpine + +COPY ./apisix-go-plugin-runner /usr/local/apisix-go-plugin-runner +``` + +Here I will again emphasize the path address as follows where the executable file is located. + +```bash +/usr/local/apisix-go-plugin-runner/cmd/go-runner/go-runner +``` + +Please make a note of this address. We will use it in the rest of the configuration. + +#### Begin to build Docker Image + +Start building a Docker image based on the Dockerfile. The command is executed in the `/home/chever/api7/cloud_native/tasks/plugin-runner` directory. The command is as follows: + +```bash +docker build -t apisix/forrunner:0.1 . +``` + +Command Explanation: Build an image with the name `apisix/forrunner` and mark it as version 0.1. + +#### Load the image to the cluster environment + +```bash +kind load docker-image apisix/forrunner:0.1 +``` + +Load the image into the kind cluster environment to pull the custom local image for installation during the helm installation. + +### Install APISIX Ingress + +#### Create namespace + +Before installation, create namespaces with the following command: + +```bash +kubectl create ns ingress-apisix Review Comment: inconsistent here and below. In addition, since you have passed --create-namespace , there is no need to create ns in advance -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
