This repository provides a template for doing your own demonstration of the end to end lifecycle as depicted in the following diagram.
- Clone the kong-plugin-mocking repository to your machine.
- A running instance of Kong EE with the Developer Portal enabled in the default workspace. We are assuming a Docker install.
- Install kong-portal-cli
- Install Helm
- Install PyYAML
- Install decK
- Create your own repository with this template
- Clone your repository
- Run
npm install
in your$PROJECT_ROOT
- Create and run a self hosted Github Action Runner inside your
$PROJECT_ROOT
.
We are assuming you have a local Kubernetes cluster running in docker-desktop or minikube.
- This demo utilizes the Developer Portal, so we are going to run Kong Enterprise on Kubernetes.
- Put a valid license file called "license" inside your
$PROJECT_ROOT/bin
directory. - Create a symbolic link to the kong-plugin-mocking plugin inside
$PROJECT_ROOT
ln -s /path/to/kong-plugin-mocking .
.
- From within the
bin
directory, run./setup_kong.sh
. This may take a few minutes to complete. Thesetup_kong.sh
script will wait for Kong to start and then will enable the Developer Portal after it is started. You should see the following in your terminal when it is finished.
{"comment":null,"created_at":1590088297,"config":{"portal_access_request_email":null,"portal_invite_email":null,"portal_reset_success_email":null,"portal_auth_conf":null,"portal_is_legacy":null,"portal_auth":null,"portal_developer_meta_fields":"[{\"label\":\"Full Name\",\"title\":\"full_name\",\"validator\":{\"required\":true,\"type\":\"string\"}}]","portal_auto_approve":null,"portal":true,"portal_token_exp":null,"portal_emails_reply_to":null,"portal_reset_email":null,"portal_approved_email":null,"portal_emails_from":null,"meta":null,"portal_session_conf":null,"portal_cors_origins":null},"id":"4639737f-d9bc-45c2-8c52-4e37a1627ba8","name":"default","meta":{"color":null,"thumbnail":null}}
- Edit the
bin/add_mocking_plugin.sh
so you have the appropriate Docker containers in thedocker cp
andexec
commands. - Run
add_mocking_plugin.sh
.
- In the feature picker, turn on
ENABLE_CUSTOM_PLUGINS
andENABLE_IMAGE_REBUILD
- this will turn on the mocking plugin. - In your terminal, run
export PORTAL_THEME=freelyDefinableWorkspaces
and select a workspace name aside form default you will use to publish to, for example Marketing. Then,export THEME_WORKSPACES="Marketing"
- Edit .github/actions/portal-deploy-action/docker_deploy.sh - and update line 4 to be:
deck sync --workspace Marketing
- Edit .github/workflows/main.yml and edit the last line to be:
portal deploy Marketing
and editkong-config-type
to bekong-declarative-config
- Make a copy of the
default
directory in/workspaces
named -Marketing
in our example. Check this directory in. - You can now run this Golden Use Case along your regular demo environment in a separate workspace.
- Commit and push your changes. From here, you can run as you would in Docker.
Once your Kong environment is up and running, we are ready to demonstrate the golden use case. In order to do so, we will edit an OpenAPI specification and push the changes to Github. After we push the changes, a 2-step Github Action workflow will execute. The first step will generate a Kong configuration file from the OpenAPI specification using our openapi-2-kong
NodeJS library, and apply it to your running version of Kong using helm or decK. The second step will deploy the OpenAPI specification to the Developer Portal using the portal
command line application.
- Configure workflow to use kong-for-kubernetes. Open
$PROJECT_ROOT/.github/workflows/main.yml
and edit thekong-config-type
input. - Open the
$PROJECT_ROOT/workspaces/default/specs/orders.yaml
file in your favorite text editor. - Edit the example response value however you like. For example, add a "zipcode" field.
- Commit and push your changes.
- Configure workflow to use kong-declarative-config. Open
$PROJECT_ROOT/.github/workflows/main.yml
and edit thekong-config-type
input. - Open the
$PROJECT_ROOT/workspaces/default/specs/orders.yaml
file in your favorite text editor. - Edit the example response value however you like. For example, add a "zipcode" field.
- Commit and push your changes.
After your commit is pushed, the workflow will start. Once the job is complete, verify everything worked properly. Point your browser to Kong Manager on localhost and check to see if is configured properly. You should see a "LCE_Order_API" service, a "LCE_Order_API-path-get" route with the "mocking" plugin installed. You can also goto http://localhost/request/v1/order/ with the host header set to mockbin.org to view the example response specified in the orders OpenAPI specificatino.
- If you get
Error: spawnSync /bin/sh EPERM
, it means your uid needs to be updated in the .github/workflow/main.yml file. If on mac, runid -u
, and insert a new line under thewith:
section with this id. For example:uid: 501
-
Feel free to try out using another plugin in a spec, instead of, or in addition to OIDC:
x-kong-plugin-rate-limiting: enabled: true config: minute: 6 limit_by: ip policy: local
-
If you need credentials for the OIDC path
/v1/order/
you may find them in this doc