-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
… required files in order to run the tutorial
Kudos, SonarCloud Quality Gate passed! |
| [Custom Plugins - gRPC](./../bdd/features/api_http_grpc_plugin.feature) | ✅ | - | | ||
| [Custom Plugins - Javascript](./api_definitions/custom_plugin.md) | ✅ | - | | ||
| Custom Plugins - Lua | ⚠️ | Untested | | ||
| Custom Plugins - Python | ✅️ | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth linking to docs/api_definitions/custom_plugin_python/custom_plugin_python.md
from here
"custom_plugin_python.yaml" via the command (assuming the tyk stack has been deployed inside the tyk namespace): | ||
|
||
``` | ||
kubectl apply -f custom_plugin_python.yaml -n tyk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that we shouldn't set path and namespace explicitly in the doc. We might use
- heredoc:
cat <<EOF | kubectl apply -n <namespace> -f -
apiVersion: tyk.tyk.io/v1alpha1
kind: ApiDefinition
metadata:
name: httpbin
spec:
name: httpbin
use_keyless: true
protocol: http
active: true
proxy:
target_url: http://httpbin.org
listen_path: /httpbin
strip_listen_path: true
custom_middleware_bundle: "bundle.zip"
EOF
- or if users have access to repository,
kubectl apply -f ./docs/api_definitions/custom_plugin_python.yaml -n <namespace>
Firstly to create the said bundle we need to run the following command: | ||
|
||
``` | ||
IMAGETAG=v3.2.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command won't run if your directory has no manifest.json
attached to this PR. So, users should be in docs/api_definitions/custom_plugin_python
directory.
``` | ||
|
||
Your bundle should now be accessible locally through the URL http://localhost:8000/bundle.zip, | ||
or through the url http://host.minikube.internal:8000/bundle.zip from within minikube. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may sound silly but why are we mentioning minikube here? The above part indicates that I should see bundle.zip in my current directory
. And after serving it, shouldn't it be accessible only locally? It seems like it shouldn't be accessible via my cluster. Maybe i am missing a feature of minikube 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned it since the gateway needs to be able to access the bundle.zip being served by the python fileserver on the HOST; in minikube, host access is permitted through host.minikube.internal, which is also why the env variable TYK_GW_BUNDLEBASEURL refers to http://host.minikube.internal:8000/.
If the python fileserver was deployed in the minkube cluster, we would simply use the k8s namespacing to refer to the bundle's hosted location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, i see. thanks @JRWu for explanation 👍 should we update doc based on your explanation? it may be helpful for users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes absolutely, I can add some more information to the markdown file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also a bit confused about this. Targeting bundle server http://host.minikube.internal:8000/bundle.zip might work fine locally / in Minikube, but how would it work in production? I need a bundle server right? So that bundle server needs to be deployable to K8s (dockerized) also with a Deployment and Service that the Gateway can target?
## Custom Plugin example using python | ||
|
||
We assume that you already have a developed python plugin with the associated python file and its manifest in JSON. | ||
If not, you can start from the provided examples ("manifest.json" and "middleware.py"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide links to the manifest.json and middleware.py example files.
3046ae9
to
ee2b362
Compare
Description
Added required documentation and examples regarding the custom plugin - python version functionality.
Related Issue
Motivation and Context
A colleague @JRWu tested this functionality himself for a blog post and provided us with the associated documentation and examples.
Test Coverage For This Change
No logic modified, just a documentation update.
Screenshots (if appropriate)
Types of changes
Checklist
master
!master
branch (left side). Also, it would be best if you started your change off our latestmaster
.gofmt -s -w .
go vet ./...
golangci-lint run