카테고리 없음
Krakend 대해 알아보자
미니대왕님
2020. 3. 9. 17:00
[root@localhost sys4u]# docker run -p 8080:8080 -v $PWD:/etc/krakend/ devopsfaith/krakend run --config /etc/krakend/krakend.json bash: docker: 명령을 찾을 수 없습니다... 'podman-docker' 명령을 제공하는 'docker' 꾸러미를 설치하시겠습니까? [N/y] y * 큐 대기 중... * 패키지 목록을 불러오고 있습니다.... 다음 패키지를 설치해야 합니다: conmon-2:2.0.6-1.module_el8.1.0+272+3e64ee36.x86_64 OCI container runtime monitor libvarlink-18-3.el8.x86_64 Varlink C Library podman-docker-1.6.4-2.module_el8.1.0+272+3e64ee36.noarch Emulate Docker CLI using podman podman-manpages-1.6.4-2.module_el8.1.0+272+3e64ee36.noarch Man pages for the podman commands 다음 패키지를 갱신해야 합니다: containernetworking-plugins-0.8.3-4.module_el8.1.0+272+3e64ee36.x86_64 CNI network plugins libseccomp-2.4.1-1.el8.x86_64 Enhanced seccomp library podman-1.6.4-2.module_el8.1.0+272+3e64ee36.x86_64 Manage Pods, Containers and Container Images runc-1.0.0-64.rc9.module_el8.1.0+272+3e64ee36.x86_64 CLI for running Open Containers slirp4netns-0.4.2-2.git21fdece.module_el8.1.0+272+3e64ee36.x86_64 slirp for network namespaces 변경 사항을 수행하시겠습니까? [N/y] y * 큐 대기 중... * 인증 대기 중... * 큐 대기 중... * 패키지 다운로드 중... * 데이터 요청 중... * 변경 사항 시험 중... * 갱신 설치 중... * 패키지 설치 중... * 갱신 설치 중... * 패키지 설치 중... * 패키지 정리 중... * 패키지 설치 중... * 패키지 정리 중... * 패키지 설치 중... * 패키지 정리 중... * 패키지 설치 중... * 패키지 정리 중... * 패키지 설치 중... * 패키지 정리 중... * 패키지 설치 중... Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg. Trying to pull registry.redhat.io/devopsfaith/krakend... unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portaledhat.com/RegistryAuthentication Trying to pull quay.io/devopsfaith/krakend... unauthorized: access to the requested resource is not authorized Trying to pull docker.io/devopsfaith/krakend... Getting image source signatures Copying blob bc51dd8edc1b done Copying blob c777086aed63 done Copying blob 00136d8bf764 done Copying blob bfd6eeafc48c done Copying config af514a1c73 done Writing manifest to image destination Storing signatures ERROR parsing the configuration file: '/etc/krakend/krakend.json' (open): no such file or directory [root@localhost sys4u]# ll /etc/krakend/krakend.json ls: cannot access '/etc/krakend/krakend.json': 그런 파일이나 디렉터리가 없습니다 |
Linux
CentOS and Redhat
The installation process requires following these steps:
- Install the repo package
- Install the KrakenD package
- Start the KrakenD service
Paste this in the terminal:
$rpm -Uvh http://repo.krakend.io/rpm/krakend-repo-0.2-0.x86_64.rpm $ yum install -y krakend $ systemctl start krakend |
[root@localhost krakend]# cat 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" } } } ] } |
Krakend 를실행 해보고 process 도 확인해보겠습니다. !
[root@localhost krakend]# systemctl start krakend [root@localhost krakend]# [root@localhost krakend]# ps -ef | grep krakend krakend 11601 1 59 00:28 ? 00:00:04 /usr/bin/krakend run -c /etc/krakend/krakend.json root 11612 11320 0 00:29 pts/2 00:00:00 grep --color=auto krakend |
C:\3. 자동
캡쳐