Using Kong Ingress Controller Addon

Kong Ingress Controller (KIC) running on your minikube server.

  1. Start minikube

    minikube start

    It will take a few minutes to get all resources provisioned.

    kubectl get nodes

Deploy the Kong Ingress Controller

Enable Kong Ingress Controller via minikube command.

$ minikube addons enable kong

🌟  The 'kong' addon is enabled

Note: this process could take up to five minutes the first time.

Setup environment variables

Next, we will set up an environment variable with the IP address at which Kong is accessible. We can use it to send requests into the Kubernetes cluster.

$ export PROXY_IP=$(minikube service -n kong kong-proxy --url | head -1)
$ echo $PROXY_IP

Alternatively, you can use minikube tunnel command.

# open another terminal window and run
minikube tunnel

# you may need to enter an admin password because minikube need to use ports 80 and 443 

Let’s test if KIC is up and running.

$ curl -v localhost

*   Trying
* Connected to localhost ( port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.77.0
> Accept: */*
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Date: Tue, 25 Jan 2022 22:35:27 GMT
< Content-Type: application/json; charset=utf-8
< Connection: keep-alive
< Content-Length: 48
< X-Kong-Response-Latency: 0
< Server: kong/2.7.0
* Connection #0 to host localhost left intact
{"message":"no Route matched with those values"}%

Creating Ingress object

Let’s create a service. As an example, we use type=ExternalName to point to

echo "
kind: Service
apiVersion: v1
  name: proxy-to-httpbin
  - protocol: TCP
    port: 80
  type: ExternalName
" | kubectl create -f -

Next, we will create the ingress object points to httpbin service.

echo '
kind: Ingress
  name: proxy-from-k8s-to-httpbin
  annotations: "true"
  ingressClassName: kong
  - http:
      - path: /foo
        pathType: ImplementationSpecific
            name: proxy-to-httpbin
              number: 80
' | kubectl create -f -

Let’s test our ingress object.

$ curl -i localhost/foo -H "Host:"

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 4
Connection: keep-alive
X-App-Version: 0.2.4
Date: Tue, 25 Jan 2022 22:44:57 GMT
X-Kong-Upstream-Latency: 1
X-Kong-Proxy-Latency: 1
Via: kong/2.7.0



Note: Read more about KIC and different use cases in official documentation.

Last modified May 6, 2022: Update (8d26f37cf)