Table of Contents

Kubernetes Ingress Controller for Kong

Install Kong or Kong Enterprise using the official Kubernetes Ingress Controller.

Learn more via the README. To run a local proof of concept, follow the Minikube and Minishift tutorials.

The Kubernetes Ingress Controller for Kong launch announcement is on the Kong Blog.

For questions and discussion, please visit Kong Nation. For bug reports, please open a new issue on GitHub.

Kong via Google Cloud Platform Marketplace

Perhaps the fastest way to try Kong on Kubernetes is via the Google Cloud Platform Marketplace and Google Kubernetes Engine - plus, with Google Cloud Platform’s Free Tier and credit, it will likely be free for you to get started.

  1. Visit https://console.cloud.google.com/marketplace/details/kong/kong
  2. Click “Configure” and follow the on-screen prompts
  3. Refer to https://github.com/Kong/google-marketplace-kong-app/blob/master/README.md for important details regarding exposing the Admin API so that you can configure Kong.

If you were only experimenting, consider deleting your Google Cloud resources once you’ve completed your experiment to avoid on-going Google Cloud usage charges.

Kong via Helm

Install Kong or Kong Enterprise using the official Helm chart.

For questions and discussion, please visit Kong Nation.

Kong via Manifest Files

Kong, or the trial version of Kong Enterprise, can be provisioned on a Kubernetes cluster via the manifest files provided in the Kong Kubernetes repository.

Prerequisites

  1. Download or clone the Kong Kubernetes repository
  2. A Kubernetes cluster

Installation Steps

The Kong Kubernetes repository includes Make tasks run_cassandra, run_postgres and run_dbless for ease of use, but we’ll detail the specific YAML files the tasks use here.

For all variations create the Kong namespace

$ kubectl apply -f kong-namespace.yaml

The next step depends on whether you are going to use Kong with Cassandra, Postgres or without a datastore:

For Cassandra, continue to Cassandra Backed Kong

For Postgres, continue to Postgres Backed Kong

For DB-less mode, continue to Using Kong without a Database

Cassandra Backed Kong

Use the cassandra-service.yaml and cassandra-statefulset.yaml file from this repository to deploy a Cassandra Service and a StatefulSet in the cluster.

$ kubectl apply -f cassandra-service.yaml
$ kubectl apply -f cassandra-statefulset.yaml

Use the kong-control-plane-cassandra.yaml file from this repository to run required migrations and deploy Kong control plane node including the Kong admin api

$ kubectl -n kong apply -f kong-control-plane-cassandra.yaml

Use the kong-ingress-data-plane-cassandra.yaml file from this repository to run the Kong data plane node

$ kubectl -n kong apply -f kong-ingress-data-plane-cassandra.yaml

Continue to Using Datastore Backed Kong

PostgreSQL Backed Kong

Use the postgres.yaml file from the repository to deploy a PostgreSQL Service and a ReplicationController in the cluster:

$ kubectl create -f postgres.yaml

Use the kong-control-plane-postgres.yaml file from this repository to run required migrations and deploy Kong control plane node including the Kong Admin API:

$ kubectl -n kong apply -f kong-control-plane-postgres.yaml

Use the kong-ingress-data-plane-postgres.yaml file from this repository to run the Kong data plane node

$ kubectl -n kong apply -f kong-ingress-data-plane-postgres.yaml

If you are using installing the Kong Enterprise Trial, you will need to continue to Additional PostgreSQL Steps for Kong Enterprise Trial Users. Otherwise, continue to Using Datastore Backed Kong

Using Datastore Backed Kong

First let’s ensure the Kong control plane and data plane are successfully running

kubectl get all -n kong
NAME                           READY   STATUS
pod/kong-control-plane         1/1     Running
pod/kong-ingress-data-plane    1/1     Running

Get access to the Kong Admin API port (if running minikube the below should work):

$ export HOST=$(kubectl get nodes --namespace default -o jsonpath='{.items[0].status.addresses[0].address}')
$ export ADMIN_PORT=$(kubectl get svc --namespace kong kong-control-plane  -o jsonpath='{.spec.ports[0].nodePort}')

If you are installing the Kong Enterprise Trial, you will need to continue to Final Steps for Kong Enterprise Trial Users. Otherwise, continue to configuring a service.

