No description
  • Go 97.5%
  • Makefile 2.1%
  • Dockerfile 0.4%
Find a file
2017-10-18 08:46:55 -04:00
yamls More cleanup and fixing yaml 2017-10-17 23:45:17 -04:00
.gitignore Plugins now supported 2017-10-17 00:08:26 -04:00
controller.go removing logging for now 2017-10-18 08:46:55 -04:00
Dockerfile Update Dockerfile 2017-10-17 11:32:17 -04:00
kongclient.go removing logging for now 2017-10-18 08:46:55 -04:00
kongclient_test.go Added go tests 2017-10-17 23:21:53 -04:00
main.go removing logging for now 2017-10-18 08:46:55 -04:00
Makefile Added go tests 2017-10-17 23:21:53 -04:00
README.md Update README.md 2017-10-17 11:34:39 -04:00
types.go Added go tests 2017-10-17 23:21:53 -04:00
types_test.go Added go tests 2017-10-17 23:21:53 -04:00
utils.go Added go tests 2017-10-17 23:21:53 -04:00
utils_test.go Added go tests 2017-10-17 23:21:53 -04:00

KongK8

Codacy Badge

This project provides a process to watch the Kubernetes API for new services and configure Kong with the new API.

This application will watch for CREATE, UPDATE and DELETE requests for services. If the service being acted on has the "GATEWAY_UPSTREAM" annotation, the process will attempt to configure a Kong instance provided the "KONG_HOST".

Build

Build the main application into an executable called kubeconfig. The make script depends on the minikube implementation providing a registry that is accessible to outside users and building images into that registry.

For information on how to set up a registry for local dev, follow the instructions from this link, disregard the xhyve bits, unnecessary: Local dev with Kubernetes.

Once you have minikube-set up, you will need to start using the minikube docker via; eval $(minikube docker-env)

Now that you have access to the docker within minikube, time to make your container.

make build

Run locally

To run the application locally, you will need to have a configured kubectl on your system.

Run the application by providing the kube configuration file with an absolute path.

On a Unix system, the invocation would be similar to the following;

./kongk8 --kubeconfig=/home/user/.kube/config

Run in Kubernetes

When running in Kubernetes, it is not necessary to provide a kube config, the application will automatically utilize the config that is inherently available to all kube containers.

That said, however, it is important to correctly configure the application to communicate with your Kong host. An example is already configured in the provided kube.yaml as http://kong.default.svc.cluster.local:8001. This is expecting that there is a service definition that exposes port 8001 for the Kong pod via a service with the matching port, 8001. If you expose a different port from the service that maps to the Kong port 8001 that is also fine, adjust your KONG_HOST url accordingly.

Below is an example configuration to run a KubeKongfig pod.

apiVersion: v1
kind: Pod
metadata:
  name: kongfig
  labels:
    run: kongfig
spec:
  containers:
  - image: localhost:5000/ecsquest/konk8
    imagePullPolicy: Always
    name: kongfig
    env:
      - name: KONG_HOST
        value: "http://kong.default.svc.cluster.local:8001"

Additional configuration

It is possible to further configure KubeKongfig with the following environment variables.

Variable Type Default Description
KONG_HOST String http://kube.local The Kong API endpoint
IGNORE_NAMESPACE String

Ingress Annotations

The following annotations can be used to force certain configuration values for the Ingress->Kong mapping

Annotation Default Description
GATEWAY_API_NAME * "" A unique name for the API entry
GATEWAY_UPSTREAM * "" The full URL of the upstream service to direct requests to
GATEWAY_PLUGINS "" Comma separated list of plugins to enable for the given API (Not used yet)
GATEWAY_URIS "" Comma separated list of url paths ig; "/path/foo" to match
GATEWAY_METHODS "" Comma separated list of HTTP VERBS allowed for endpoint
GATEWAY_STRIP_URL "false" If "true", will not provide the full URL path to the upstream service, ig: http://foo.com/fizz/buzz becomes http://my.ns.svc.cluster.local
GATEWAY_PRESERVE_HOST "true"

* Required Annotation