Code Monkey home page Code Monkey logo

kong-ingress's Introduction

Kong Ingress [Deprecated]

Notice

I think this project fullfiled his goal of providing an unofficial ingress controller for Kong. Right now there's an official project under development and I invite everyone interested to check it out: https://github.com/Kong/kubernetes-ingress-controller.


It's a Kubernetes Ingress Controller for Kong which manages Kong apis for each existent host on ingresses resources.

What's an Ingress Controller

An Ingress Controller is a daemon, deployed as a Kubernetes Pod, that watches the apiserver's /ingresses endpoint for updates to the Ingress resource. Its job is to satisfy requests for ingress.

Important Note

  • This is a work in progress project.
  • It relies on a beta Kubernetes resource.

Overview

Kong it's an API Gateway that deals with L7 traffic, the ingress uses the kong admin API for managing the apis resources. Each existent host on an ingress spec could map several apis on Kong enabling path based routing. The main object of this controller is to act as an orchestrator of domains and routes on Kong. Load balancing between containers could be achieved using Services. To expose your routes outside of the cluster, choose between a publish service type on Kubernetes.

Domain Claims

Some of the main problems of using name based virtual hosting with ingress is that you can't know who's the owner of a specific host, thus a Kong api could be updated by multiple ingress resources resulting in an unwanted behaviour.

A Custom Resource Definition is used to allow the kong ingress to lease domains for each host specified on ingress resources. If a domain is already claimed in the cluster, the controller rejects the creation of apis on Kong.

Read more about Domain Claims.

In the future this probally will change if the Ingress Claim Proposal move forward.

More Info:

Controller Scope

The controller watches for all ingress resources of the cluster, meaning that it's not necessary to install multiple instances of the controller by namespace.

Prerequisites

  • Kubernetes cluster v1.7.0+
  • Kubernetes DNS add-on
  • Kong server v0.10.0+

Quick Start - Minikube

The example above installs Kong and the Ingress Controller in the default namespace. It's recommended to install the components in a custom namespace to facilitate administration.

  1. Follow the Kong Kubernetes Tutorial to install a Kubernetes cluster with Kong
  2. Install RBAC (optional)

If RBAC is in place, users must create RBAC rules for the ingress controller:

kubectl create -f ./examples/rbac/cluster-role.yaml
kubectl create -f ./examples/rbac/cluster-role-binding.yaml

It will enable access only to the default Service Account and only to the required resources. Note: The cluster role binding namespace defaults to kong-system, make sure to change if you're installing in a different namespace.

  1. Install the Kong Ingress Controller
kubectl create -f ./examples/deployment.yaml

After all pods are in the Running state, begin to create your routes. The example above creates two distinct deployments and expose then using services as web and hello:

# An example app
kubectl create -f - <<EOF
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: nginx:1.7.9
        ports:
        - containerPort: 80
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
      - name: hello
        image: tutum/hello-world
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      name: http
  selector:
    app: web
---
apiVersion: v1
kind: Service
metadata:
  name: hello
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      name: http
  selector:
    app: hello
EOF
  1. The ingress resource below will create 4 routes at Kong, one route for each path
# The ingress resource mapping the routes
kubectl create -f - <<EOF
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: acme-routes
  annotations:
    kolihub.io/acme.local: primary
spec:
  rules:
  - host: acme.local
    http:
      paths:
      - path: /
        backend:
          serviceName: web
          servicePort: 80
  - host: duck.acme.local
    http:
      paths:
      - path: /
        backend:
          serviceName: web
          servicePort: 80
  - host: marvin.acme.local
    http:
      paths:
      - path: /web
        backend:
          serviceName: web
          servicePort: 80
      - path: /hello
        backend:
          serviceName: hello
          servicePort: 80
EOF
  1. Expose Kong Proxy and access the services
kubectl -n kong-system patch service kong-proxy -p '{"spec": {"externalIPs": ["'$(minikube ip)'"]}}'

Assuming the domains are mapped in /etc/hosts file, it's possible to access the services through Kong at:

  • http://acme.local:8000
  • http://duck.acme.local:8000
  • http://marvin.acme.local:8000/web
  • http://marvin.acme.local:8000/hello

You could perform a HTTP request with CURL and use the Host header to fake the access to a specific route:

curl http://$(minikube ip):8000/web -H 'Host: marvin.acme.local'

Known Issues/Limitations

  • Removing a namespace from the delegates field in a domain resource will not trigger an update to the child resources
  • It's possible to register a "subdomain" as primary, thus an user could register a subdomain which he doesn't own, e.g.: coyote.acme.org
  • Removing an ingress resource doesn't remove the associated Kong routes

Read more at docs.

kong-ingress's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kong-ingress's Issues

Check supported images using regexp

We should check supported images using regular expression. There are situations where we want to use -alpha -beta or -rcX images.

F0823 15:49:33.844585       1 main.go:123] failed retrieving kong version: failed converting version: strconv.Atoi: parsing "0rc2": invalid syntax

automated builds

We should automate the process of building the code and releasing early and release versions of the code.

  • Tag latest should contain the latest version of the code.
  • Tag master should contain the latest version of the code in master branch.
  • Tag development should contain the latest version of the code in development branch.
  • Tags following Semantic versioning contain the release version of the code.

Deprecate TPR

A new API object type called a Custom Resource Definition (CRD) will replace the existing Third Party Resource (TPR) extension mechanism over the next Kubernetes releases.

This issue is to track the transition between TPR to CRD

Unit test controller

Every logic must be unit tested to ensure better code consistency and enable others to contribute with the project.

Support for http2/grpc

