Chever-John commented on code in PR #994: URL: https://github.com/apache/apisix-ingress-controller/pull/994#discussion_r877763878
########## docs/en/latest/practices/how-to-use-go-plugin-runner-in-apisix-ingress.md: ########## @@ -0,0 +1,207 @@ +--- +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. +# +--> + +## Brief 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. Review Comment: Solved -- 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]
