-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #374 from devopsfaith/v2.0-dev
Release KrakenD 2.0
- Loading branch information
Showing
43 changed files
with
1,217 additions
and
1,863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/vendor | ||
bench_res | ||
krakend | ||
krakend-alpine | ||
cmd/krakend-integration/krakend-integration | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
FROM debian:buster-slim | ||
ARG GOLANG_VERSION | ||
ARG ALPINE_VERSION | ||
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} as builder | ||
|
||
LABEL maintainer="[email protected]" | ||
RUN apk --no-cache add make gcc musl-dev binutils-gold | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y ca-certificates && \ | ||
update-ca-certificates && \ | ||
rm -rf /var/lib/apt/lists/* | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
ADD krakend /usr/bin/krakend | ||
RUN make build | ||
|
||
RUN useradd -r -c "KrakenD user" -U krakend | ||
|
||
USER krakend | ||
FROM alpine:${ALPINE_VERSION} | ||
|
||
VOLUME [ "/etc/krakend" ] | ||
LABEL maintainer="[email protected]" | ||
|
||
RUN apk add --no-cache ca-certificates && \ | ||
adduser -u 1000 -S -D -H krakend && \ | ||
mkdir /etc/krakend && \ | ||
echo '{ "version": 3 }' > /etc/krakend/krakend.json | ||
|
||
COPY --from=builder /app/krakend /usr/bin/krakend | ||
|
||
USER 1000 | ||
|
||
WORKDIR /etc/krakend | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
|
||
BIN_NAME :=krakend | ||
OS := $(shell uname | tr '[:upper:]' '[:lower:]') | ||
VERSION := 1.4.1 | ||
VERSION := 2.0.0 | ||
GIT_COMMIT := $(shell git rev-parse --short=7 HEAD) | ||
PKGNAME := krakend | ||
LICENSE := Apache 2.0 | ||
VENDOR= | ||
|
@@ -15,10 +16,12 @@ RELEASE := 0 | |
USER := krakend | ||
ARCH := amd64 | ||
DESC := High performance API gateway. Aggregate, filter, manipulate and add middlewares | ||
MAINTAINER := Daniel Ortiz <dortiz@devops.faith> | ||
MAINTAINER := Daniel Ortiz <dortiz@krakend.io> | ||
DOCKER_WDIR := /tmp/fpm | ||
DOCKER_FPM := devopsfaith/fpm | ||
GOLANG_VERSION := 1.16.4 | ||
GOLANG_VERSION := 1.17.8 | ||
GLIBC_VERSION := $(shell sh find_glibc.sh) | ||
ALPINE_VERSION := 3.15 | ||
|
||
FPM_OPTS=-s dir -v $(VERSION) -n $(PKGNAME) \ | ||
--license "$(LICENSE)" \ | ||
|
@@ -47,53 +50,67 @@ RPMNAME=${PKGNAME}-${VERSION}-${RELEASE}.x86_64.rpm | |
all: test | ||
|
||
update_krakend_deps: | ||
go get github.com/luraproject/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
# go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/luraproject/lura/[email protected] | ||
go get github.com/devopsfaith/bloomfilter/[email protected] | ||
go get github.com/devopsfaith/krakend-amqp/[email protected] | ||
go get github.com/devopsfaith/krakend-botdetector/[email protected] | ||
go get github.com/devopsfaith/krakend-cel/[email protected] | ||
go get github.com/devopsfaith/krakend-circuitbreaker/[email protected] | ||
go get github.com/devopsfaith/krakend-cobra/[email protected] | ||
go get github.com/devopsfaith/krakend-cors/[email protected] | ||
go get github.com/devopsfaith/krakend-flexibleconfig/[email protected] | ||
go get github.com/devopsfaith/krakend-gelf/[email protected] | ||
go get github.com/devopsfaith/krakend-gologging/[email protected] | ||
go get github.com/devopsfaith/krakend-httpcache/[email protected] | ||
go get github.com/devopsfaith/krakend-httpsecure/[email protected] | ||
go get github.com/devopsfaith/krakend-influx/[email protected] | ||
go get github.com/devopsfaith/krakend-jose/[email protected] | ||
go get github.com/devopsfaith/krakend-jsonschema/[email protected] | ||
go get github.com/devopsfaith/krakend-lambda/[email protected] | ||
go get github.com/devopsfaith/krakend-logstash/[email protected] | ||
go get github.com/devopsfaith/krakend-lua/[email protected] | ||
go get github.com/devopsfaith/krakend-martian/[email protected] | ||
go get github.com/devopsfaith/krakend-metrics/[email protected] | ||
go get github.com/devopsfaith/krakend-oauth2-clientcredentials/[email protected] | ||
go get github.com/devopsfaith/krakend-opencensus/[email protected] | ||
go get github.com/devopsfaith/krakend-pubsub/[email protected] | ||
go get github.com/devopsfaith/krakend-ratelimit/[email protected] | ||
go get github.com/devopsfaith/krakend-rss/[email protected] | ||
go get github.com/devopsfaith/[email protected] | ||
go get github.com/devopsfaith/krakend-viper@v1.4.0 | ||
go get github.com/devopsfaith/krakend-xml@v1.4.0 | ||
go get github.com/devopsfaith/krakend-viper/[email protected].0 | ||
go get github.com/devopsfaith/krakend-xml/[email protected].0 | ||
make test | ||
|
||
|
||
build: | ||
@echo "Building the binary..." | ||
@go get . | ||
@go build -ldflags="-X github.com/luraproject/lura/core.KrakendVersion=${VERSION}" -o ${BIN_NAME} ./cmd/krakend-ce | ||
@go build -ldflags="-X github.com/luraproject/lura/v2/core.KrakendVersion=${VERSION} \ | ||
-X github.com/luraproject/lura/v2/core.GoVersion=${GOLANG_VERSION} \ | ||
-X github.com/luraproject/lura/v2/core.GlibcVersion=${GLIBC_VERSION}" \ | ||
-o ${BIN_NAME} ./cmd/krakend-ce | ||
@echo "You can now use ./${BIN_NAME}" | ||
|
||
test: build | ||
go test -v ./tests | ||
|
||
# Build KrakenD using docker (defaults to whatever the golang container uses) | ||
build_on_docker: | ||
docker run --rm -it -v "${PWD}:/app" -w /app golang:${GOLANG_VERSION} make build | ||
docker run --rm -it -v "${PWD}:/app" -w /app golang:${GOLANG_VERSION} make -e build | ||
|
||
# Build the container using the Dockerfile (alpine) | ||
docker: | ||
docker build --pull -t devopsfaith/krakend:${VERSION} . | ||
docker build --no-cache --pull --build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} -t devopsfaith/krakend:${VERSION} . | ||
|
||
benchmark: | ||
@mkdir -p bench_res | ||
@touch bench_res/${GIT_COMMIT}.out | ||
@docker run --rm -d --name krakend -v "${PWD}/tests/fixtures:/etc/krakend" -p 8080:8080 devopsfaith/krakend:${VERSION} run -dc /etc/krakend/bench.json | ||
@sleep 2 | ||
@docker run --rm -it --link krakend peterevans/vegeta sh -c \ | ||
"echo 'GET http://krakend:8080/test' | vegeta attack -rate=0 -duration=30s -max-workers=300 | tee results.bin | vegeta report" > bench_res/${GIT_COMMIT}.out | ||
@docker stop krakend | ||
@cat bench_res/${GIT_COMMIT}.out | ||
|
||
builder/skel/%/etc/init.d/krakend: builder/files/krakend.init | ||
mkdir -p "$(dir $@)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,55 @@ | ||
![Krakend logo](https://raw.githubusercontent.com/devopsfaith/krakend.io/master/images/logo.png) | ||
|
||
# KrakenD API Gateway | ||
Ultra-High performance API Gateway with middlewares | ||
# KrakenD | ||
KrakenD is an extensible, ultra-high performance API Gateway that helps you effortlessly adopt microservices and secure communications. KrakenD is easy to operate and run and scales out without a single point of failure. | ||
|
||
**KrakenD Community Edition** (or *KrakenD-CE*) is the binary distribution of [KrakenD](https://www.krakend.io). | ||
**KrakenD Community Edition** (or *KrakenD-CE*) is the open-source distribution of [KrakenD](https://www.krakend.io). | ||
|
||
In this repository, you'll find the utils to build the KrakenD binary yourself. If you want to use KrakenD [download the binary](https://www.krakend.io/download/) | ||
[KrakenD Site](https://www.krakend.io/) | [Documentation](https://www.krakend.io/docs/overview/introduction/) | [Blog](https://www.krakend.io/blog/) | [Twitter](https://twitter.com/krakend_io) | [Downloads](https://www.krakend.io/download/) | ||
|
||
[KrakenD Site](https://www.krakend.io/) | [Documentation](https://www.krakend.io/docs/overview/introduction/) | [Blog](https://www.krakend.io/blog) | [Twitter](https://twitter.com/krakend_io) | ||
## Benefits | ||
|
||
## Features | ||
Some of the features you get with KrakenD are: | ||
- **Easy integration** of an ultra-high performance gateway. | ||
- **Effortlessly transition to microservices** and Backend For Frontend implementations. | ||
- **True linear scalability**: Thanks to its **stateless design**, every KrakenD node can operate independently in the cluster without any coordination or centralized persistence. | ||
- **Low operational cost**: +70K reqs/s on a single instance of regular size. Super low memory consumption with high traffic (usually under 50MB w/ +1000 concurrent). Fewer machines. Smaller machines. Lower budget. | ||
- **Platform-agnostic**. Whether you work in a Cloud-native environment (e.g., Kubernetes) or self-hosted on-premises. | ||
- **No vendor lock-in**: Reuse the best existing open-source and proprietary tools rather than having everything in the gateway (telemetry, identity providers, etc.) | ||
- **API Lifecycle**: Using **GitOps** and **declarative configuration**. | ||
- **Decouple clients** from existing services. Create new APIs without changing your existing API contracts. | ||
|
||
- **Ultra-High performance** API Gateway | ||
- **Backend for Frontend** | ||
- **Efficient**: Super low memory consumption with high traffic (usually under 50MB w/ +1000 concurrent) and even lower with low traffic (under 5MB) | ||
- **Easy to use**: Declaration of endpoints by just writing the `/url/patterns/and/{variables}` | ||
- **Unlimited** number of backends and endpoints associated with each endpoint. The limit is your kernel. | ||
- **Aggregation** of all the data in the backends for a single endpoint | ||
- **Response composition** and data manipulation (capture, groups, renames...) | ||
- **Response filtering** (whitelist and blacklist) | ||
- **Concurrent** API calls to the backend for the same request | ||
- **Simple configuration**: All application configuration and behavior declared in a `krakend.json`. | ||
- **Friendly**: No development needed to build your gateway. Use the Visual API [Designer](https://www.krakend.io/designer/) (UI to generate the `krakend.json`) | ||
- **SSL** | ||
- **HTTP2** ready | ||
- **Circuit breaker** (fail fast and avoid smashing stressed backends) | ||
- **Bursting** on High-load | ||
- **Logging and statistics** of usage | ||
- **API with statistics** | ||
- **Service Discovery**: DNS SRV, ETCD or add your own | ||
- **Multiple encodings** supported (json, XML, RSS or response as single string) | ||
- **Injections via DSL** in the configuration (Martian) | ||
- **Throttling**: Limits of usage in the router and proxy layers. | ||
- **User quota**: Restrict usage of users by IP or custom headers | ||
- **Basic Firewalling**: Restrict connections by host, drop connections on certain limits | ||
- **Automatic load balancing** | ||
- **HTTP Cache** headers | ||
- **In-memory backend response cache** | ||
- Multiple installation options (bin, docker, rpm, deb, brew) | ||
- **Cloud native** | ||
- **Loved by orchestrators** (Kubernetes, Mesos + Marathon, Nomad, Docker Swarm, and others) | ||
- **Secure:** | ||
- Support for SSL | ||
- OAuth client grant | ||
- JSON Web Tokens (JWT) and JSON Object Signing and Encryption (JOSE) | ||
- HTTP Strict Transport Security (HSTS) | ||
- Clickjacking protection | ||
- HTTP Public Key Pinning (HPKP) | ||
- MIME-Sniffing prevention | ||
- Cross-site scripting (XSS) protection | ||
- Cross-origin resource sharing (CORS) | ||
## Technical features | ||
|
||
- **Content aggregation**, composition, and filtering: Create views and mashups of aggregated content from your APIs. | ||
- **Content Manipulation and format transformation**: Change responses, convert transparently from XML to JSON, and vice-versa. | ||
- **Security:**: Zero-trust policy, CORS, OAuth, JWT, HSTS, clickjacking protection, HPKP, MIME-Sniffing prevention, XSS protection... | ||
- **Concurrent calls**: Serve content faster than consuming backends directly. | ||
- **SSL** and **HTTP2** ready | ||
- **Throttling**: Limits of usage in the router and proxy layers | ||
- **Multi-layer rate-limiting** for the end-user and between KrakenD and your services, including bursting, load balancing, and circuit breaker. | ||
- **Telemetry** and dashboards of all sorts: Datadog, Zipkin, Jaeger, Prometheus, Grafana... | ||
- **Extensible** with Go plugins, Lua scripts, Martian, or Google CEL spec. | ||
|
||
For a more nice description of the features have a look in the [website](https://www.krakend.io/features/). | ||
## Gateway documentation | ||
See the [website](https://www.krakend.io) for more information. | ||
|
||
Full, comprehensive documentation is viewable on the KrakenD website: | ||
## Download | ||
KrakenD is [packaged and distributed in several formats](https://www.krakend.io/download/). You don't need to clone this repo to use KrakenD unless you want to tweak and build the binary yourself. | ||
|
||
https://www.krakend.io/docs/overview/introduction/ | ||
## Run | ||
In its simplest form with Docker: | ||
|
||
## Build Requirements | ||
docker run -it -p "8080:8080" devopsfaith/krakend | ||
|
||
- golang 1.11 | ||
Now see [http://localhost:8080/__health](http://localhost:8080/__health). The gateway is listening. Now *CTRL-C* and replace `/etc/krakend/krakend.json` with your [first configuration](https://designer.krakend.io). | ||
|
||
## Build | ||
See the required Go version in the `Makefile`, and then: | ||
``` | ||
make build | ||
``` | ||
|
||
## Building with docker | ||
Or, if you don't have or don't want to install `go`, you can build it using the golang docker container: | ||
|
||
If you don't have or don't want to install `go` you can build it using the golang docker container. | ||
``` | ||
make docker_build | ||
``` | ||
|
||
## FPM | ||
You can set up your fpm docker image to run setting `DOCKER_FPM` on the `Makefile`. | ||
|
||
|
||
## Using the generated packages | ||
The package creates a krakend user to run the service and configures the service to run under systemd. | ||
|
||
## Linux Distributions | ||
* just any Linux (using the `tar.gz`) | ||
* Ubuntu | ||
* Debian | ||
* CentOS/RedHat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.