I can see that kong seemingly supports http-2, but kong-ingress may be behind.
Certainly my attempt at a grpc connection yields:
error => { Error: Trying to connect an http1.x server

Would that be a known issue?

Event message with wrong host format

When host parameter is wrong we're getting the following event:

Field 'host' in wrong format, expecting: [name].[namespace].[domain.tld]

The expected is

Field 'host' in wrong format, expecting: [name]-[namespace].[domain.tld]

ingress not recovering after bad spec sent

Steps to reproduce the issue:

  1. Create a spec file with an unsupported host:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nodejs-app
  namespace: personal-bunny-acme
spec:
  rules:
  - host: nodejs-app.personal-bunny-acme.kolihub.io
    http:
      paths:
      - path: /
        backend:
          serviceName: nodejs-app
          servicePort: 80
  1. Try to edit the spec. fixing the spec.rules.host value to nodejs-app-personal-bunny-acme.kolihub.io. The API will not be created on kong.

  2. Further you can even try to delete the ingress and try to create it again with the proper host value. You won't be able to.

To fix you must delete the Ingress Pod and create the ingress again but with the correct specs.

not able to connect kong proxy

followed steps what ever specified in docs and domains, kong wit postgres running. and exposed kong deployment as proxy on 8000, added apps (web and hello) with ingress. but, not able to connect web/hello apps.

trying this "http://acme.local:8000" outside and getting "This site can’t be reached" and even no logs observed in ingress and kong (/usr/local/kong/logs/) pods. What could be the issue? how to debug this issues.

does not re-sync a route that went down but now is up

So, I register a new route, and re-deploy kong-ingress, API got registered, and my MS that gets traffic from that route, works.
If that MS has some issue or stops working, API will get unregistered, but when it gets resolved (or we re-deploy that MS), kong-ingress will not re-register that API, therefor our MS will not work. We end up re-deploying kong-ingress, which get this API registered again and MS working again.

This is what I found on kong-ingress pod:
I0416 14:11:24.398947 1 utils.go:90] Syncing ms/MSNAME
I0416 14:11:24.399137 1 controller.go:189] ms/MSNAME - gc=true, service resource doesn't exists
I0416 14:27:22.775073 1 utils.go:90] Syncing ms/MSNAME

Am I missing something? Is there a proper way of doing this?

We are using image quay.io/koli/kong-ingress:v0.4.0-alpha
kubernetes version v1.8.7

Thanks in advance!

Global configuration for API defaults

The ingress deals with new routes providing only the required fields. To change an API configuration of a route it's a manual process.
The Pull Request #24 introduces a way of configuring the strip_uri attribute using an ingress annotation.

Instead of specifying an annotation for each ingress resource, I propose a global configuration for defining default values for API routes, and annotations could be used to override those defaults.

E.g.:

Binary args

# In this example each route will be provisioned with those values
./kong-ingress --strip-uri=false --preserve-host=true --retries=10

Or environment variable configuration

STRIP_URI=false
PRESERVE_HOST=true

Reference: https://getkong.org/docs/0.11.x/admin-api/#add-api

GO import package

current some packages starts with "kolihub.io/kong-ingress/pkg...".
This should better work with this import "github.com/koli/kong-ingress/pkg..." ?

After "go get github.com/koli/kong-ingress" and change the package i can build without any error.

cannot create namespaces at the cluster scope

When i enabled RBAC in kubernetes ,i get error as below:

Failed creating default namespace [User "system:serviceaccount:kong-system:default" cannot create namespaces at the cluster scope. (post namespaces)]

Domains and CSD are not deleting

Trying to delete CSD (domains.platform.koli.io) and domains ("acme-org") by using below commands:
kubectl delete domain acme-org --force
kubectl delete customresourcedefinition domains.platform.koli.io --force

Some how, these are not deleting, kubectl describe csd domains.platform.koli.io gives below information,

$ kubectl describe customresourcedefinition domains.platform.koli.io
Name: domains.platform.koli.io
Namespace:
Labels:
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"apiextensions.k8s.io/v1beta1","kind":"CustomResourceDefinition","metadata":{"annotations":{},"name":"domains.platform.koli.io","namespac...
API Version: apiextensions.k8s.io/v1beta1
Kind: CustomResourceDefinition
Metadata:
Creation Timestamp: 2017-12-02T20:50:19Z
Deletion Grace Period Seconds: 0
Deletion Timestamp: 2017-12-03T17:10:37Z
Finalizers:
customresourcecleanup.apiextensions.k8s.io
Generation: 1
Resource Version: 225770
Self Link: /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/domains.platform.koli.io
UID: 689e052b-d7a2-11e7-9912-fa163ee34aab
Spec:
Group: platform.koli.io
Names:
Kind: Domain
List Kind: DomainList
Plural: domains
Singular: domain
Scope: Namespaced
Version: v1
Status:
Accepted Names:
Kind: Domain
List Kind: DomainList
Plural: domains
Singular: domain
Conditions:
Last Transition Time:
Message: no conflicts found
Reason: NoConflicts
Status: True
Type: NamesAccepted
Last Transition Time: 2017-12-02T20:50:19Z
Message: the initial names have been accepted
Reason: InitialNamesAccepted
Status: True
Type: Established
Last Transition Time:
Message: could not confirm zero CustomResources remaining: timed out waiting for the condition
Reason: InstanceDeletionCheck
Status: True
Type: Terminating
Events:

Am I doing anything wrong here, how to cleanup these CSD's ? any best practices?

Add support for custom ports on ingress

The kong-ingress doesn't support custom ports, if the ingress contain any port distinct than 80 or 443 it's doesn't append the port when the upstream URL is constructed.

Related #16

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.