Kong can easily be provisioned to Openshift cluster using the following steps:
-
Initial setup
bash -c "$(curl -fsSL https://raw.githubusercontent.com/hi-cli/hi-cli/master/bin/install)" hi package install heketi
Download or clone the following repo:
git clone https://github.com/john-deng/kong-openshift.git cd kong-openshift
Create Openshift Project and edit supplemental-group and uid-range
oc new-project gateway-dev oc edit ns gateway-dev
Edit hi.conf, modify heketi_password and heketi_cli_server
vim hi.conf
Create PV and PVC
hi heketi create pv size=4 pvc name=kong-database-claim uid=26
Check if pvc is created
oc get pvc
Enable Container Images that Require Root
oc adm policy add-scc-to-user anyuid system:serviceaccount:gateway-dev:default
Deploy Kong
oc process -f kong-template.yaml -v PROJECT_NAME=gateway-dev -v KONG_DASHBOARD_PASSWORD=password | oc create -f -
The last step, expose service
oc expose svc/kong-dashboard oc expose svc/kong-admin oc expose svc/kong-proxy
-
Usage
Scale up Kong
Open Kong dashboard, after exposed svc/kong-dashboard, you should able to open dashboard on your web browser.
Setting Kong node URL
Add API to gateway
Assume that you've deployed the spring-boot app 'appname' which expose port 8080, then fill below form and proess SAVE button.
- Name: project-name-app-name-api
- Uris: /project-name/app-name/api/
- Upstream url: http://appname.projectname.svc.cluster.local:8080/projectname/appname/api/
Now, let's check the api
http http://kong-proxy-gateway-dev.172.16.5.95.nip.io/projectname/appname/api/health