Using Kong without a Database

For declarative / db-less, create a config map using the declarative.yaml sample file from this repository

$ kubectl create configmap kongdeclarative -n kong --from-file=declarative.yaml

Now deploy the Kong dataplane using the kong-dbless.yaml file from this repository

$ kubectl apply -f kong-dbless.yaml

Using Declarative / DB Less Backed Kong

To update declarative / db-less Kong edit the declarative file and then replace the config map

$ kubectl create configmap kongdeclarative -n kong --from-file=declarative.yaml -o yaml --dry-run | kubectl replace -n kong -f -

Now do a rolling deployment using the md5sum of the declarative Kong yaml file

$ kubectl patch deployment kong-dbless -n kong -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"declarative\":\"`md5sum declarative.yaml | awk '{ print $$1 }'`\"}}}}}}"

Get access to the Kong Admin API port (if running minikube the below should work):

$ export HOST=$(kubectl get nodes --namespace default -o jsonpath='{.items[0].status.addresses[0].address}')=
$ export ADMIN_PORT=$(kubectl get svc --namespace kong kong-control-plane  -o jsonpath='{.spec.ports[0].nodePort}')

Continue to db-less and declarative configuration documentation page

Additional PostgreSQL Steps for Kong Enterprise Trial Users

  1. Publish a Kong Enterprise Docker image to your container registry

    Because the Kong Enterprise image is not available on the public Docker container registry, you must publish it to a private repository for use with Kubernetes. While any private repository will work, this example uses the Google Cloud Platform Container Registry, which automatically integrates with the Google Cloud Platform examples in the other steps.

    In the steps below, replace <image ID> with ID associated with your loaded image in docker images output. Replace <project ID> with your Google Cloud Platform project ID.

     $ docker load -i /tmp/kong-docker-enterprise-edition.tar.gz
     $ docker images
     $ docker tag <image ID> gcr.io/<project ID>/kong-ee
     $ gcloud docker -- push gcr.io/demo-cs-lab/kong-ee:latest
    
  2. Add your Kong Enterprise License File

    Edit kong_trial_postgres.yaml and kong_trial_migration_postgres.yaml to replace YOUR_LICENSE_HERE with your Kong Enterprise License File string - it should look like:

     - name: KONG_LICENSE_DATA
       value: '{"license":{"signature":"alongstringofcharacters","payload":{"customer":"Test Company","license_creation_date":"2018-03-06","product_subscription":"Kong Only","admin_seats":"5","support_plan":"Premier","license_expiration_date":"2018-06-04","license_key":"anotherstringofcharacters"},"version":1}}'
    
  3. Use the Kong Enterprise image

    Edit kong_trial_postgres.yaml and kong_trial_migration_postgres.yaml and replace image: kong with image: gcr.io/<project ID>/kong-ee, using the same project ID as above.

  4. Updating Postgres configuration (Optional)

    The migration job assumes that your Postgres instance is located in the default namespace. If you followed the steps above, you can skip this step. If you used a different namespace, you will need to update the configuration. Update kong_trial_migration_postgres.yaml and set the KONG_PG_HOST env variable to postgres.{namespace}.svc.cluster.local so it looks like:

     - name: KONG_PG_HOST
       value: postgres.{namespace}.svc.cluster.local
    

Continue to Using Datastore Backed Kong

Final Steps for Kong Enterprise Trial Users

  1. Deploy Kong Enterprise

    You will need to deploy the kong_trial_* YAML files in the Kong Enterprise Trial directory. using:

     kubectl apply -n kong -f ee-trial/kong_trial_migration_postgres.yaml
     kubectl apply -n kong -f ee-trial/kong_trial_postgres.yaml
    
  2. Access the Enterprise Dashboard

    Once Kong Enterprise is running, you should be able to access the Kong Admin UI. Use the BASH script below to obtain the URL’s.

     hostname="$(kubectl get service kong-admin -n kong -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
     sslhostname="$(kubectl get service kong-admin-ssl -n kong -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
     echo "Access the Admin UI at http://$hostname:8002 or https://$sslhostname:8445."
    

Continue to configuring a service.

Get Updates!

Follow Up:

Get future release notes emailed to you.


Having Trouble? We're Here to Help!