krakend / krakend-ce Goto Github PK
View Code? Open in Web Editor NEWKrakenD Community Edition: High-performance, stateless, declarative, API Gateway written in Go.
Home Page: https://www.krakend.io
License: Apache License 2.0
KrakenD Community Edition: High-performance, stateless, declarative, API Gateway written in Go.
Home Page: https://www.krakend.io
License: Apache License 2.0
HI,
I've just discovered that in released version of krakend-ce (0.4.0) is dependency of krakend-martian, which is marked as non production ready:
https://github.com/devopsfaith/krakend-ce/blob/67fbdd4ea9e820a0bae9b27aac06a1a70f6608c5/backend_factory.go#L30
https://github.com/devopsfaith/krakend-martian
I think that means one of two: Krakend-ce is not production ready, or krakend-martian is production ready
... so the krakend/krakend-jose#13 is included in the next release
Include the CORS middleware in the next release of KrakenD-CE:
http://github.com/devopsfaith/krakend-cors
Relates to #15
This is my config:
{
"version": 2,
"name": "My lovely gateway",
"port": 8008,
"cache_ttl": "3600s",
"timeout": "3s",
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND-sequential]",
"syslog": false,
"stdout": true
}
},
"endpoints": [
{
"endpoint": "/gcapi/pmall.goods.Goods_backStage/ViewById",
"headers_to_pass": [
"*"
],
"output_encoding": "json",
"method": "POST",
"backend": [
{
"url_pattern": "/gcrpc/pmall.goods.Goods_backStage/ViewById",
"encoding": "no-op",
"host": [
"http://127.0.0.1:61020"
]
},
{
"url_pattern": "/gcrpc/pmall.category.Category_backstage/ViewById/{{resp0_category_id}}",
"encoding": "no-op",
"host": [
"http://127.0.0.1:61020"
]
}
],
"extra_config": {
"github.com/devopsfaith/krakend/proxy": {
"sequential": true
}
}
}
]
}
go run cmd/krakend-ce/main.go check -d -c ./krakend_proxy.json
get this error:
Parsing configuration file: ./krakend_proxy.json
Parsed configuration: CacheTTL: 1h0m0s, Port: 8008
Hosts: []
Extra (1):
github_com/devopsfaith/krakend-gologging: map[stdout:true level:DEBUG syslog:false prefix:[KRAKEND-sequential]]
Endpoints (1):
Endpoint: /gcapi/pmall.goods.Goods_backStage/ViewById, Method: POST, CacheTTL: 1h0m0s, Concurrent: 1, QueryString: []
Extra (1):
github.com/devopsfaith/krakend/proxy: map[sequential:true]
Backends (2):
URL: /gcrpc/pmall.goods.Goods_backStage/ViewById, Method: POST
Timeout: 3s, Target: , Mapping: map[], BL: [], WL: [], Group:
Hosts: [http://127.0.0.1:61020]
Extra (0):
URL: /gcrpc/pmall.category.Category_backstage/ViewById/{{resp0_category_id}}, Method: POST
Timeout: 3s, Target: , Mapping: map[], BL: [], WL: [], Group:
Hosts: [http://127.0.0.1:61020]
Extra (0):
ERROR parsing the configuration file.
Too many output params! input: map[resp0_category_id:<nil>], output: [resp0_category_id]
Include the krakend-newrelic module
Hi, first I would like to say that krakend looks really awesome - this is the kind of software I love! Slick, quick, minimal stack, but great features, smart configuration, simply brilliant! I was researching a few of the api gateway monstrosities that exist and I believe krakend can easily lead the pack! Thank you very much for your efforts and for making this a real open source project!
Please allow me to add some issues / ideas to make it even more awesome!
This first one is already very clear from the issue title, so I took the opportunity to show my appreciation here :)
Hi!
I want to set-up KrakenD to authenticate API calls using JWT. Is it right to check tokens on gateway and if it right forward requests to backend endpoint, or I need to verify token on each service?
What is the right strategy to implement this?
Hi there,
On start up I always get this error message
ERROR Unable to load custom config from the extra config
I am not sure what is wrong with the configuration. I always get http response code 500 when I try to access the resource. I believe it is related to that error message on start up.
Following situation:
Resources
http://192.168.178.44:8000/posts
Log
[GIN] 2018/06/25 - 23:56:18 | 500 | 8.315425ms | 192.168.178.44 | GET /posts
Why do I always get the 500 error? It should work! Appreciate your help.
Thanks
Config file created with the designer:
{
"version": 2,
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
},
"krakendesigner": {
"endpoint_defaults": {
"github.com/devopsfaith/krakend-ratelimit/juju/router": {
"maxRate": 0,
"clientMaxRate": 0
}
}
},
"github_com/devopsfaith/krakend-etcd": {
"dial_timeout": "5s",
"dial_keepalive": "30s",
"header_timeout": "1s"
},
"github_com/devopsfaith/krakend-oauth2-clientcredentials": {
"is_disabled": true,
"endpoint_params": {}
},
"github_com/devopsfaith/krakend-httpsecure": {
"disable": true,
"allowed_hosts": [],
"ssl_proxy_headers": {}
},
"github_com/devopsfaith/krakend-opencensus": {
"sample_rate": 100,
"reporting_period": 1,
"exporters": {}
}
},
"output_encoding": "json",
"read_timeout": "0s",
"write_timeout": "0s",
"idle_timeout": "0s",
"read_header_timeout": "0s",
"timeout": "3000ms",
"cache_ttl": "300s",
"name": "Consul",
"sd_providers": {
"providers": {
"dns": false,
"static": true,
"custom": false
},
"hosts": [
{
"sd": "static",
"host": "http://192.168.178.44:8000"
}
]
},
"endpoints": [
{
"endpoint": "/posts",
"method": "GET",
"output_encoding": "json",
"concurrent_calls": 1,
"extra_config": {
"github.com/devopsfaith/krakend-httpsecure": {
"disable": true,
"allowed_hosts": [],
"ssl_proxy_headers": {}
},
"github.com/devopsfaith/krakend-ratelimit/juju/router": {
"maxRate": 0,
"clientMaxRate": 0
}
},
"backend": [
{
"url_pattern": "/posts",
"encoding": "json",
"extra_config": {
"github.com/devopsfaith/krakend-oauth2-clientcredentials": {
"is_disabled": true,
"endpoint_params": {}
}
},
"sd": "static",
"host": [
"http://192.168.178.44:8000"
],
"disable_host_sanitize": false
}
]
}
],
"disable_rest": false
}
I don't see any documentation on KrakenD being cluster aware. For example, is there some documentation on implementing rate limiting on a service that is on two KrakenD instances that are in a cluster?
Hi everyone,
I'm following KrakenD documentation in order to implement a working example of forcing requests to provide a token issued by a third party.
https://www.krakend.io/docs/authorization/jwt-validation/
My main issue is that I have to set every role that a given protected resource allows by using "roles_key" and "roles" keys:
roles_key: When passing roles, the key name inside the JWT payload specifying the role of the user.
roles: list. When set, the JWT token not having at least one of the listed roles are rejected.
Is there any way to set this roles dynamically by using a properties file or an external configuration file? I'm asking this because it would give the opportunity to change access policies using an UI or any given service.
Thanks in advance.
The flexible configuration is correctly logging the fatal errors when the passed configuration has syntax problems, but KrakenD-CE starts the service with whatever configuration is left.
This might lead to problems and if the configuration has issues the execution should abort.
E.g:
$ FC_ENABLE=1 FC_SETTINGS="$PWD/config/settings" FC_PARTIALS="$PWD/config/partials" \
krakend run -d -c "$PWD/config/krakend.json"
error procesing settings: &{service.json 44 420 {60488472 63676398574 0x227c9e0} {16777220 33188 1 10744684 501 20 0 [0 0 0 0] {1540801786 877794360} {1540801774 60488472} {1540801774 60488472} {1540752956 505953760} 44 8 4194304 0 0 0 [0 0]}} unexpected end of JSON input
Parsing configuration file: /Users/artomb/git/devopsfaith/krakend-test-dummy-backend/config/krakend.json
ERROR: unable to create the gologgin logger: getting the extra config for the krakend-gologging module
WARNING: building the etcd client: unable to create the etcd client: no config
DEBUG: creating a new influxdb client
DEBUG: no config fot the influxdb client. aborting
ERROR: Unable to load custom config from the extra config
ERROR: opencensus: no extra config defined for the opencensus module
INFO: no config for the bloomfilter map[]
ERROR: registering the BloomFilter: no config for the bloomfilter
[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
WARNING: no config present for the httpsecure module
DEBUG: Debug enabled
[GIN-debug] GET /__debug/*param --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] POST /__debug/*param --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] PUT /__debug/*param --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.DebugHandler.func1 (3 handlers)
ERROR: JOSE: no signer config /
[GIN-debug] GET / --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.CustomErrorEndpointHandler.func1 (3 handlers)
ERROR: JOSE: no signer config /d
[GIN-debug] GET /d --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.CustomErrorEndpointHandler.func1 (3 handlers)
The flexibleconfig parser is not getting the template param:
if os.Getenv(fcEnable) != "" {
cfg = flexibleconfig.NewTemplateParser(flexibleconfig.Config{
Parser: cfg,
Partials: os.Getenv(fcPartials),
Settings: os.Getenv(fcSettings),
Path: os.Getenv(fcPath),
})
}
Hello,
I'm finding difficult to get an working example for getting error responses according to backend response and not the default 500 error response.
I've implemented my Gateway according to your Gin example and, at the moment, it is like this:
package main
import (
"flag"
"log"
"os"
"time"
"github.com/gin-gonic/gin"
"gopkg.in/gin-contrib/cors.v1"
"api_gateway_admin/middleware"
"github.com/devopsfaith/krakend/config"
"github.com/devopsfaith/krakend/logging"
"github.com/devopsfaith/krakend/proxy"
krakendgin "github.com/devopsfaith/krakend/router/gin"
)
func main() {
port := flag.Int("p", 0, "Port of the service")
logLevel := flag.String("l", "ERROR", "Logging level")
debug := flag.Bool("d", false, "Enable the debug")
configFile := flag.String("c", "{{path to file}}/configuration.json", "Path to the configuration filename")
flag.Parse()
parser := config.NewParser()
serviceConfig, err := parser.Parse(*configFile)
if err != nil {
log.Fatal("ERROR:", err.Error())
}
serviceConfig.Debug = serviceConfig.Debug || *debug
if *port != 0 {
serviceConfig.Port = *port
}
logger, err := logging.NewLogger(*logLevel, os.Stdout, "[KRAKEND]")
if err != nil {
log.Println("ERROR:", err.Error())
return
}
routerFactory := krakendgin.NewFactory(krakendgin.Config{
Engine: gin.Default(),
ProxyFactory: customProxyFactory{logger, proxy.DefaultFactory(logger)},
Logger: logger,
HandlerFactory: krakendgin.EndpointHandler,
Middlewares: []gin.HandlerFunc{
cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:4200", "http://127.0.0.1:4200", "http://localhost:8089", "http://localhost:8069", "http://localhost:8080", "http://localhost:8099"},
AllowMethods: []string{"PUT", "PATCH", "POST", "GET", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Accept",
"Accept-Encoding",
"Accept-Language",
"access-control-allow-origin",
"Access-Control-Request-Headers",
"Access-Control-Request-Method",
"authorization",
"Cache-Control",
"Connection",
"Content-Type",
"Host",
"If-Modified-Since",
"Keep-Alive",
"Key",
"Origin",
"Pragma",
"User-Agent",
"X-Custom-Header"},
ExposeHeaders: []string{"Content-Length", "Content-Type"},
AllowCredentials: true,
MaxAge: 48 * time.Hour,
}),
middleware.JwtCheck(),
},
})
routerFactory.New().Run(serviceConfig)
}
// customProxyFactory adds a logging middleware wrapping the internal factory
type customProxyFactory struct {
logger logging.Logger
factory proxy.Factory
}
// New implements the Factory interface
func (cf customProxyFactory) New(cfg *config.EndpointConfig) (p proxy.Proxy, err error) {
p, err = cf.factory.New(cfg)
if err == nil {
p = proxy.NewLoggingMiddleware(cf.logger, cfg.Endpoint)(p)
}
return
}
Could you please help me out on what should I change here?
Thank you.
The homepage states one can build in a container, but the command fails due to the target not present in the makefile
make docker_build
make: *** No rule to make target `docker_build'. Stop.
How do I get the original status of the backend, from krakend json ?
Inject into the KrakenD-CE the https://github.com/devopsfaith/krakend-jsonschema module
Create a chart to install krakend using helm in kubernetes.
Image: devopsfaith/krakend
ConfigMap to load the krakend.json
There exists some of this features with krakend ?
Thanks
Hi guys!
I've an question about CORS:
On the main page there is a string "Cross-origin resource sharing (CORS)" in tool features description
But in documentation I can't find any info to how implement it / enable it
I have Kubernetes Cluster with some micro-services and deployed and configured KrakenD in front of them, when I send some request to service endpoint I get error in Chrome console:
"Failed to load https://integration.****.com/*: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://dev.' is therefore not allowed access. The response had HTTP status code 500."
I can try configure Kube Ingress to handle it, but I want to enable it in KrakenD
So, how I can implement it?
Thanks!
krakend fails to compile with go 1.11:
==> make build
Building the binary...
# github.com/devopsfaith/krakend-ce
github.com/devopsfaith/krakend-ce/vendor/github.com/tmthrgd/go-hex.encodeASM: relocation target runtime.support_avx not defined
github.com/devopsfaith/krakend-ce/vendor/github.com/tmthrgd/go-memset.memsetAsm: relocation target runtime.support_avx not defined
make: *** [build] Error 2
Hello,
I'm getting an error, after running:
make all
The error:
Building the binary...
cmd/krakend-ce/main.go:12:2: import "krakend-ce/vendor/github.com/devopsfaith/krakend-ce" is a program, not an importable package
make: *** [build] Error 1
I've just cloned the repository and hit the make command.
Any idea why this is happening?
Hello, I'm trying to see if this solution is viable for us. I'm trying get a basic fake api working over https. But I'm not even getting into the API gateway.
My configuration is as follows (generated from the online config tool):
{
"version": 2,
"port": 8001,
"extra_config": {
"github_com/devopsfaith/krakend-httpsecure": {
"allowed_hosts": [
"api.site.com"
],
"ssl_proxy_headers": {
"X-Forwarded-Proto": "https"
},
"ssl_redirect": true,
"ssl_certificate": "/opt/gateway/certs/site.crt",
"ssl_private_key": "/opt/gateway/certs/site.key",
"sts_include_subdomains": true,
"ssl_host": "api.site.com"
}
},
"host": [
"https://api.site.com"
],
"output_encoding": "json",
"timeout": "3000ms",
"cache_ttl": "300s",
"name": "My API Gateway",
"endpoints": [
{
"endpoint": "/testing",
"method": "GET",
"output_encoding": "json",
"concurrent_calls": 1,
"extra_config": {
"github.com/devopsfaith/krakend/proxy": {
"static": {
"data": {
"new_field_a": 123,
"new_field_b": [
"arr1",
"arr2"
],
"new_field_c": {
"obj": "obj1"
}
},
"strategy": "always"
}
}
},
"backend": [
{
"url_pattern": "/",
"encoding": "json",
"extra_config": {},
"sd": "static"
}
]
}
]
}
My Output is as follows when running krakend in debug mode
root@vastyk:/etc/krakend# krakend run -c krakend.json -d
Parsing configuration file: krakend.json
ERROR: unable to create the gologgin logger: getting the extra config for the krakend-gologging module
WARNING: building the etcd client: unable to create the etcd client: no config
DEBUG: creating a new influxdb client
DEBUG: no config fot the influxdb client. aborting
ERROR: Unable to load custom config from the extra config
ERROR: opencensus: no extra config defined for the opencensus module
INFO: no config for the bloomfilter map[github_com/devopsfaith/krakend-httpsecure:map[allowed_hosts:[] ssl_redirect:true ssl_certificate:/opt/gateway/certs/site.crt ssl_private_key:/opt/gateway/certs/site.key ssl_host:api.site.com]]
ERROR: registering the BloomFilter: no config for the bloomfilter
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
DEBUG: Debug enabled
[GIN-debug] GET /__debug/*param --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.DebugHandler.func1 (4 handlers)
[GIN-debug] POST /__debug/*param --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.DebugHandler.func1 (4 handlers)
[GIN-debug] PUT /__debug/*param --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.DebugHandler.func1 (4 handlers)
ERROR: JOSE: no signer config /testing
[GIN-debug] GET /testing --> github.com/devopsfaith/krakend-ce/vendor/github.com/devopsfaith/krakend/router/gin.CustomErrorEndpointHandler.func1 (4 handlers)
[GIN] 2018/09/11 - 18:41:36 | 200 | 116.989573ms | 207.99.59.82 | GET /testing
In Postman if I send a request to https://api.site.com:8001/testing I get "Could not get any response" immediately. In the running display of KrakenD I have no connection attempt.
In Postman if I send a request to http://api.site.com:8001/testing I get the fake api response I expected. and I see the debug print out as you can see in my output snippet above. Why is this not accepting SSL connections? I noticed in my startup there is one ERROR that is listed as "Unable to load custom config from the extra config". Not sure if that is of use?
I have this output
{
"pricing": [
{
"max_number": "10",
"desc": "Sample description 1"
},
{
"max_number": "42",
"desc": "Sample description 2"
}
]
}
I want this
{
"pricing": [{
"maxNumber": "10",
"description": "Sample description 1"
},
{
"maxNumber": "42",
"description": "Sample description 2"
}
]
}
How can I do that with krakend ?
I tried do resolve it with this conf (sniped) :
{
"endpoint": "/get/pricing",
"method": "GET",
"concurrent_calls": 1,
"backend": [{
"url_pattern": "/api/v1/get/pricing",
"encoding": "json",
"is_collection": true,
"mapping": {
"collection": "pricing",
"collection.desc": "description",
"collection.max_number": "maxNumber"
},
"host": [
"http://facke_server/"
]
}]
}
add feature to do something with the payload content, e.g. simple calculations or regex replacements.
You have an example in the docs:
{
"apiVersion":"2.0",
"data": {
"updated":"2010-01-07T19:58:42.949Z",
"totalItems":800,
"startIndex":1,
"itemsPerPage":1,
"items":[]
}
}
I think it would be extremely useful to not only capture the data
, but also calculate the sum for all totalItems
.
I believe this feature will be of giant usefulness even with a very simple set of possible operations, like simple math and regex string replacement. Huge possibilities to save many loc in any aggregation backend.
For me it is a pain to decide at which point in the infrastructure this kind of aggregation should happen - building another service just for aggregation will lead to convoluted api request chains with lots of problems when things go wrong. Having simple aggregation tasks happen in the api gateway would be a fantastic solution.
as pointed at krakend/krakend-viper#1, the KrakenD-CE is not evaluating not JSON config files
I try to set my cookie in my backend side with echo framework code :
func (s *Auth) SetLoginCookie(c echo.Context, path, actoken, rftoken string) {
// 写入 cookie
cookie := new(http.Cookie)
cookie.Name = access_token
cookie.Value = actoken
cookie.Secure = true
cookie.HttpOnly = true
cookie.Path = path
cookie.Domain = s.cfgCookies.Domain
cookie.Expires = time.Now().Add(24 * time.Hour)
fmt.Println("cookie:", cookie)
c.SetCookie(cookie)
}
with the krakend config :
{
"endpoint": "/gcapi/iam.IAM/login",
"method": "POST",
"output_encoding": "JSON",
"backend": [{
"url_pattern": "/gcapi/iam.IAM/login",
"encoding": "JSON",
"disable_host_sanitize":true,
"sd": "etcd",
"host": [
"micro-rpc-iam"
]
}]
},
But I can't set the cookie in the chrome browser.
When I use the nginx to proxy the backend ,I can write it to my chrome browser.
How to set krakend Config to write the cookie ??
Hi Krakend Team,
Assume that I have 2 backend service (upstreams), I would like to know that what setting should be done in krakend.json to prevent the error whole request error?
for example:
I have following compoentns
I expected that if /c is failed, it should be return {} empty object, or krakend will be automatically handle error to {} empty object.
and finally response will be
response : {
b: { success: {} }
c: {}
}
Do you have any suggestion?
Hello People,
I am getting error regrading GELF writer after I have successfully compiled the krakend locally:
~/go/1.11/src/github.com/devopsfaith/krakend-ce$ ./krakend run -c krakend.json -d
Parsing configuration file: krakend.json
[KRAKEND] 2019/01/09 - 22:30:12.035 ▶ ERROR unable to create the GELF writer: getting the extra config for the krakend-gelf module
[KRAKEND] 2019/01/09 - 22:30:12.035 ▶ INFO Listening on port: 8000
[KRAKEND] 2019/01/09 - 22:30:12.036 ▶ WARNIN building the etcd client: unable to create the etcd client: no config
krakend.json
{
"version": 2,
"name": "My lovely gateway",
"port": 8000,
"cache_ttl": "3600s",
"timeout": "3s",
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
},
"github_com/devopsfaith/krakend-metrics": {
"collection_time": "60s",
"proxy_disabled": false,
"router_disabled": false,
"backend_disabled": false,
"endpoint_disabled": false,
"listen_address": ":8090"
},
"github_com/devopsfaith/krakend-cors": {
"allow_origins": [ "http://192.168.99.100:3000", "http://localhost:3000" ],
"allow_methods": [ "POST", "GET" ],
"allow_headers": [ "Origin", "Authorization", "Content-Type" ],
"expose_headers": [ "Content-Length" ],
"max_age": "12h"
}
},
"endpoints": [
{
"endpoint": "/supu",
"method": "GET",
"headers_to_pass": ["Authorization", "Content-Type"],
"backend": [
{
"host": [
"http://127.0.0.1:8000"
],
"url_pattern": "/__debug/supu",
"extra_config": {
"github.com/devopsfaith/krakend-martian": {
"fifo.Group": {
"scope": ["request", "response"],
"aggregateErrors": true,
"modifiers": [
{
"header.Modifier": {
"scope": ["request", "response"],
"name" : "X-Martian",
"value" : "ouh yeah!"
}
},
{
"header.RegexFilter": {
"scope": ["request"],
"header" : "X-Neptunian",
"regex" : "no!",
"modifier": {
"header.Modifier": {
"scope": ["request"],
"name" : "X-Martian-New",
"value" : "some value"
}
}
}
}
]
}
},
"github.com/devopsfaith/krakend-circuitbreaker/gobreaker": {
"interval": 60,
"timeout": 10,
"maxErrors": 1
}
}
}
]
},
{
"endpoint": "/github/{user}",
"method": "GET",
"backend": [
{
"host": [
"https://api.github.com"
],
"url_pattern": "/",
"whitelist": [
"authorizations_url",
"code_search_url"
],
"disable_host_sanitize": true,
"extra_config": {
"github.com/devopsfaith/krakend-martian": {
"fifo.Group": {
"scope": ["request", "response"],
"aggregateErrors": true,
"modifiers": [
{
"header.Modifier": {
"scope": ["request", "response"],
"name" : "X-Martian",
"value" : "ouh yeah!"
}
},
{
"body.Modifier": {
"scope": ["request"],
"contentType" : "application/json",
"body" : "eyJtc2ciOiJ5b3Ugcm9jayEifQ=="
}
},
{
"header.RegexFilter": {
"scope": ["request"],
"header" : "X-Neptunian",
"regex" : "no!",
"modifier": {
"header.Modifier": {
"scope": ["request"],
"name" : "X-Martian-New",
"value" : "some value"
}
}
}
}
]
}
},
"github.com/devopsfaith/krakend-ratelimit/juju/proxy": {
"maxRate": 2,
"capacity": 2
},
"github.com/devopsfaith/krakend-circuitbreaker/gobreaker": {
"interval": 60,
"timeout": 10,
"maxErrors": 1
}
}
}
]
},
{
"endpoint": "/private/{user}",
"backend": [
{
"host": [ "http://api.github.com" ],
"url_pattern": "/",
"whitelist": [
"authorizations_url",
"code_search_url"
]
}
],
"extra_config": {
"github.com/devopsfaith/krakend-jose/validator": {
"alg": "RS256",
"aud": "http://api.example.com",
"roles_key": "http://api.example.com/custom/roles",
"roles": [ "user", "admin" ],
"jwk-url": "https://albert-test.auth0.com/.well-known/jwks.json"
}
}
},
{
"endpoint": "/show/{id}",
"backend": [
{
"host": [
"http://showrss.info/"
],
"url_pattern": "/user/schedule/{id}.rss",
"encoding": "rss",
"group": "schedule",
"whitelist": ["items", "title"],
"extra_config": {
"github.com/devopsfaith/krakend-ratelimit/juju/proxy": {
"maxRate": 1,
"capacity": 1
},
"github.com/devopsfaith/krakend-circuitbreaker/gobreaker": {
"interval": 60,
"timeout": 10,
"maxErrors": 1
}
}
},
{
"host": [
"http://showrss.info/"
],
"url_pattern": "/user/{id}.rss",
"encoding": "rss",
"group": "available",
"whitelist": ["items", "title"],
"extra_config": {
"github.com/devopsfaith/krakend-ratelimit/juju/proxy": {
"maxRate": 2,
"capacity": 2
},
"github.com/devopsfaith/krakend-circuitbreaker/gobreaker": {
"interval": 60,
"timeout": 10,
"maxErrors": 1
}
}
}
],
"extra_config": {
"github.com/devopsfaith/krakend-ratelimit/juju/router": {
"maxRate": 50,
"clientMaxRate": 5,
"strategy": "ip"
}
}
}
]
}
I am using go version go1.11.4 linux/amd64
Thanks
add feature to store raw api result data in a configurable way for debugging or historical reasons.
I know this will kill performance. For some use cases, however, persisting information can be more important than performance (reporting, debugging, etc).
Include the KrakenD CEL component into the official binary, so users will be able to define verification expressions using the requests and responses.
PFB details
When i start the Container,i got bellow issue
please help me.
:~/krakend-ce# ls
backend_factory.go Dockerfile executor.go Gopkg.toml krakend krakend.json main.go proxy_factory.go router_engine.go vendor
builder encoding.go Gopkg.lock handler_factory.go krakend-alpine LICENSE Makefile README.md sd.go
root@i~/krakend-ce# docker run -p 8080:8080 -v ./krakend.json:/etc/krakend/ devopsfaith/krakend run --config /etc/krakend/krakend.json
docker: Error response from daemon: create ./krakend.json: "./krakend.json" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
E.g situation where it.is.nesessary to restrict API usage like 100.000 request only.
I am looking to map all inbound paths for example such "/api/*" to "/backend/*" application.
Is there any example where I can build this functionality? I am assuming this would need to be a custom router implementation.
When using backend which setting request header (i.e. martian) in endpoint with multiple backends, both backend requests are getting same header value event if configuration is different.
0.4.1
{
"version": 2,
"name": "My lovely gateway",
"port": 8000,
"cache_ttl": "3600s",
"timeout": "3s",
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
}
},
"endpoints": [
{
"endpoint": "/xy",
"method": "GET",
"backend": [
{
"host": [
"http://127.0.0.1:8083"
],
"url_pattern": "/x",
"extra_config": {
"github.com/devopsfaith/krakend-martian": {
"fifo.Group": {
"scope": ["request"],
"aggregateErrors": true,
"modifiers": [
{
"header.Modifier": {
"scope": ["request"],
"name" : "X-Martian",
"value" : "ouh yeah!"
}
}
]
}
}
}
},
{
"host": [
"http://127.0.0.1:8083"
],
"url_pattern": "/y",
"extra_config": {
"github.com/devopsfaith/krakend-martian": {
"fifo.Group": {
"scope": ["request"],
"aggregateErrors": true,
"modifiers": [
{
"header.Modifier": {
"scope": ["request"],
"name" : "X-Martian",
"value" : "ouh yeah! 2"
}
}
]
}
}
}
}
]
}
]
}
Run mmock: https://github.com/jmartin82/mmock with following command:
mmock -config-path . -console-ip 127.0.0.1 -server-ip 127.0.0.1
Run curl http://127.0.0.1:8000/xy
Both requests (to /x and to /y) are called with X-Martian
header set to ouh yeah!
Requests to /x should have X-Martian
header set to ouh yeah!
where request to /y should have X-Martian
header set to ouh yeah! 2
When using mmock you can open mmock console in browser to see incoming requests:
Is there support for websocket proxying?
so users can start consuming their lambda functions from AWS
Hello, first of all it's an amazing project!
Any option to setup a wildcard in endpoints preserving the structure? For example, I want forward
http://krakend:8000/myserviceA/humans/man/user?userId={id} http://krakend:8000/myserviceA/animals/dogs/dog?dogId={id} http://krakend:8000/myserviceA/animals/cats/cat?catId={id}
to the backend http://serverA/
preserving the structure of the paths above, i.e
http://serverA/humans/man/user?userId={id} http://serverA/myserviceA/animals/dogs/dog?dogId={id} http://serverA/myserviceA/animals/cats/cat?catId={id}
On the other hands, I want to forward
http://krakend:8000/myserviceB/humans/man/user?userId={id} http://krakend:8000/myserviceB/animals/dogs/dog?dogId={id} http://krakend:8000/myserviceB/animals/cats/cat?catId={id}
to the backend http://serverB/
preserving the same structure.
Something like this:
{
"endpoint": "/myserviceA/*",
"backend": [
{
"host": [ "http://serverA/" ],
"url_pattern": "/"
}
]
},
{
"endpoint": "/myserviceB/*",
"backend": [
{
"host": [ "http://localhost:8060" ],
"url_pattern": "/"
}
]
}
O something similar. Any idea?
Thanks
The builder of the KrakenD binary is using dep 0.4.1.
https://golang.github.io/dep/blog/2018/07/25/announce-v0.5.0.html
Hi.
We're exploring KrakenD and it seems to suit almost all our use case scenarios.
Most of our services, when filtering list results, expect a list of field_name=value
pairs. Some services have nested objects, so object1.object2.field_name=value
is common.
Those services are all backed by some kind of document-oriented database, so new fields can sometimes simply start existing. Consumers should be able to filter using those new fields.
How could I expose something like this using KrakenD? It doesn't seems possible, as I would have to describe every possible query string parameter we need to forward to the backend service...
Thanks!
My etcd version is :
etcd Version: 3.3.11
My config is :
"github_com/devopsfaith/krakend-etcd": {
"machines": [
"http://127.0.0.1:2379"
],
"dial_timeout": "5s",
"dial_keepalive": "30s",
"header_timeout": "1s"
},
"backend": [{
"url_pattern": "/gcrpc/gcrpc.user.User/List",
"encoding": "no-op",
"sd": "etcd",
"host": [
"/micro-rpc-api"
]
}],
But it can't get the value,the Jaeger tell me :
"dial tcp: lookup micro-rpc-api: no such host"
add a rules engine that triggers any kind of action based on e.g. backend down event.
combine this with my previous ideas and allow rules to be triggered from payload content (regex or number greater than etc.)
⋊> ~/D/g/s/g/d/krakend-ce on master ◦ make docker_build
docker run --rm -it -e "GOPATH=/go" -v "/Users/michael2008s/Develop/golang/src/github.com/devopsfaith/krakend-ce:/go/src/github.com/devopsfaith/krakend-ce" -w /go/src/github.com/devopsfaith/krakend-ce instrumentisto/dep:0.5.0-alpine ensure -v
grouped write of manifest, lock and vendor: scratch directory /go/src/github.com/devopsfaith/krakend-ce/.vendor-new already exists, please remove it
make: *** [docker_build] Error 1
Add a plugin system that allows me to do anything i want with api payload, not only combine and capture.
Again, combine this issue with my previous ones. Users might define their own events like "field x contains y" to trigger any kind of action.
Actions might be anything, defined in a plugin.
Some pre-defined standard actions should come with the system, like "send email", "write to file", "do another request with combined fields from request A and B" to update some data in a service, etc.
Of course I see that this will potentially kill performance - as an optional feature it still will be extremely useful.
so users can start injecting their custom middlewares to the binary
Hi,
I have a microservice which outputs following as a response.
It's an HTTP_GET request which serves on http://localhost:8050/location?company=5
curl -X GET http://localhost:8050/location?company=5
{
"locations": [
{ "key": "1050", "lat": 24.000000000, "lon": 46.000000000 },
{ "key": "1254", "lat": 24.999999999, "lon": 46.999999999 }
]
}
And I also have a HTTP_POST request, which accepts list of keys and returns relevent branch details.
it serves on http://localhost:8060/branches
and accepts a json array.
curl -X POST http://localhost:8060/branches -H 'Content-Type: application/json' -d '["1050","1254"]'
and the output would be
{
"branches": [
{ "key": "1050", "branch_name": "DC", "telephone": "+1 11 111 111" },
{ "key": "1254", "branch_name": "LA", "telephone": "+1 22 222 222" }
]
}
and I need the final merged output as following
{
"branches": [
{ "key": "1050", "branch_name": "DC", "telephone": "+1 11 111 111" },
{ "key": "1254", "branch_name": "LA", "telephone": "+1 22 222 222" }
],
"locations": [
{ "key": "1050", "lat": 24.000000000, "lon": 46.000000000 },
{ "key": "1254", "lat": 24.999999999, "lon": 46.999999999 }
]
}
I'm developing an api gateway using krakend and it'll do the above and serves on http://localhost:8080/findBranches?company=2
Here is my krakend-config.json
{
"version": 2,
"extra_config": {},
"timeout": "3000ms",
"cache_ttl": "300s",
"output_encoding": "json",
"name": "sample",
"endpoints": [
{
"endpoint": "/findBranches",
"method": "GET",
"extra_config": {
"github.com/devopsfaith/krakend/proxy": {
"sequential": true
}
},
"headers_to_pass": [ "*" ],
"querystring_params": [ "company" ],
"output_encoding": "json",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/location",
"encoding": "json",
"method": "GET",
"host": [ "http://localhost:8050" ],
"disable_host_sanitize": true
},
{
"url_pattern": "/branches",
"encoding": "json",
"method": "POST",
"host": [ "http://localhost:8060" ],
"disable_host_sanitize": false
}
]
}
]
}
How do I manipulate the response of 1st backend and send it to the post request of the second?
add feature to build backend fallback chains, like nginx try_files for backends: try_backends
when i build a docker image ,i got a issue
the list of supported distros (https://github.com/devopsfaith/krakend-ce#linux-distributions) does not include ubuntu 18.04
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.