I quickly threw this together just to see if I could get it working on my local machine using docker for mac and kubernetes.
It’s pretty rough, but just putting it here in case anyone needs the same info I pulled together.
This is for local testing with NodePort, not for production or cloud use.
I also used postgres.
Kong kubernetes setup documentation here:
https://docs.konghq.com/install/kubernetes/
Steps to set up kong locally using kubernetes and docker for mac
Enable kubernetes with docker for mac
- Click on docker preferences
- Click on the Kubernetes tab
- Select enable kubernetes checkbox and click on the kubernetes radio button
Note: Make sure kubernetes has access to internet, if it does not start up, check internet connection. If you run on a VPN that has strict security firewalls, that might be preventing kubernetes from installing.
Update type to NodePort
In order for kong to run locally you need to update the type from LoadBalancer to NodePort.
Also make sure the kong version you are using is supported by the kong dashboard image. At the time of writing this only kong version under 0.14 are supported. So I updated the version of kong to 0.13 in the yaml scripts.
Updated kong tag to 0.13
Yaml files
Grab the yaml files from here:
https://github.com/CariZa/kubernetes-kong-with-dashboard
Commands:
1 2 3 4 5
| kubectl create -f postgres.yaml
kubectl create -f kong_postgres.yaml
kubectl create -f kong_migration_postgres.yaml |
Check the service ip for
Copy the ip of the kong-admin service and paste it in kong_dashboard.yml as an “args” value, eg:
When you run “$ kubectl get service” you might get this response:
1 2 3 4
| NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
...
kong-admin NodePort 10.101.71.20 <none> 8001:30916/TCP 46m
... |
What you want to take is the CLUSTER-IP and the first part of the PORT(S)
You will add it in the kong_dashboard.yaml file by the args list around line 34:
1
| args: ["start", "--kong-url", "http://10.101.71.20:8001"] |
Then create the kong-dashboard:
1
| kubectl create -f kong_dashboard.yml |
To check if your dashboard runs correctly check the logs.
First get the full pod name for kong-dashboard:
It will be something like **kong-dashboard-86dfddcfdf-qgnhl**
Then check the logs:
eg
1
| kubectl logs kong-dashboard-86dfddcfdf-qgnhl |
You should see
1 2 3 4 5
| Connecting to Kong on http://10.101.71.20:8001 ...
Connected to Kong on http://10.101.71.20:8001.
Kong version is 0.13.1
Starting Kong Dashboard on port 8080
Kong Dashboard has started on port 8080 |
If you only see
1
| Connecting to Kong on http://10.101.71.20:8001 |
It might still be starting up or your internal kong-admin url could be incorrect. Remember the url is the kubernetes internal url.
Test the dashboard works
You should be able to access your kong-dashboard using the service port:
Grab the port by the kong-dashboard service, it will be the second port:
1 2 3 4
| NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
...
kong-dashboard NodePort 10.97.55.180 <none> 8080:30719/TCP 1h
... |
In this case the port value is 30719
So the url will be:
http://localhost:30719
Note
This is for local testing with NodePort, not for production or cloud use.
Screenshots
This is what I a see on my side at the date of publication:
I added a test api entry, pointed to a service I was running on kubernetes:
This is the settings I added for the test:
I got the url but checking the service value:
I get the values:
1
| hello-kubernetes NodePort 10.106.125.184 <none> 8080:30281/TCP 22h |
I used “10.106.125.184” and “8080” as the “upsteam_url”
And I could then access the internal route using the kong-proxy ip and the path I set “/test”
Eg:
http://localhost:32246/test
localhost:32246 -> Kong Proxy url
/test -> The path I told the kong_dashboard to use and redirect to the internal url “10.106.125.184:8080”