• This repository has been archived on 23/Sep/2022
  • Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Scala
  • License
    Other
  • Created over 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple route management API for Skipper

Innkeeper

Innkeeper is a simple route management API for Skipper

When a new instance of Skipper (configured to fetch the routes from Innkeeper) is started, it will connect to Innkeeper, ask for all the routes and initialize its own data structures.

Then, at every x minutes will ask innkeeper for the modified routes and update its internal data structures.

Build Status

Getting started

First, create your application.conf file. One way to do it is by using the sample one:

cp src/main/resources/sample.application.conf src/main/resources/application.conf

Set the oauth.url with your OAuth provider url.

Innkeeper has three different OAuth scopes, configured in the application.conf file also. For more info, see the OAuth chapter.

Innkeeper requires a Postgres DB for operation. For local development, docker can be used to spawn a DB (see below the Postgres chapter).

To run Innkeeper, execute sbt run.

Running the tests

To run the unit test suite, run sbt test. To run the integration test suite, run sbt it:test.

Inserting a new route manually

# create a path for that route
curl -i -XPOST localhost:9080/paths -d '{
    "uri": "/the-uri",
    "host_ids": [1, 2, 3, 4]
}' -H 'Content-Type: application/json' -H 'Authorization: Bearer oauth-token-with-write-scope'

# the response will look like this:
HTTP/1.1 200 OK
{
  "created_by": "user~1",
  "owned_by_team": "team1",
  "host_ids": [1, 2, 3, 4],
  "uri": "/the-uri",
  "id": 6,
  "created_at": "2016-05-30T15:01:48.018"
}

# create a route for that path

curl -i -XPOST localhost:9080/routes -d '{
  "name": "theRoute1",
  "description": "this is a route",
  "activate_at": "2015-10-10T10:10:10",
  "disable_at": "2016-11-11T11:11:11",
  "predicates": [{
    "name": "method",
    "args": [{
        "value": "GET",
        "type": "string"
      }]
  }],
  "path_id": 6,
  "uses_common_filters": true
}' -H 'Content-Type: application/json' -H 'Authorization: Bearer oauth-token-with-write-scope'

Getting all routes

curl http://localhost:9080/routes -H 'Authorization: Bearer oauth-token-with-read-scope'

To see it streaming:

curl -i --limit-rate 3000 http://localhost:9080/routes -H 'Authorization: oauth-token'

Getting last modified routes

curl -i http://localhost:9080/updated-routes/2015-08-21T15:23:05.731 -H 'Authorization: Bearer oauth-token'

Here are more examples

OAuth

A client can have different scopes when calling Innkeeper:

  • read -> the client is allowed to read the routes
  • write -> the client is allowed to create only routes with a full path matcher
  • admin -> the client with this scope is allowed to create routes with a regex matcher

Postgres

For localhost

CREATE ROLE innkeeper superuser login createdb;
ALTER ROLE innkeeper WITH PASSWORD 'innkeeper';

Postgres via docker

It is possible to simply start a docker container with a postgres ready for innkeeper by running:

$ docker run -e POSTGRES_PASSWORD=innkeeper -e POSTGRES_USER=innkeeper -p 5432:5432 postgres:9.4

For the tests, a different DB is used:

$ docker run -e POSTGRES_PASSWORD= -e POSTGRES_USER=innkeepertest -p 5433:5432 postgres:9.4

For users of boot2docker or docker-machine it is also necessary to create a port forwarding. Assuming the docker-machine is named default this can be achieved via:

$ VBoxManage controlvm "default" natpf1 "tcp-port6767,tcp,,6767,,6767"
$ VBoxManage controlvm "default" natpf1 "tcp-port6768,tcp,,6768,,6768"
$ VBoxManage controlvm "default" natpf1 "tcp-port5433,tcp,,5433,,5433"
$ VBoxManage controlvm "default" natpf1 "tcp-port9080,tcp,,9080,,9080"

Acceptance Tests

For docker-machine, on the first run, use the -nat option, to set up the port forwarding.

Copy the sample.application.conf file to the application.conf file.

cp src/main/resources/sample.application.conf src/main/resources/application.conf

To run the acceptance tests, use the acceptance-tests.sh script.

There is a '-fast' option, which will skip the building of the docker image.

Client script - ikc.sh

For development time, it is possible to use scripts/ikc.sh to view/modify innkeeper data. See more details in: scripts/ikc.md

License

