GithubHelp home page GithubHelp logo

k4k8s's Introduction

Kong setup

This repo shows a setup of using Kong as ingress controller in Kubernetes. It is configured with one endpoint that has rate limiting applied based on the client id for an OAuth Bearer token in the request Authorization header.

The client id is read from the token using a token introspection request to a specified endpoint.

The following steps shows how to run it locally, using Minikube:

  • Build Docker image for Kong, including custom plugins, and make sure the image is available in Minikube:
    $ minikube start
    $ eval $(minikube docker-env)
    $ docker build -t kong-with-local-plugin .
  • Run Kong in k8s:
    $ helm repo add kong https://charts.konghq.com
    $ helm repo update
    $ helm init
    $ helm install -f kong-override.yaml --name kong kong/kong
    $ export PROXY_IP=$(minikube service kong-kong-proxy --url | head -1)
  • Setup echo-server (from here):
    $ kubectl apply -f https://bit.ly/echo-service
  • First, configure introspection_endpoint and introspection_client_credentials in ingress.yaml, then add ingress rule with Kong plugins configured:
    $ kubectl apply -f ingress.yaml

To test it, make some requests and check the returned rate limiting headers:

$ curl -i ${PROXY_IP}/foo # without authorization, rate limiting defaults to client IP
$ curl -i ${PROXY_IP}/foo -H 'Authorization: Bearer <token>' # with authorization, rate limiting will use client id from valid token

k4k8s's People

Contributors

zamzterz avatar

Stargazers

nguyen nam avatar SouthWolf avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.