Code Monkey home page Code Monkey logo

kong's Introduction

kong

Try at KataCode: https://katacoda.com/vs4vijay/scenarios/kong-with-kubernetes

Getting Start

Kong with Docker

  • Run Kong with Postgres DB:
docker-compose up
  • Run with Konga UI:
docker-compose -f docker-compose.yml -f docker-compose.konga.yml up
  • Stop Kong
docker-compose down

Kong with Kubernetes

  • Acts as north-south traffic gateway
  • Declarative configuration
  • DB-less

Installation:

kubectl apply -f https://bit.ly/k4k8s

kubectl get services -n kong

export PROXY_IP=$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].ip}" service -n kong kong-proxy)

Try Sample Service:

kubectl apply -f https://bit.ly/echo-service


kubectl apply -f - <<DOC
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: viz-request-id
config:
  header_name: viz-request-id
plugin: correlation-id
DOC


kubectl apply -f - <<DOC
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: viz-rate-limit
config:
  minute: 5
  limit_by: ip
  policy: local
plugin: rate-limiting
DOC


kubectl apply -f - <<DOC
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: demo
  annotations:
    konghq.com/plugins: viz-request-id, viz-rate-limit
spec:
  rules:
  - http:
      paths:
      - path: /demo
        backend:
          serviceName: echo
          servicePort: 80
DOC

Notes:

  • Kong Plugins can be applied to k8s Ingress or Service
  • Can use KongClusterPlugin for cluster-level resources

References:


Screenshots

Konga UI

Konga UI


Development Notes

kubectl apply -f https://bit.ly/k8s-httpbin

kubectl patch service ext-httpbin -p '{"metadata":{"annotations":{"konghq.com/plugins":"viz-rate-limit"}}}'

kubectl annotate service httpbin konghq.com/plugins=viz-request-id

kubectl apply -f - <<DOC

DOC

https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/platform/kube/bookinfo.yaml

https://github.com/kubernetes/examples/tree/master/guestbook-go

https://bit.ly/k4k8s
https://bit.ly/echo-service
https://bit.ly/k8s-redis
https://bit.ly/k8s-httpbin
https://bit.ly/kong-ingress-dbless


#####################
# Inline HTTP Server

## Using Python
python -m SimpleHTTPServer
python3 -m http.server

## Using Bash
while true; do nc -l -p 8000 -c 'echo -e "HTTP/1.1 200 OK\n\n $(date)"'; done
while true; do echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -l localhost 8000; done

## Using Ruby
ruby -run -e httpd . -p 8000

## Using PHP
php -S localhost:8000
#####################

export PROXY_IP=$(kubectl get -o jsonpath="{.spec.clusterIP}" service -n kong kong-proxy)

kong's People

Contributors

vs4vijay avatar

Stargazers

 avatar

Watchers

 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.