Copyright 2015 Zalando SE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

patroni

A template for PostgreSQL High Availability with Etcd, Consul, ZooKeeper, or Kubernetes
Python
6,267
star
2

postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
Go
3,686
star
3

skipper

An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress
Go
3,088
star
4

restful-api-guidelines

A model set of guidelines for RESTful APIs and Events, created by Zalando
CSS
2,605
star
5

zalenium

A flexible and scalable container based Selenium Grid with video recording, live preview, basic auth & dashboard.
Java
2,385
star
6

SwiftMonkey

A framework for doing randomised UI testing of iOS apps
Swift
1,947
star
7

logbook

An extensible Java library for HTTP request and response logging
Java
1,788
star
8

tailor

A streaming layout service for front-end microservices
JavaScript
1,728
star
9

tech-radar

Visualizing our technology choices
1,581
star
10

spilo

Highly available elephant herd: HA PostgreSQL cluster using Docker
Python
1,225
star
11

intellij-swagger

A plugin to help you easily edit Swagger and OpenAPI specification files inside IntelliJ IDEA
Java
1,172
star
12

problem-spring-web

A library for handling Problems in Spring Web MVC
Java
1,031
star
13

nakadi

A distributed event bus that implements a RESTful API abstraction on top of Kafka-like queues
Java
928
star
14

zally

A minimalistic, simple-to-use API linter
Kotlin
903
star
15

problem

A Java library that implements application/problem+json
Java
869
star
16

zalando-howto-open-source

Open Source guidance from Zalando, Europe's largest online fashion platform
799
star
17

go-keyring

Cross-platform keyring interface for Go
Go
689
star
18

gin-oauth2

Middleware for Gin Framework users who also want to use OAuth2
Go
579
star
19

zappr

An agent that enforces guidelines for your GitHub repositories
JavaScript
542
star
20

pg_view

Get a detailed, real-time view of your PostgreSQL database and system metrics
Python
494
star
21

engineering-principles

Our guidelines for building new applications and managing legacy systems
376
star
22

gulp-check-unused-css

A build tool for checking your HTML templates for unused CSS classes
CSS
359
star
23

zmon

Real-time monitoring of critical metrics & KPIs via elegant dashboards, Grafana3 visualizations & more
Shell
355
star
24

expan

Open-source Python library for statistical analysis of randomised control trials (A/B tests)
Python
325
star
25

PGObserver

A battle-tested, flexible & comprehensive monitoring solution for your PostgreSQL databases
Python
316
star
26

riptide

Client-side response routing for Spring
Java
292
star
27

jackson-datatype-money

Extension module to properly support datatypes of javax.money
Java
240
star
28

grafter

Grafter is a library to configure and wire Scala applications
Scala
240
star
29

opentracing-toolbox

Best-of-breed OpenTracing utilities, instrumentations and extensions
Java
180
star
30

elm-street-404

A fun WebGL game built with Elm
Elm
176
star
31

tokens

Java library for conveniently verifying and storing OAuth 2.0 service access tokens
Java
169
star
32

public-presentations

List of public talks by Zalando Tech: meetup presentations, recorded conference talks, slides
165
star
33

python-nsenter

Enter kernel namespaces from Python
Python
139
star
34

faux-pas

A library that simplifies error handling for Functional Programming in Java
Java
132
star
35

dress-code

The official style guide and framework for all Zalando Brand Solutions products
CSS
129
star
36

beard

A lightweight, logicless templating engine, written in Scala and inspired by Mustache
Scala
121
star
37

friboo

Utility library for writing microservices in Clojure, with support for Swagger and OAuth
Clojure
117
star
38

spring-cloud-config-aws-kms

Spring Cloud Config add-on that provides encryption via AWS KMS
Java
99
star
39

zalando.github.io

Open Source Documentation and guidelines for Zalando developers
HTML
86
star
40

failsafe-actuator

Endpoint library for the failsafe framework
Java
52
star
41

package-build

A toolset for building system packages using Docker and fpm-cookery
Ruby
35
star
42

ghe-backup

Github Enterprise backup at ZalandoTech (Kubernetes, AWS, Docker)
Shell
30
star
43

rds-health

discover anomalies, performance issues and optimization within AWS RDS
Go
26
star
44

backstage-plugin-api-linter

API Linter is a quality assurance tool that checks the compliance of API's specifications to Zalando's API rules.
TypeScript
12
star
45

.github

Standard github health files
1
star