SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
Byungjin Park · posquit0.com · posquit0Copyright © 2018 All Rights Reserved.
박 병진(Byungjin Park) · Site Reliability Engineer @ KASA
Managing Kong API Gateway with Terraform
Terraform으로 Kong API Gateway 관리하기
서울 밋업 #2 at HashiCorp KRUG
Oct 23, 2018
Copyright © 2018 All Rights Reserved.
speaker
발표자 소개
Byungjin Park · posquit0.com · posquit0
박병진 / @posquit0
(현) Site Reliability Engineer @ Kasa
(전) Software Architect @ OMNIOUS
DEFCON CTF 국제해킹대회 World Final 5회 진출
Node.js와 Python을 좋아합니다.
터미널 환경을 사랑하는 굉장한 Vim 덕후입니다.
GitHub에서 활발하게 오픈소스 활동을 하고 있습니다.
서비스 개발 및 운영과 관련된 모든 일을 즐깁니다.
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
api gateway
Copyright © 2018 All Rights Reserved.
api gateway
MSA (MICROSERVICES ARCHITECTURE)
Byungjin Park · posquit0.com · posquit0
API Gateway는 마이크로 서비스 아키텍처와 많은 연관을 가지고 있습니다.
MSA 는 하나의 큰 어플리케이션을 독립적인 역할을 수행하는 여러 마이크로 서비스로 쪼개어 조합함으로써 개별 서비스의 복잡도를 줄이는 설계 패턴 입니다.
Monolithic Micro-services Architecture
User
Auth
Order
Payment
Notification
CAR RENTAL SERVICE CAR RENTAL SERVICE
User
Auth
Payment Noti
Order
Copyright © 2018 All Rights Reserved.
api gateway
COMMUNICATION IN MSA
Byungjin Park · posquit0.com · posquit0
가장 큰 단점 중 하나는 운영해야 하는 서비스의 수가 늘어나면서 굉장히 복잡해지는 통신(Communication) 문제 입니다.
하지만, MSA 가 장점만을 가지는 것은 아닙니다.
Client-Server Communication Inter Service Communication
North - South East - West
Copyright © 2018 All Rights Reserved.
api gateway
COMMUNICATION IN MSA
Byungjin Park · posquit0.com · posquit0
이러한 문제들을 효율적으로 해결하기 위해 API Gateway 와 Service Mesh 등이 나타났습니다.
MSA 에서는 클라이언트와 서비스 간의 통신 뿐만 아니라 서비스 간의 통신 또한 고려 해야 합니다.
Client-Server Communication Inter Service Communication
North - South East - West
Copyright © 2018 All Rights Reserved.
api gateway
WHY USE API GATEWAY?
Byungjin Park · posquit0.com · posquit0
API Gateway는 MSA 에서 클라이언트와 서버 간의 통신 문제를 해결하기 위한 솔루션 입니다.
하나의 게이트웨이로서 클라이언트와의 통신을 담당할 수 있으며, 각 마이크로서비스가 중복으로 가져야 했던 기능 레이어들을 대신 처리할 수 있습니다.
Copyright © 2018 All Rights Reserved.
api gateway
CANDIDATES
Byungjin Park · posquit0.com · posquit0
이러한 API Gateway 를 구현한 오픈소스 프로젝트 혹은 엔터프라이즈 서비스 들이 이미 시장에 많이 존재 합니다.
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
kong
Copyright © 2018 All Rights Reserved.
kong
KONG API GATEWAY
Byungjin Park · posquit0.com · posquit0
Apache 라이센스로 이용 가능한 커뮤니티 에디션과, 고급 기능 및 기술 지원이 제공되는 엔터프라이즈 에디션이 있습니다.
Kong는 이미 널리 사용되고 있는 Nginx 웹 서버를 기반으로 Lua 를 통해 기능이 확장된 오픈소스 API 게이트웨이 입니다.
Cloud-native, fast, scalable, and distributed Microservice Abstraction Layer
(also known as an API Gateway, or in some cases Service Mesh)
https://github.com/kong/kong
License Model
- Community Edition (CE)
- Enterprise Edition (EE)
Nginx / OpenResty 을 기반으로하여 Lua로 확장 가능한 오픈소스 API 게이트웨이
NGINX
OpenResty
Clustering & Datastore
Plugins
RESTful Administration API
Copyright © 2018 All Rights Reserved.
kong
WHY USE KONG?
Byungjin Park · posquit0.com · posquit0
당연히 Lua 스크립트를 통해 직접 커스텀 플러그인을 제작하여 활용할 수도 있습니다.
Kong은 인증, 보안, 모니터링, 로깅 등 API Gateway 에 필요한 많은 기능을 기본 플러그인을 통해 제공하고 있습니다.
Features
API Gateway를 위한 다양한 기능을 기본 플러그인으로 제공
- Authentication
- Security
- Traffic Control
- Request / Response Transformation
- Serverless
- Analytics & Monitoring
- Logging
Copyright © 2018 All Rights Reserved.
kong
WHY USE KONG?
Byungjin Park · posquit0.com · posquit0
전세계 개발자들이 관련 프로젝트 및 플러그인을 개발하고 있으며, Kong을 주제로한 밋업 또한 전세계에서 진행되고 있습니다.
Kong은 커뮤니티 에디션을 통해 강력한 커뮤니티 생태계를 가지고 있습니다.
Ecosystem
무료 커뮤니티 에디션(CE) 을 중심으로 한 강력한 오픈소스 생태계
- 4,500,000+ 다운로드 수
- 100+ 오픈소스 컨트리뷰터
- 36,000+ 커뮤니티 참여자
- 100+ 전세계 밋업 진행
- 4000+ Kong 관련 프로젝트
- 500+ Kong 플러그인
Kong Hub: Kong 기능 확장 모음 (https://docs.konghq.com/hub/)
Kong Nation: Kong 커뮤니티 포럼 (https://discuss.konghq.com)
Copyright © 2018 All Rights Reserved.
kong
ENTERPRISE EDITION
Byungjin Park · posquit0.com · posquit0
다만, 가격이… 🙄🙄🙄
Kong 엔터프라이즈 에디션은 기술 지원, 추가 플러그인, 관리자 대시보드 등을 추가 지원합니다.
Benefits
- Kong Manager: 웹 기반 관리자 대시보드
- Kong Vitals: 자체 모니터링 대시보드
- Kong Dev Portal: 개발자 포탈. OpenAPI 기반의 API 문서 제공
- Admin API에 대한 RBAC(Role Based Access Control) 지원
- 24/7 기술 지원
- 추가적인 고급 플러그인 다수 제공
- OpenID Connect
- OAuth 2.0 Introspection
- Enterprise Rate Limiting
- Edge Caching
Copyright © 2018 All Rights Reserved.
kong
COMPONENTS
Byungjin Park · posquit0.com · posquit0
현재 Kong이 공식 지원하는 데이터 저장소는 PostgreSQL과 Cassandrda 입니다.
Kong CE는 관리자 API, 프록시 API, 데이터 저장소로 구성 됩니다.
Kong Proxy API
Kong Admin API
Data Store
Kong Admin API
API Gateway 설정 관리 목적의 관리자 API
기본 8001(HTTP), 8444(HTTPS) 포트 이용
Kong Proxy API
Admin API를 통해 구성된 API Gateway의 엔드포인트 모음
기본 8000(HTTP), 8443(HTTPS) 포트 이용
Data Store
Kong 의 API 오브젝트(서비스, 라우트, 컨슈머 등) 저장소
Postgres, Cassandra 지원
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
꼭 알아두어야 할 API 오브젝트로는 Service, Route, Consumer, Credential, Plugin 이 있습니다.
Kong API Gateway를 구성하는 작업은 Kong Admin API의 오브젝트를 관리하는 것이라 생각하면 됩니다.
Service Route Consumer Plugin
Upstream Target
Credential
SNI Certificate
API
deprecated
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
프로토콜은 현재 HTTP/S, HTTP2, WebSocket을 지원 합니다.
서비스(Service) 오브젝트는 API Gateway에 연결 되어 클라이언트 요청을 전달 할 업스트림 서비스를 정의합니다.
Service
Kong API Gateway에 연결 될 업스트림 서비스를 의미
프로토콜, 호스트, 포트, 경로 설정
User Service
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
정규표현식과 우선순위를 지원하여 유연하게 설정을 할 수 있습니다.
라우트(Route) 오브젝트는 클라이언트의 요청(HTTP Method, Path 등)에 따라 특정 서비스로 해당 요청을 전달하기 위한 규칙을 정의합니다.
Service
Kong API Gateway에 연결 될 업스트림 서비스
프로토콜, 호스트, 포트, 경로 설정
User Service
Route
클라이언트의 요청을 서비스로 포워딩하기 위한 규칙(Rule)
프로토콜, 호스트, 경로, HTTP 메소드 설정
정규표현식과 우선순위 지원
POST /users GET /users/me
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
업스트림 객체를 사용하지 않아도 Kong API Gateway는 사용 가능합니다.
업스트림(Upstream) 오브젝트는 Kong API Gateway 자체적으로 L7 로드밸런싱 기능을 지원하고자 도입된 가상호스트 개념입니다.
Upstream
로드밸런싱을 지원하기 위한 가상 호스트(Virtual Host)
Active Health Check 및 Passive Health Check (Circuit Breaker) 지원
user.service
POST /users GET /users/me
User Service
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
가중치 값을 활용하여 카나리 배포(Canary Deployment)를 구현하는 것도 가능합니다.
타겟(Target) 오브젝트는 업스트림에 연결되어 분배된 요청을 처리 할 백엔드 서비스를 정의합니다.
Upstream
로드밸런싱을 지원하기 위한 가상 호스트(Virtual Host)
Active Health Check 및 Passive Health Check (Circuit Breaker) 지원
User v1 User v2
Target
호스트와 포트 쌍으로 구성된 가상호스트로의 요청을 분배할 타겟
로드밸런싱 가중치(Weight) 지원
user.service
POST /users GET /users/me
User Service
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
같은 서비스 사용자라도 플랫폼 별(Web, Android, iOS 등)로 컨슈머를 만들어 연결하는 것도 가능하다.
컨슈머(Consumer) 오브젝트는 API를 소비할 사용자를 정의하며, 이를 통해 인증 / 접근제어 / 트래킹 등 API Gateway의 여러 기능을 활용할 수 있습니다.
Consumer
API 소비자를 나타내며 인증 / 접근제어 / 트래킹 등 여러 목적으로 활용
custom_id 필드를 통해 서비스 상의 사용자 ID와 매핑 가능
컨슈머와 사용자가 반드시 1:1 관계일 필요는 없음
user.service
consumer
POST /users GET /users/me
User Service
User v1 User v2
Copyright © 2018 All Rights Reserved.
kong
API OBJECTS
Byungjin Park · posquit0.com · posquit0
이미 제공되는 플러그인을 활용할 뿐만 아니라, Lua로 직접 커스텀 플러그인을 제작하여 활용할 수 있습니다.
플러그인(Plugin) 오브젝트는 Kong API Gateway의 가장 강력한 기능으로 HTTP 요청-응답 플로우 상에 원하는 기능을 확장할 수 있습니다.
Consumer
API 소비자를 나타내며 인증 / 접근제어 / 트래킹 등 여러 목적으로 활용
custom_id 필드를 통해 서비스 상의 사용자 ID와 매핑 가능
컨슈머와 사용자가 반드시 1:1 관계일 필요는 없음
user.service
consumer
Plugin
HTTP 요청-응답 흐름 상에 실행될 수 있는 확장 기능
인증 / 접근 제어 / 요청, 응답 가공 / 로그, 메트릭 전달 등
plugin
POST /users GET /users/me
User Service
User v1 User v2
Copyright © 2018 All Rights Reserved.
kong
DISTRIBUTIONS
Byungjin Park · posquit0.com · posquit0
Kong은 다양한 배포 방법을 지원하고 있어 쉽고 빠르게 Kong API Gateay를 사용해볼 수 있습니다.
Copyright © 2018 All Rights Reserved.
kong
INSTALL
Byungjin Park · posquit0.com · posquit0
데이터베이스 구성 후 DB 마이그레이션 작업을 통해 DB 테이블을 생성하고, Kong 서비스를 해당 DB와 연결하여 실행하면 됩니다.
Set-up DB
Migrate DB
Run Kong
1. Set up Database
Kong의 데이터 저장소로 Postgres 혹은 Cassandra 로 DB 구성
2. Migrate Database
Kong의 데이터베이스 마이그레이션 명령어를 수행하여 DB 스키마 생성
3. Run Kong API Gateway
구성한 DB 연결 정보와 함께 Kong 서비스 실행
Kong의 설치 작업은 크게 세 단계로 구성됩니다.
Copyright © 2018 All Rights Reserved.
kong
INSTALL WITH DOCKER
Byungjin Park · posquit0.com · posquit0
도커(Docker)로 Kong을 설치하기 위해서는 우선 네트워크와 데이터베이스를 구성해야 합니다.
1. Set up Database
- 다른 도커 컨테이너와 통신하기 위한 네트워크 생성
- Postgres 도커 컨테이너 실행
# Create a custom network to allow the containers
# to discover and communicate with each other
$ docker network create kong-net
# Run Postgres container
$ docker run -d --name kong-database 
--network=kong-net 
-p 5432:5432 
-e "POSTGRES_USER=kong" 
-e "POSTGRES_DB=kong" 
postgres:9.6
Copyright © 2018 All Rights Reserved.
kong
INSTALL WITH DOCKER
Byungjin Park · posquit0.com · posquit0
데이터베이스 구동 후에는 DB 테이블을 생성하기 위하여 Kong 이미지를 통해 마이그레이션 작업을 수행합니다.
2. Migrate Database
- Kong 도커 이미지를 통해 DB 마이그레이션 작업 수행 # Run the migrations with an Kong container
$ docker run --rm 
--network=kong-net 
-e "KONG_DATABASE=postgres" 
-e "KONG_PG_HOST=kong-database" 
kong:latest kong migrations up
3. Run Kong API Gateway
- Kong API Gateway 도커 컨테이너 실행
- 포트 번호
- 8000: Kong Proxy(HTTP)
- 8443: Kong Proxy(HTTPS)
- 8001: Kong Admin(HTTP)
- 8444: Kong Admin(HTTPS)
Copyright © 2018 All Rights Reserved.
kong
INSTALL WITH DOCKER
Byungjin Park · posquit0.com · posquit0
마이그레이션 작업이 끝나면, Kong 도커 컨테이너를 실행하여 Kong Proxy와 Kong Admin 서비스의 포트를 개방합니다.
# Start a Kong container that will connect to database
$ docker run -d --name kong 
--network=kong-net 
-e "KONG_DATABASE=postgres" 
-e "KONG_PG_HOST=kong-database" 
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" 
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" 
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" 
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" 
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" 
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" 
-p 8000:8000 
-p 8443:8443 
-p 8001:8001 
-p 8444:8444 
kong:latest
Validate Kong is running
- Kong Admin API에 요청을 보내 Kong Admin 동작 확인
Copyright © 2018 All Rights Reserved.
kong
INSTALL WITH DOCKER
Byungjin Park · posquit0.com · posquit0
Kong 설치가 완료되면 Admin API에 HTTP 요청을 보내 Kong이 정상적으로 동작하는지 확인합니다.
$ curl -i http://localhost:8001/

HTTP/1.1 200 OK
Date: Sun, 21 Oct 2018 12:03:02 GMT
Content-Type: application/json;
charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.14.1
Content-Length: 5659
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
kong management
Using CLI based HTTP Client Command
- API First Design 을 기반으로 하여 HTTP로 모든 기능 이용 가능
- 가장 빠르게 Kong 을 관리해 볼 수 있는 방법
Copyright © 2018 All Rights Reserved.
kong management
USING CLI
Byungjin Park · posquit0.com · posquit0
Kong 은 HTTP 기반의 Admin API 를 제공해주기 때문에 다른 도구 설치 없이도 빠르게 API Gateway를 구성해 볼 수 있습니다.
# Add user service
$ curl -i -X POST 
--url http://localhost:8001/services/ 
--data 'name=user-service' 
--data 'protocol=http' 
--data 'host=user.service' 
--data 'port=80' 
--data 'path=/'
Using CLI based HTTP Client Command
- API First Design 을 기반으로 하여 HTTP로 모든 기능 이용 가능
- 가장 빠르게 Kong 을 관리해 볼 수 있는 방법
Copyright © 2018 All Rights Reserved.
kong management
USING CLI
Byungjin Park · posquit0.com · posquit0
하지만 API Gateway를 설정하기 위하여 매번 HTTP 요청 명령어를 작성하는 것은 너무나 번거로운 일 입니다.
# Add user service
$ curl -i -X POST 
--url http://localhost:8001/services/ 
--data 'name=user-service' 
--data 'protocol=http' 
--data 'host=user.service' 
--data 'port=80' 
--data 'path=/'
Problems
- 매번 쿼리 작성하기 귀찮음…
Using GUI based HTTP Client
- Kong Admin API 엔드포인트를 미리 등록
- 디렉토리 기능을 통한 API 엔드포인트 분류
- 환경(로컬, 개발, 운영 등)에 따른 변수 관리
- Postman / Insomnia / ETC
Copyright © 2018 All Rights Reserved.
USING GUI HTTP CLIENT
Byungjin Park · posquit0.com · posquit0
Postman, Insomnia 와 같은 GUI 기반의 HTTP 클라이언트 앱을 사용한다면 Kong 을 보다 쉽게 관리할 수 있습니다.
kong management
Using GUI based HTTP Client
- Kong Admin API 엔드포인트를 미리 등록
- 디렉토리 기능을 통한 API 엔드포인트 분류
- 환경(로컬, 개발, 운영 등)에 따른 변수 관리
- Postman / Insomnia / ETC
Copyright © 2018 All Rights Reserved.
USING GUI HTTP CLIENT
Byungjin Park · posquit0.com · posquit0
그러나, 이 또한 현재 API Gateway가 어떻게 설정되어 있는지 한 눈에 파악하기가 어렵습니다.
kong management
Problems
- 현재 API Gateway 의 설정을 한 눈에 보기 어려움
Admin Dashboard for Kong CE
- Kong CE를 위한 오픈소스 관리자 대시보드 웹 (비공식)
- Kong DB 백업/복구 기능 제공
- LDAP 을 통한 대시보드 접근제어 지원
- 이메일 / 슬랙 알림 기능
Copyright © 2018 All Rights Reserved.
USING DASHBOARD
Byungjin Park · posquit0.com · posquit0
Kong EE 의 관리자 대시보드에서 제공하는 기능과 거의 대등할 정도로 풍부한 기능을 제공합니다. (디자인도 이뻐요 👍)
Konga
More than just another GUI to Kong Admin API
https://github.com/pantsel/konga
Konga는 Kong 커뮤니티에서 오픈소스로 만들어져 관리되고 있는 Kong CE 용 관리자 대시보드입니다.
kong management
Problems
API 게이트웨이 설정 변경에 대한 추적(Tracking) 필요
- “누가 예약 라우트 설정을 변경했지?”
- “사용자 서비스 포트 번호는 왜 변경된거지?”
- “IP 블랙 리스트 플러그인은 언제 추가한거지?”
- “내가 이 설정을 변경해도 되나?”
- “어제까지만 해도 잘 동작 하던게 왜 안되지!?”
Copyright © 2018 All Rights Reserved.
USING DASHBOARD
Byungjin Park · posquit0.com · posquit0
누가, 언제, 무슨 설정을, 어떻게, 왜 변경해야 하는지 추적할 수 있어야 합니다.
API Gateway의 설정이 점점 복잡해지고, 이를 다루는 엔지니어의 수가 증가함에 따라 또 다른 문제와 마주하게 됩니다.
kong management
Copyright © 2018 All Rights Reserved.
TRACKING CHANGES
Byungjin Park · posquit0.com · posquit0
설정의 변경사항을 추적하기 위해서는 감사 로그(Audit Log)를 남겨 추적하거나, 선언식 설정(Declarative Configuration)을 이용할 수 있습니다.
kong management
OR
Audit Log Declarative Configuration
Copyright © 2018 All Rights Reserved.
TRACKING CHANGES
Byungjin Park · posquit0.com · posquit0
선언식 설정을 이용하는 것에 비하여 이점이 없습니다.
kong management
Audit Log
- 누가, 언제, 무엇을, 어떻게 변경 하였는지 기록
- 로그를 쉽게 검색할 수 있고 가시화하기 위한 또 다른 도구 필요
- 특정 그룹에 알림(Notification) 설정 필요
감사 로그(Audit Log)를 이용하는 것은 배보다 배꼽이 더 큰 해결책이 될 수 있으며,
Copyright © 2018 All Rights Reserved.
TRACKING CHANGES
Byungjin Park · posquit0.com · posquit0
파일을 통해 설정을 관리할수 있기 때문에 여러 이점을 취할 수 있습니다.
kong management
Declarative Configuration
- 명령식 설정(Imperative Configuration)과 다르게 현재 설정을 선언
- 설정 파일을 통해 버전 관리가 가능
- Terraform, Ansible, Puppet, Kubernetes 등
선언식 설정(Declarative Configuration)은 보통 명령식 설정(Imperative Configuration)과 많이 비교 됩니다.
Copyright © 2018 All Rights Reserved.
TERRAFORM
Byungjin Park · posquit0.com · posquit0
AWS 인프라를 코드로 관리하기 위해 많이 사용되곤 합니다.
HashiCorp의 테라폼(Terraform)은 다양한 플랫폼에서 사용할 수 있는 오픈소스 IaC(Infrastructure as Code) 도구 입니다.
kong management
A tool for building, changing, and combining infrastructure safely and efficiently
https://www.terraform.io/
IaC (Infrastructure as Code)
- 설정(Configuration)을 코드로 버전관리
- 코드 리뷰를 통한 협업과 실수 방지
- 테스트 가능
- 코드 실행을 통한 자동화(Automation) 및 재사용(Reuse)
Copyright © 2018 All Rights Reserved.
USING DECLARATIVE CONFIGURATION
Byungjin Park · posquit0.com · posquit0
(공식 프로바이더는 아닙니다…😭😭)
오픈소스로 공개되어 있는 terraform-provider-kong 을 이용하면, 테라폼으로 인프라를 관리하던 경험을 그대로 Kong 관리에 가져올 수 있습니다.
kong management
Kong Provider for Terraform
https://github.com/kevholditch/terraform-provider-kong
Terraform Community Provider for Kong
- 테라폼으로 Kong API Gateway 설정 가능
- Admin API 엔드포인트에 대한 Basic Auth와 API Key Auth 지원
- 거의 모든 API 오브젝트에 대한 설정 가능
- 테라폼 데이터 소스 및 임포트 지원
Copyright © 2018 All Rights Reserved.
USING DECLARATIVE CONFIGURATION
Byungjin Park · posquit0.com · posquit0
위와 같이 HCL(HashiCorp Configuration Language) 로 선언식 설정을 할 수 있습니다.
kong management
Kong Provider for Terraform
https://github.com/kevholditch/terraform-provider-kong
provider "kong" {
kong_admin_uri = "http://admin.my-kong.com:8001"
kong_admin_username = "youruser"
kong_admin_password = "yourpass"
}
resource "kong_route" "route" {
protocols = [ "http", "https" ]
methods = [ "GET", "POST" ]
hosts = [ "example2.com" ]
paths = [ "/test" ]
strip_path = false
preserve_host = true
service_id = "${kong_service.service.id}"
}
Copyright © 2018 All Rights Reserved.
ALTERNATIVES: KONGFIG
Byungjin Park · posquit0.com · posquit0
Kong 만을 선언식 설정으로 관리하기 위한 도구도 있었더랍니다…ㅜㅜ
kong management
Declarative configuration for Kong
https://github.com/mybuilder/kongfig
- Kong 을 선언식 설정으로 관리하기 위해 만들어진 Node.js 기반 도구
- 테라폼과 사용법 유사
- 업데이트 안된지 오래 됨…
- 최신 API 오브젝트 미지원…
$ kongfig apply --path config.yml --host localhost:8001
plugins:
- name: cors
attributes:
username:
enabled: true
config:
credentials: false
preflight_continue: false
max_age: 7000
consumers:
- username: iphone-app
custom_id: foobar-1234
Copyright © 2018 All Rights Reserved.
ALTERNATIVES: KUBERNETES INGRESS CONTROLLER
Byungjin Park · posquit0.com · posquit0
이를 이용하면 Kubernetes Manifest 파일을 통해 플러그인 / 컨슈머 / 인증서 관리를 할 수 있습니다.
kong management
Use Kong for Kubernetes Ingress
https://github.com/Kong/kubernetes-ingress-controller
- NGINX 인그레스 컨트롤러를 기반으로 한 Kong 인그레스 컨트롤러
- Ingress 오브젝트를 통해 서비스 / 라우트 / 업스트림 / 타겟 관리 자동화
- CRD(Custom Resource Definition)을 통해 플러그인 / 컨슈머 / 인증서 관리
- Kong 의 공식 쿠버네티스 배포판
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: http-svc-consumer-ratelimiting
namespace: default
config:
key: value
plugin: my-plugin
Kong Ingress Controller는 Kong Inc. 에서 쿠버네티스를 적극 지원하기 위해 활발히 개발중인 공식 쿠버네티스 배포판입니다.
$ kubectl apply -f kong-plugin.yaml
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
demo
Copyright © 2018 All Rights Reserved.
GOALS
Byungjin Park · posquit0.com · posquit0
주요 Kong API 오브젝트 및 플러그인을 다루어 보겠습니다.
demo
이번 데모에서는 사용자 서비스와 할 일 서비스로 구성된 API Gateway를 테라폼을 이용하여 구성해보려 합니다.
모든 데모 코드는 https://github.com/posquit0/demo-terraform-provider-kong 에서 확인할 수 있습니다.
Services
- User Service
- TODO Service
Routes
- User Routes
- TODO Routes
- Fallback Route
Consumers
- User
- Admin
- Anonymous
Auth
- Basic Auth
Plugins
- CORS
- Rate Limiting
- Correlation ID
- Bot Detection
Copyright © 2018 All Rights Reserved.
ENVIRONMENTS
Byungjin Park · posquit0.com · posquit0
이번 데모에서 사용하는 Terraform, Kong CE, Terraform Provider Kong 의 버전은 위와 같습니다.
demo
모든 데모 코드는 https://github.com/posquit0/demo-terraform-provider-kong 에서 확인할 수 있습니다.
Terraform v0.11.9
Kong CE v0.14.1
Terraform Kong Povider v1.7.0
Copyright © 2018 All Rights Reserved.
INSTALL TERRAFORM KONG PROVIDER
Byungjin Park · posquit0.com · posquit0
위와 같이 직접 Kong 프로바이더를 다운로드 받아 설정해야 합니다.
demo
Kong은 테라폼의 공식 프로바이더가 아니기 때문에 terraform init 을 통해 자동 설치 되지 않습니다.
모든 데모 코드는 https://github.com/posquit0/demo-terraform-provider-kong 에서 확인할 수 있습니다.
$ wget https://github.com/kevholditch/terraform-provider-kong/releases/download/v1.7.0/terraform-provider-kong_1.7.0_darwin_amd64.zip
$ unzip -j terraform-provider-kong_1.7.0_darwin_amd64.zip terraform-provider-kong_v1.7.0 -d ~/.terraform.d/plugins/
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
retrospective
Copyright © 2018 All Rights Reserved.
retrospective
GOOD THINGS
Byungjin Park · posquit0.com · posquit0
코드를 통한 버전 관리와 자동화를 할 수 있다는 넘나 행복합니다… 🤫🤫
Kong API Gateway 운영을 위하여 테라폼을 도입하게 되면서 많은 이득을 볼 수 있었습니다.
Version Control
감사 로그(Audit Log) 없이 API Gateway 설정의 변경 이력 관리
Collaboration
GitHub와 S3 상태 저장소를 사용하여 팀원과 설정을 함께 관리
No GUI
Konga 혹은 Kong EE 와 같은 GUI 대시보드 없이 운영 가능
Automation
코드 실행 한 번으로 모든 설정을 빠르게 적용
Testing
운영 환경 적용 전 테스트용 API Gateway 설정 용이
Documentation
테라폼 코드 자체가 API Gateway 설정에 대한 문서 역할
Copyright © 2018 All Rights Reserved.
retrospective
FUTURE WORKS
Byungjin Park · posquit0.com · posquit0
또, 현재 테라폼 Kong Provider는 Consumer Credential 오브젝트를 지원하지 않으며, 그 외에도 부족한 기능이 존재하는게 사실 입니다.
아직 IaC 팀 문화 전파 및 자동화 측면에서 목표하는 바까지 도달하지는 못하였습니다.
Access Control
CI / CD 파이프라인 상의 특정 서비스 계정만 Admin API 접근 허가
Pull Request + Code Review
GitHub 상에서 코드리뷰를 통해 PR이 병합되어야 변경사항 적용
CI / CD Pipeline
Jenkins 와 통합하여 운영 / 스테이징 환경 배포 자동화
Terraform Kong Provider
오픈소스 기여를 통한 불완전한 기능 보완
Copyright © 2018 All Rights Reserved.
retrospective
AWESOME KONG
Byungjin Park · posquit0.com · posquit0
Kong CEO가 별풍선 주고 갔어요! 🤩
Kong API Gateway를 도입하면서 도움이 되었던 리소스를 큐레이션하여 GitHub에 공유하고 있습니다.
https://github.com/posquit0/awesome-kong
Copyright © 2018 All Rights Reserved.
retrospective
V1 RELEASE
Byungjin Park · posquit0.com · posquit0
서비스 메시 패턴 지원이 기대 되네요! (Istio도 아직 못 써보았는데…😂😂)
Kong 버전 1이 곧 정식 릴리즈 된다고 합니다..
v1.0 GA Release in 2018 !?
AI / 머신러닝 기반의 비정상 행위 탐지 (Anomaly Detection)
서비스 메시(Service Mesh) 패턴 지원
쿠버네티스 지원 강화
https://konghq.com/blog/announcing-kong-1-0/
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
API Gateway가 필요하다면 Kong을 추천한다.
API Gateway의 관리에 Terraform을 도입해보자.
SUMMARY
Copyright © 2018 All Rights Reserved.
recruiting
카사와 함께 성장할 개발자를 찾습니다.
Byungjin Park · posquit0.com · posquit0
카사(Kasa)에서는 엔지니어 분들을 상시 채용하고 있으니 관심이 있으시다면 편하게 연락 주세요! 😁😁
Open Positions
Backend / DevOps / BigData Platform / Security Compliance
카사는 전세계 모든 자산에 누구든 투자할 수 있게 한다는 미션 아래 부동산 투자의 높은 장벽을
블록체인을 활용한 기술 혁신으로 해결하는 프롭테크(PropTech) 기업입니다.
Make the world’s assets accessible to all
카사 엔지니어링 채용에 관심이 있나요?

간단한 본인 소개와 함께 레쥬메 형식의 이력서를 첨부하여 careers@kasa.network 로 연락주시면, 담당자가 확인 후 연락 드리겠습니다.
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0
THE END
Thank you for attention :)
Visit my AMA (https://github.com/posquit0/ama) for any question!
감사합니다!
Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0

Contenu connexe

Tendances

Observability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing PrimerObservability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing PrimerVMware Tanzu
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & DevelopmentAshok Pundit
 
OPA: The Cloud Native Policy Engine
OPA: The Cloud Native Policy EngineOPA: The Cloud Native Policy Engine
OPA: The Cloud Native Policy EngineTorin Sandall
 
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red HatSpeed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red HatHostedbyConfluent
 
Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...Kai Wähner
 
API Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API ManagementAPI Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API ManagementBizTalk360
 
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API ManagerWSO2
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsTessa Mero
 
Gatekeeper: API gateway
Gatekeeper: API gatewayGatekeeper: API gateway
Gatekeeper: API gatewayChengHui Weng
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & GuidelinesPrabath Siriwardena
 
API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)Bishoy Demian
 
How Netflix Is Solving Authorization Across Their Cloud
How Netflix Is Solving Authorization Across Their CloudHow Netflix Is Solving Authorization Across Their Cloud
How Netflix Is Solving Authorization Across Their CloudTorin Sandall
 
Architecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyArchitecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyWSO2
 
Distributed Tracing with Jaeger
Distributed Tracing with JaegerDistributed Tracing with Jaeger
Distributed Tracing with JaegerInho Kang
 
Intro to DefectDojo at OWASP Switzerland
Intro to DefectDojo at OWASP SwitzerlandIntro to DefectDojo at OWASP Switzerland
Intro to DefectDojo at OWASP SwitzerlandMatt Tesauro
 
Secure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with KeycloakSecure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with KeycloakRed Hat Developers
 

Tendances (20)

Observability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing PrimerObservability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing Primer
 
REST API Authentication Methods.pdf
REST API Authentication Methods.pdfREST API Authentication Methods.pdf
REST API Authentication Methods.pdf
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
OPA: The Cloud Native Policy Engine
OPA: The Cloud Native Policy EngineOPA: The Cloud Native Policy Engine
OPA: The Cloud Native Policy Engine
 
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red HatSpeed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
 
Prometheus monitoring
Prometheus monitoringPrometheus monitoring
Prometheus monitoring
 
Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...
 
API Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API ManagementAPI Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API Management
 
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
Gatekeeper: API gateway
Gatekeeper: API gatewayGatekeeper: API gateway
Gatekeeper: API gateway
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & Guidelines
 
API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)
 
How Netflix Is Solving Authorization Across Their Cloud
How Netflix Is Solving Authorization Across Their CloudHow Netflix Is Solving Authorization Across Their Cloud
How Netflix Is Solving Authorization Across Their Cloud
 
Microservices
MicroservicesMicroservices
Microservices
 
Architecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyArchitecting an Enterprise API Management Strategy
Architecting an Enterprise API Management Strategy
 
Distributed Tracing with Jaeger
Distributed Tracing with JaegerDistributed Tracing with Jaeger
Distributed Tracing with Jaeger
 
Kong
KongKong
Kong
 
Intro to DefectDojo at OWASP Switzerland
Intro to DefectDojo at OWASP SwitzerlandIntro to DefectDojo at OWASP Switzerland
Intro to DefectDojo at OWASP Switzerland
 
Secure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with KeycloakSecure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with Keycloak
 

Similaire à AManaging Kong API Gateway with Terraform

[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...
[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...
[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...Byungjin Park
 
글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)
글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)
글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)Channy Yun
 
블로코 웨비나 세션1 - 박헌영 CTO
블로코 웨비나 세션1 - 박헌영 CTO블로코 웨비나 세션1 - 박헌영 CTO
블로코 웨비나 세션1 - 박헌영 CTOBLOCKO
 
How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)Channy Yun
 
Google Cloud Platform - Apigee
Google Cloud Platform - ApigeeGoogle Cloud Platform - Apigee
Google Cloud Platform - Apigeebliexsoft
 
멀티클라우드 Service Mesh
멀티클라우드 Service Mesh멀티클라우드 Service Mesh
멀티클라우드 Service MeshJeong-Ho Na
 
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API 안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API Gosu Ok
 
Provisioning Dedicated Game Server on Kubernetes Cluster
Provisioning Dedicated Game Server on Kubernetes ClusterProvisioning Dedicated Game Server on Kubernetes Cluster
Provisioning Dedicated Game Server on Kubernetes ClusterJinwoong Kim
 
[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...
[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...
[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...OpenStack Korea Community
 
애플리케이션 최적화를 위한 컨테이너 인프라 구축
애플리케이션 최적화를 위한 컨테이너 인프라 구축애플리케이션 최적화를 위한 컨테이너 인프라 구축
애플리케이션 최적화를 위한 컨테이너 인프라 구축rockplace
 
HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)
HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)
HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)JeongHeon Lee
 
윤정식 포트폴리오
윤정식 포트폴리오윤정식 포트폴리오
윤정식 포트폴리오정식 윤
 
AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018
AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018
AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018Amazon Web Services Korea
 
Mozilla 오픈 웹 모바일 플랫폼 (2012)
Mozilla 오픈 웹 모바일 플랫폼 (2012)Mozilla 오픈 웹 모바일 플랫폼 (2012)
Mozilla 오픈 웹 모바일 플랫폼 (2012)Channy Yun
 
Do IoT Yourself 3rd : Open API - revision 3
Do IoT Yourself 3rd : Open API - revision 3Do IoT Yourself 3rd : Open API - revision 3
Do IoT Yourself 3rd : Open API - revision 3Hyunghun Cho
 
웹 2.0 기술 소개 (2006)
웹 2.0 기술 소개 (2006)웹 2.0 기술 소개 (2006)
웹 2.0 기술 소개 (2006)Channy Yun
 
SOSCON 2017 - Backend.AI
SOSCON 2017 - Backend.AISOSCON 2017 - Backend.AI
SOSCON 2017 - Backend.AIJoongi Kim
 
자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021
자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021
자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021AWSKRUG - AWS한국사용자모임
 
Meetup tools for-cloud_native_apps_meetup20180510-vs
Meetup tools for-cloud_native_apps_meetup20180510-vsMeetup tools for-cloud_native_apps_meetup20180510-vs
Meetup tools for-cloud_native_apps_meetup20180510-vsminseok kim
 
락플레이스 OpenShift Q&A 토크쇼 발표자료
락플레이스 OpenShift Q&A 토크쇼 발표자료락플레이스 OpenShift Q&A 토크쇼 발표자료
락플레이스 OpenShift Q&A 토크쇼 발표자료rockplace
 

Similaire à AManaging Kong API Gateway with Terraform (20)

[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...
[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...
[GDG DevFest Seoul 2017] JAMstack이 GitHub와 CloudFlare를 만날 때 고성능 웹 어플리케이션 호스팅은...
 
글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)
글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)
글로벌 지도 API 서비스 현황과 미래 - 한국지리정보학회 (2014)
 
블로코 웨비나 세션1 - 박헌영 CTO
블로코 웨비나 세션1 - 박헌영 CTO블로코 웨비나 세션1 - 박헌영 CTO
블로코 웨비나 세션1 - 박헌영 CTO
 
How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)
 
Google Cloud Platform - Apigee
Google Cloud Platform - ApigeeGoogle Cloud Platform - Apigee
Google Cloud Platform - Apigee
 
멀티클라우드 Service Mesh
멀티클라우드 Service Mesh멀티클라우드 Service Mesh
멀티클라우드 Service Mesh
 
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API 안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
 
Provisioning Dedicated Game Server on Kubernetes Cluster
Provisioning Dedicated Game Server on Kubernetes ClusterProvisioning Dedicated Game Server on Kubernetes Cluster
Provisioning Dedicated Game Server on Kubernetes Cluster
 
[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...
[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...
[OpenInfra Days Korea 2018] (Track 4) Provisioning Dedicated Game Server on K...
 
애플리케이션 최적화를 위한 컨테이너 인프라 구축
애플리케이션 최적화를 위한 컨테이너 인프라 구축애플리케이션 최적화를 위한 컨테이너 인프라 구축
애플리케이션 최적화를 위한 컨테이너 인프라 구축
 
HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)
HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)
HTML5 기반 다매체 연동형 서비스 발전 방향(티비스톰 정운교 이사)
 
윤정식 포트폴리오
윤정식 포트폴리오윤정식 포트폴리오
윤정식 포트폴리오
 
AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018
AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018
AWS 클라우드 네트워크 서비스 알아보기::서지혜::AWS Summit Seoul 2018
 
Mozilla 오픈 웹 모바일 플랫폼 (2012)
Mozilla 오픈 웹 모바일 플랫폼 (2012)Mozilla 오픈 웹 모바일 플랫폼 (2012)
Mozilla 오픈 웹 모바일 플랫폼 (2012)
 
Do IoT Yourself 3rd : Open API - revision 3
Do IoT Yourself 3rd : Open API - revision 3Do IoT Yourself 3rd : Open API - revision 3
Do IoT Yourself 3rd : Open API - revision 3
 
웹 2.0 기술 소개 (2006)
웹 2.0 기술 소개 (2006)웹 2.0 기술 소개 (2006)
웹 2.0 기술 소개 (2006)
 
SOSCON 2017 - Backend.AI
SOSCON 2017 - Backend.AISOSCON 2017 - Backend.AI
SOSCON 2017 - Backend.AI
 
자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021
자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021
자바개발자가 최대한 빠르게 서비스를 오픈하는 방법 - 최진환 (드라마앤컴퍼니) :: AWS Community Day Online 2021
 
Meetup tools for-cloud_native_apps_meetup20180510-vs
Meetup tools for-cloud_native_apps_meetup20180510-vsMeetup tools for-cloud_native_apps_meetup20180510-vs
Meetup tools for-cloud_native_apps_meetup20180510-vs
 
락플레이스 OpenShift Q&A 토크쇼 발표자료
락플레이스 OpenShift Q&A 토크쇼 발표자료락플레이스 OpenShift Q&A 토크쇼 발표자료
락플레이스 OpenShift Q&A 토크쇼 발표자료
 

Plus de Byungjin Park

HashiCorp 한국 사용자 모임 소개
HashiCorp 한국 사용자 모임 소개HashiCorp 한국 사용자 모임 소개
HashiCorp 한국 사용자 모임 소개Byungjin Park
 
Posquit0 - Fabric을 이용한 ssh streamlining
Posquit0 - Fabric을 이용한 ssh streamliningPosquit0 - Fabric을 이용한 ssh streamlining
Posquit0 - Fabric을 이용한 ssh streamliningByungjin Park
 
Monkey D. Luffy - 리더의 격을 배우다 by Posquit0
Monkey D. Luffy - 리더의 격을 배우다 by Posquit0Monkey D. Luffy - 리더의 격을 배우다 by Posquit0
Monkey D. Luffy - 리더의 격을 배우다 by Posquit0Byungjin Park
 
2013 PoApper Introduction
2013 PoApper Introduction2013 PoApper Introduction
2013 PoApper IntroductionByungjin Park
 
PoApper Introduction
PoApper IntroductionPoApper Introduction
PoApper IntroductionByungjin Park
 
Pivotal tracker를 활용한 팀 프로젝트 관리
Pivotal tracker를 활용한 팀 프로젝트 관리Pivotal tracker를 활용한 팀 프로젝트 관리
Pivotal tracker를 활용한 팀 프로젝트 관리Byungjin Park
 

Plus de Byungjin Park (6)

HashiCorp 한국 사용자 모임 소개
HashiCorp 한국 사용자 모임 소개HashiCorp 한국 사용자 모임 소개
HashiCorp 한국 사용자 모임 소개
 
Posquit0 - Fabric을 이용한 ssh streamlining
Posquit0 - Fabric을 이용한 ssh streamliningPosquit0 - Fabric을 이용한 ssh streamlining
Posquit0 - Fabric을 이용한 ssh streamlining
 
Monkey D. Luffy - 리더의 격을 배우다 by Posquit0
Monkey D. Luffy - 리더의 격을 배우다 by Posquit0Monkey D. Luffy - 리더의 격을 배우다 by Posquit0
Monkey D. Luffy - 리더의 격을 배우다 by Posquit0
 
2013 PoApper Introduction
2013 PoApper Introduction2013 PoApper Introduction
2013 PoApper Introduction
 
PoApper Introduction
PoApper IntroductionPoApper Introduction
PoApper Introduction
 
Pivotal tracker를 활용한 팀 프로젝트 관리
Pivotal tracker를 활용한 팀 프로젝트 관리Pivotal tracker를 활용한 팀 프로젝트 관리
Pivotal tracker를 활용한 팀 프로젝트 관리
 

AManaging Kong API Gateway with Terraform

  • 1. Byungjin Park · posquit0.com · posquit0Copyright © 2018 All Rights Reserved. 박 병진(Byungjin Park) · Site Reliability Engineer @ KASA Managing Kong API Gateway with Terraform Terraform으로 Kong API Gateway 관리하기 서울 밋업 #2 at HashiCorp KRUG Oct 23, 2018
  • 2. Copyright © 2018 All Rights Reserved. speaker 발표자 소개 Byungjin Park · posquit0.com · posquit0 박병진 / @posquit0 (현) Site Reliability Engineer @ Kasa (전) Software Architect @ OMNIOUS DEFCON CTF 국제해킹대회 World Final 5회 진출 Node.js와 Python을 좋아합니다. 터미널 환경을 사랑하는 굉장한 Vim 덕후입니다. GitHub에서 활발하게 오픈소스 활동을 하고 있습니다. 서비스 개발 및 운영과 관련된 모든 일을 즐깁니다.
  • 3. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 api gateway
  • 4. Copyright © 2018 All Rights Reserved. api gateway MSA (MICROSERVICES ARCHITECTURE) Byungjin Park · posquit0.com · posquit0 API Gateway는 마이크로 서비스 아키텍처와 많은 연관을 가지고 있습니다. MSA 는 하나의 큰 어플리케이션을 독립적인 역할을 수행하는 여러 마이크로 서비스로 쪼개어 조합함으로써 개별 서비스의 복잡도를 줄이는 설계 패턴 입니다. Monolithic Micro-services Architecture User Auth Order Payment Notification CAR RENTAL SERVICE CAR RENTAL SERVICE User Auth Payment Noti Order
  • 5. Copyright © 2018 All Rights Reserved. api gateway COMMUNICATION IN MSA Byungjin Park · posquit0.com · posquit0 가장 큰 단점 중 하나는 운영해야 하는 서비스의 수가 늘어나면서 굉장히 복잡해지는 통신(Communication) 문제 입니다. 하지만, MSA 가 장점만을 가지는 것은 아닙니다. Client-Server Communication Inter Service Communication North - South East - West
  • 6. Copyright © 2018 All Rights Reserved. api gateway COMMUNICATION IN MSA Byungjin Park · posquit0.com · posquit0 이러한 문제들을 효율적으로 해결하기 위해 API Gateway 와 Service Mesh 등이 나타났습니다. MSA 에서는 클라이언트와 서비스 간의 통신 뿐만 아니라 서비스 간의 통신 또한 고려 해야 합니다. Client-Server Communication Inter Service Communication North - South East - West
  • 7. Copyright © 2018 All Rights Reserved. api gateway WHY USE API GATEWAY? Byungjin Park · posquit0.com · posquit0 API Gateway는 MSA 에서 클라이언트와 서버 간의 통신 문제를 해결하기 위한 솔루션 입니다. 하나의 게이트웨이로서 클라이언트와의 통신을 담당할 수 있으며, 각 마이크로서비스가 중복으로 가져야 했던 기능 레이어들을 대신 처리할 수 있습니다.
  • 8. Copyright © 2018 All Rights Reserved. api gateway CANDIDATES Byungjin Park · posquit0.com · posquit0 이러한 API Gateway 를 구현한 오픈소스 프로젝트 혹은 엔터프라이즈 서비스 들이 이미 시장에 많이 존재 합니다.
  • 9. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 kong
  • 10. Copyright © 2018 All Rights Reserved. kong KONG API GATEWAY Byungjin Park · posquit0.com · posquit0 Apache 라이센스로 이용 가능한 커뮤니티 에디션과, 고급 기능 및 기술 지원이 제공되는 엔터프라이즈 에디션이 있습니다. Kong는 이미 널리 사용되고 있는 Nginx 웹 서버를 기반으로 Lua 를 통해 기능이 확장된 오픈소스 API 게이트웨이 입니다. Cloud-native, fast, scalable, and distributed Microservice Abstraction Layer (also known as an API Gateway, or in some cases Service Mesh) https://github.com/kong/kong License Model - Community Edition (CE) - Enterprise Edition (EE) Nginx / OpenResty 을 기반으로하여 Lua로 확장 가능한 오픈소스 API 게이트웨이 NGINX OpenResty Clustering & Datastore Plugins RESTful Administration API
  • 11. Copyright © 2018 All Rights Reserved. kong WHY USE KONG? Byungjin Park · posquit0.com · posquit0 당연히 Lua 스크립트를 통해 직접 커스텀 플러그인을 제작하여 활용할 수도 있습니다. Kong은 인증, 보안, 모니터링, 로깅 등 API Gateway 에 필요한 많은 기능을 기본 플러그인을 통해 제공하고 있습니다. Features API Gateway를 위한 다양한 기능을 기본 플러그인으로 제공 - Authentication - Security - Traffic Control - Request / Response Transformation - Serverless - Analytics & Monitoring - Logging
  • 12. Copyright © 2018 All Rights Reserved. kong WHY USE KONG? Byungjin Park · posquit0.com · posquit0 전세계 개발자들이 관련 프로젝트 및 플러그인을 개발하고 있으며, Kong을 주제로한 밋업 또한 전세계에서 진행되고 있습니다. Kong은 커뮤니티 에디션을 통해 강력한 커뮤니티 생태계를 가지고 있습니다. Ecosystem 무료 커뮤니티 에디션(CE) 을 중심으로 한 강력한 오픈소스 생태계 - 4,500,000+ 다운로드 수 - 100+ 오픈소스 컨트리뷰터 - 36,000+ 커뮤니티 참여자 - 100+ 전세계 밋업 진행 - 4000+ Kong 관련 프로젝트 - 500+ Kong 플러그인 Kong Hub: Kong 기능 확장 모음 (https://docs.konghq.com/hub/) Kong Nation: Kong 커뮤니티 포럼 (https://discuss.konghq.com)
  • 13. Copyright © 2018 All Rights Reserved. kong ENTERPRISE EDITION Byungjin Park · posquit0.com · posquit0 다만, 가격이… 🙄🙄🙄 Kong 엔터프라이즈 에디션은 기술 지원, 추가 플러그인, 관리자 대시보드 등을 추가 지원합니다. Benefits - Kong Manager: 웹 기반 관리자 대시보드 - Kong Vitals: 자체 모니터링 대시보드 - Kong Dev Portal: 개발자 포탈. OpenAPI 기반의 API 문서 제공 - Admin API에 대한 RBAC(Role Based Access Control) 지원 - 24/7 기술 지원 - 추가적인 고급 플러그인 다수 제공 - OpenID Connect - OAuth 2.0 Introspection - Enterprise Rate Limiting - Edge Caching
  • 14. Copyright © 2018 All Rights Reserved. kong COMPONENTS Byungjin Park · posquit0.com · posquit0 현재 Kong이 공식 지원하는 데이터 저장소는 PostgreSQL과 Cassandrda 입니다. Kong CE는 관리자 API, 프록시 API, 데이터 저장소로 구성 됩니다. Kong Proxy API Kong Admin API Data Store Kong Admin API API Gateway 설정 관리 목적의 관리자 API 기본 8001(HTTP), 8444(HTTPS) 포트 이용 Kong Proxy API Admin API를 통해 구성된 API Gateway의 엔드포인트 모음 기본 8000(HTTP), 8443(HTTPS) 포트 이용 Data Store Kong 의 API 오브젝트(서비스, 라우트, 컨슈머 등) 저장소 Postgres, Cassandra 지원
  • 15. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 꼭 알아두어야 할 API 오브젝트로는 Service, Route, Consumer, Credential, Plugin 이 있습니다. Kong API Gateway를 구성하는 작업은 Kong Admin API의 오브젝트를 관리하는 것이라 생각하면 됩니다. Service Route Consumer Plugin Upstream Target Credential SNI Certificate API deprecated
  • 16. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 프로토콜은 현재 HTTP/S, HTTP2, WebSocket을 지원 합니다. 서비스(Service) 오브젝트는 API Gateway에 연결 되어 클라이언트 요청을 전달 할 업스트림 서비스를 정의합니다. Service Kong API Gateway에 연결 될 업스트림 서비스를 의미 프로토콜, 호스트, 포트, 경로 설정 User Service
  • 17. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 정규표현식과 우선순위를 지원하여 유연하게 설정을 할 수 있습니다. 라우트(Route) 오브젝트는 클라이언트의 요청(HTTP Method, Path 등)에 따라 특정 서비스로 해당 요청을 전달하기 위한 규칙을 정의합니다. Service Kong API Gateway에 연결 될 업스트림 서비스 프로토콜, 호스트, 포트, 경로 설정 User Service Route 클라이언트의 요청을 서비스로 포워딩하기 위한 규칙(Rule) 프로토콜, 호스트, 경로, HTTP 메소드 설정 정규표현식과 우선순위 지원 POST /users GET /users/me
  • 18. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 업스트림 객체를 사용하지 않아도 Kong API Gateway는 사용 가능합니다. 업스트림(Upstream) 오브젝트는 Kong API Gateway 자체적으로 L7 로드밸런싱 기능을 지원하고자 도입된 가상호스트 개념입니다. Upstream 로드밸런싱을 지원하기 위한 가상 호스트(Virtual Host) Active Health Check 및 Passive Health Check (Circuit Breaker) 지원 user.service POST /users GET /users/me User Service
  • 19. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 가중치 값을 활용하여 카나리 배포(Canary Deployment)를 구현하는 것도 가능합니다. 타겟(Target) 오브젝트는 업스트림에 연결되어 분배된 요청을 처리 할 백엔드 서비스를 정의합니다. Upstream 로드밸런싱을 지원하기 위한 가상 호스트(Virtual Host) Active Health Check 및 Passive Health Check (Circuit Breaker) 지원 User v1 User v2 Target 호스트와 포트 쌍으로 구성된 가상호스트로의 요청을 분배할 타겟 로드밸런싱 가중치(Weight) 지원 user.service POST /users GET /users/me User Service
  • 20. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 같은 서비스 사용자라도 플랫폼 별(Web, Android, iOS 등)로 컨슈머를 만들어 연결하는 것도 가능하다. 컨슈머(Consumer) 오브젝트는 API를 소비할 사용자를 정의하며, 이를 통해 인증 / 접근제어 / 트래킹 등 API Gateway의 여러 기능을 활용할 수 있습니다. Consumer API 소비자를 나타내며 인증 / 접근제어 / 트래킹 등 여러 목적으로 활용 custom_id 필드를 통해 서비스 상의 사용자 ID와 매핑 가능 컨슈머와 사용자가 반드시 1:1 관계일 필요는 없음 user.service consumer POST /users GET /users/me User Service User v1 User v2
  • 21. Copyright © 2018 All Rights Reserved. kong API OBJECTS Byungjin Park · posquit0.com · posquit0 이미 제공되는 플러그인을 활용할 뿐만 아니라, Lua로 직접 커스텀 플러그인을 제작하여 활용할 수 있습니다. 플러그인(Plugin) 오브젝트는 Kong API Gateway의 가장 강력한 기능으로 HTTP 요청-응답 플로우 상에 원하는 기능을 확장할 수 있습니다. Consumer API 소비자를 나타내며 인증 / 접근제어 / 트래킹 등 여러 목적으로 활용 custom_id 필드를 통해 서비스 상의 사용자 ID와 매핑 가능 컨슈머와 사용자가 반드시 1:1 관계일 필요는 없음 user.service consumer Plugin HTTP 요청-응답 흐름 상에 실행될 수 있는 확장 기능 인증 / 접근 제어 / 요청, 응답 가공 / 로그, 메트릭 전달 등 plugin POST /users GET /users/me User Service User v1 User v2
  • 22. Copyright © 2018 All Rights Reserved. kong DISTRIBUTIONS Byungjin Park · posquit0.com · posquit0 Kong은 다양한 배포 방법을 지원하고 있어 쉽고 빠르게 Kong API Gateay를 사용해볼 수 있습니다.
  • 23. Copyright © 2018 All Rights Reserved. kong INSTALL Byungjin Park · posquit0.com · posquit0 데이터베이스 구성 후 DB 마이그레이션 작업을 통해 DB 테이블을 생성하고, Kong 서비스를 해당 DB와 연결하여 실행하면 됩니다. Set-up DB Migrate DB Run Kong 1. Set up Database Kong의 데이터 저장소로 Postgres 혹은 Cassandra 로 DB 구성 2. Migrate Database Kong의 데이터베이스 마이그레이션 명령어를 수행하여 DB 스키마 생성 3. Run Kong API Gateway 구성한 DB 연결 정보와 함께 Kong 서비스 실행 Kong의 설치 작업은 크게 세 단계로 구성됩니다.
  • 24. Copyright © 2018 All Rights Reserved. kong INSTALL WITH DOCKER Byungjin Park · posquit0.com · posquit0 도커(Docker)로 Kong을 설치하기 위해서는 우선 네트워크와 데이터베이스를 구성해야 합니다. 1. Set up Database - 다른 도커 컨테이너와 통신하기 위한 네트워크 생성 - Postgres 도커 컨테이너 실행 # Create a custom network to allow the containers # to discover and communicate with each other $ docker network create kong-net # Run Postgres container $ docker run -d --name kong-database --network=kong-net -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" postgres:9.6
  • 25. Copyright © 2018 All Rights Reserved. kong INSTALL WITH DOCKER Byungjin Park · posquit0.com · posquit0 데이터베이스 구동 후에는 DB 테이블을 생성하기 위하여 Kong 이미지를 통해 마이그레이션 작업을 수행합니다. 2. Migrate Database - Kong 도커 이미지를 통해 DB 마이그레이션 작업 수행 # Run the migrations with an Kong container $ docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" kong:latest kong migrations up
  • 26. 3. Run Kong API Gateway - Kong API Gateway 도커 컨테이너 실행 - 포트 번호 - 8000: Kong Proxy(HTTP) - 8443: Kong Proxy(HTTPS) - 8001: Kong Admin(HTTP) - 8444: Kong Admin(HTTPS) Copyright © 2018 All Rights Reserved. kong INSTALL WITH DOCKER Byungjin Park · posquit0.com · posquit0 마이그레이션 작업이 끝나면, Kong 도커 컨테이너를 실행하여 Kong Proxy와 Kong Admin 서비스의 포트를 개방합니다. # Start a Kong container that will connect to database $ docker run -d --name kong --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" -e "KONG_PROXY_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong:latest
  • 27. Validate Kong is running - Kong Admin API에 요청을 보내 Kong Admin 동작 확인 Copyright © 2018 All Rights Reserved. kong INSTALL WITH DOCKER Byungjin Park · posquit0.com · posquit0 Kong 설치가 완료되면 Admin API에 HTTP 요청을 보내 Kong이 정상적으로 동작하는지 확인합니다. $ curl -i http://localhost:8001/
 HTTP/1.1 200 OK Date: Sun, 21 Oct 2018 12:03:02 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Access-Control-Allow-Origin: * Server: kong/0.14.1 Content-Length: 5659
  • 28. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 kong management
  • 29. Using CLI based HTTP Client Command - API First Design 을 기반으로 하여 HTTP로 모든 기능 이용 가능 - 가장 빠르게 Kong 을 관리해 볼 수 있는 방법 Copyright © 2018 All Rights Reserved. kong management USING CLI Byungjin Park · posquit0.com · posquit0 Kong 은 HTTP 기반의 Admin API 를 제공해주기 때문에 다른 도구 설치 없이도 빠르게 API Gateway를 구성해 볼 수 있습니다. # Add user service $ curl -i -X POST --url http://localhost:8001/services/ --data 'name=user-service' --data 'protocol=http' --data 'host=user.service' --data 'port=80' --data 'path=/'
  • 30. Using CLI based HTTP Client Command - API First Design 을 기반으로 하여 HTTP로 모든 기능 이용 가능 - 가장 빠르게 Kong 을 관리해 볼 수 있는 방법 Copyright © 2018 All Rights Reserved. kong management USING CLI Byungjin Park · posquit0.com · posquit0 하지만 API Gateway를 설정하기 위하여 매번 HTTP 요청 명령어를 작성하는 것은 너무나 번거로운 일 입니다. # Add user service $ curl -i -X POST --url http://localhost:8001/services/ --data 'name=user-service' --data 'protocol=http' --data 'host=user.service' --data 'port=80' --data 'path=/' Problems - 매번 쿼리 작성하기 귀찮음…
  • 31. Using GUI based HTTP Client - Kong Admin API 엔드포인트를 미리 등록 - 디렉토리 기능을 통한 API 엔드포인트 분류 - 환경(로컬, 개발, 운영 등)에 따른 변수 관리 - Postman / Insomnia / ETC Copyright © 2018 All Rights Reserved. USING GUI HTTP CLIENT Byungjin Park · posquit0.com · posquit0 Postman, Insomnia 와 같은 GUI 기반의 HTTP 클라이언트 앱을 사용한다면 Kong 을 보다 쉽게 관리할 수 있습니다. kong management
  • 32. Using GUI based HTTP Client - Kong Admin API 엔드포인트를 미리 등록 - 디렉토리 기능을 통한 API 엔드포인트 분류 - 환경(로컬, 개발, 운영 등)에 따른 변수 관리 - Postman / Insomnia / ETC Copyright © 2018 All Rights Reserved. USING GUI HTTP CLIENT Byungjin Park · posquit0.com · posquit0 그러나, 이 또한 현재 API Gateway가 어떻게 설정되어 있는지 한 눈에 파악하기가 어렵습니다. kong management Problems - 현재 API Gateway 의 설정을 한 눈에 보기 어려움
  • 33. Admin Dashboard for Kong CE - Kong CE를 위한 오픈소스 관리자 대시보드 웹 (비공식) - Kong DB 백업/복구 기능 제공 - LDAP 을 통한 대시보드 접근제어 지원 - 이메일 / 슬랙 알림 기능 Copyright © 2018 All Rights Reserved. USING DASHBOARD Byungjin Park · posquit0.com · posquit0 Kong EE 의 관리자 대시보드에서 제공하는 기능과 거의 대등할 정도로 풍부한 기능을 제공합니다. (디자인도 이뻐요 👍) Konga More than just another GUI to Kong Admin API https://github.com/pantsel/konga Konga는 Kong 커뮤니티에서 오픈소스로 만들어져 관리되고 있는 Kong CE 용 관리자 대시보드입니다. kong management
  • 34. Problems API 게이트웨이 설정 변경에 대한 추적(Tracking) 필요 - “누가 예약 라우트 설정을 변경했지?” - “사용자 서비스 포트 번호는 왜 변경된거지?” - “IP 블랙 리스트 플러그인은 언제 추가한거지?” - “내가 이 설정을 변경해도 되나?” - “어제까지만 해도 잘 동작 하던게 왜 안되지!?” Copyright © 2018 All Rights Reserved. USING DASHBOARD Byungjin Park · posquit0.com · posquit0 누가, 언제, 무슨 설정을, 어떻게, 왜 변경해야 하는지 추적할 수 있어야 합니다. API Gateway의 설정이 점점 복잡해지고, 이를 다루는 엔지니어의 수가 증가함에 따라 또 다른 문제와 마주하게 됩니다. kong management
  • 35. Copyright © 2018 All Rights Reserved. TRACKING CHANGES Byungjin Park · posquit0.com · posquit0 설정의 변경사항을 추적하기 위해서는 감사 로그(Audit Log)를 남겨 추적하거나, 선언식 설정(Declarative Configuration)을 이용할 수 있습니다. kong management OR Audit Log Declarative Configuration
  • 36. Copyright © 2018 All Rights Reserved. TRACKING CHANGES Byungjin Park · posquit0.com · posquit0 선언식 설정을 이용하는 것에 비하여 이점이 없습니다. kong management Audit Log - 누가, 언제, 무엇을, 어떻게 변경 하였는지 기록 - 로그를 쉽게 검색할 수 있고 가시화하기 위한 또 다른 도구 필요 - 특정 그룹에 알림(Notification) 설정 필요 감사 로그(Audit Log)를 이용하는 것은 배보다 배꼽이 더 큰 해결책이 될 수 있으며,
  • 37. Copyright © 2018 All Rights Reserved. TRACKING CHANGES Byungjin Park · posquit0.com · posquit0 파일을 통해 설정을 관리할수 있기 때문에 여러 이점을 취할 수 있습니다. kong management Declarative Configuration - 명령식 설정(Imperative Configuration)과 다르게 현재 설정을 선언 - 설정 파일을 통해 버전 관리가 가능 - Terraform, Ansible, Puppet, Kubernetes 등 선언식 설정(Declarative Configuration)은 보통 명령식 설정(Imperative Configuration)과 많이 비교 됩니다.
  • 38. Copyright © 2018 All Rights Reserved. TERRAFORM Byungjin Park · posquit0.com · posquit0 AWS 인프라를 코드로 관리하기 위해 많이 사용되곤 합니다. HashiCorp의 테라폼(Terraform)은 다양한 플랫폼에서 사용할 수 있는 오픈소스 IaC(Infrastructure as Code) 도구 입니다. kong management A tool for building, changing, and combining infrastructure safely and efficiently https://www.terraform.io/ IaC (Infrastructure as Code) - 설정(Configuration)을 코드로 버전관리 - 코드 리뷰를 통한 협업과 실수 방지 - 테스트 가능 - 코드 실행을 통한 자동화(Automation) 및 재사용(Reuse)
  • 39. Copyright © 2018 All Rights Reserved. USING DECLARATIVE CONFIGURATION Byungjin Park · posquit0.com · posquit0 (공식 프로바이더는 아닙니다…😭😭) 오픈소스로 공개되어 있는 terraform-provider-kong 을 이용하면, 테라폼으로 인프라를 관리하던 경험을 그대로 Kong 관리에 가져올 수 있습니다. kong management Kong Provider for Terraform https://github.com/kevholditch/terraform-provider-kong Terraform Community Provider for Kong - 테라폼으로 Kong API Gateway 설정 가능 - Admin API 엔드포인트에 대한 Basic Auth와 API Key Auth 지원 - 거의 모든 API 오브젝트에 대한 설정 가능 - 테라폼 데이터 소스 및 임포트 지원
  • 40. Copyright © 2018 All Rights Reserved. USING DECLARATIVE CONFIGURATION Byungjin Park · posquit0.com · posquit0 위와 같이 HCL(HashiCorp Configuration Language) 로 선언식 설정을 할 수 있습니다. kong management Kong Provider for Terraform https://github.com/kevholditch/terraform-provider-kong provider "kong" { kong_admin_uri = "http://admin.my-kong.com:8001" kong_admin_username = "youruser" kong_admin_password = "yourpass" } resource "kong_route" "route" { protocols = [ "http", "https" ] methods = [ "GET", "POST" ] hosts = [ "example2.com" ] paths = [ "/test" ] strip_path = false preserve_host = true service_id = "${kong_service.service.id}" }
  • 41. Copyright © 2018 All Rights Reserved. ALTERNATIVES: KONGFIG Byungjin Park · posquit0.com · posquit0 Kong 만을 선언식 설정으로 관리하기 위한 도구도 있었더랍니다…ㅜㅜ kong management Declarative configuration for Kong https://github.com/mybuilder/kongfig - Kong 을 선언식 설정으로 관리하기 위해 만들어진 Node.js 기반 도구 - 테라폼과 사용법 유사 - 업데이트 안된지 오래 됨… - 최신 API 오브젝트 미지원… $ kongfig apply --path config.yml --host localhost:8001 plugins: - name: cors attributes: username: enabled: true config: credentials: false preflight_continue: false max_age: 7000 consumers: - username: iphone-app custom_id: foobar-1234
  • 42. Copyright © 2018 All Rights Reserved. ALTERNATIVES: KUBERNETES INGRESS CONTROLLER Byungjin Park · posquit0.com · posquit0 이를 이용하면 Kubernetes Manifest 파일을 통해 플러그인 / 컨슈머 / 인증서 관리를 할 수 있습니다. kong management Use Kong for Kubernetes Ingress https://github.com/Kong/kubernetes-ingress-controller - NGINX 인그레스 컨트롤러를 기반으로 한 Kong 인그레스 컨트롤러 - Ingress 오브젝트를 통해 서비스 / 라우트 / 업스트림 / 타겟 관리 자동화 - CRD(Custom Resource Definition)을 통해 플러그인 / 컨슈머 / 인증서 관리 - Kong 의 공식 쿠버네티스 배포판 apiVersion: configuration.konghq.com/v1 kind: KongPlugin metadata: name: http-svc-consumer-ratelimiting namespace: default config: key: value plugin: my-plugin Kong Ingress Controller는 Kong Inc. 에서 쿠버네티스를 적극 지원하기 위해 활발히 개발중인 공식 쿠버네티스 배포판입니다. $ kubectl apply -f kong-plugin.yaml
  • 43. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 demo
  • 44. Copyright © 2018 All Rights Reserved. GOALS Byungjin Park · posquit0.com · posquit0 주요 Kong API 오브젝트 및 플러그인을 다루어 보겠습니다. demo 이번 데모에서는 사용자 서비스와 할 일 서비스로 구성된 API Gateway를 테라폼을 이용하여 구성해보려 합니다. 모든 데모 코드는 https://github.com/posquit0/demo-terraform-provider-kong 에서 확인할 수 있습니다. Services - User Service - TODO Service Routes - User Routes - TODO Routes - Fallback Route Consumers - User - Admin - Anonymous Auth - Basic Auth Plugins - CORS - Rate Limiting - Correlation ID - Bot Detection
  • 45. Copyright © 2018 All Rights Reserved. ENVIRONMENTS Byungjin Park · posquit0.com · posquit0 이번 데모에서 사용하는 Terraform, Kong CE, Terraform Provider Kong 의 버전은 위와 같습니다. demo 모든 데모 코드는 https://github.com/posquit0/demo-terraform-provider-kong 에서 확인할 수 있습니다. Terraform v0.11.9 Kong CE v0.14.1 Terraform Kong Povider v1.7.0
  • 46. Copyright © 2018 All Rights Reserved. INSTALL TERRAFORM KONG PROVIDER Byungjin Park · posquit0.com · posquit0 위와 같이 직접 Kong 프로바이더를 다운로드 받아 설정해야 합니다. demo Kong은 테라폼의 공식 프로바이더가 아니기 때문에 terraform init 을 통해 자동 설치 되지 않습니다. 모든 데모 코드는 https://github.com/posquit0/demo-terraform-provider-kong 에서 확인할 수 있습니다. $ wget https://github.com/kevholditch/terraform-provider-kong/releases/download/v1.7.0/terraform-provider-kong_1.7.0_darwin_amd64.zip $ unzip -j terraform-provider-kong_1.7.0_darwin_amd64.zip terraform-provider-kong_v1.7.0 -d ~/.terraform.d/plugins/
  • 47. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 retrospective
  • 48. Copyright © 2018 All Rights Reserved. retrospective GOOD THINGS Byungjin Park · posquit0.com · posquit0 코드를 통한 버전 관리와 자동화를 할 수 있다는 넘나 행복합니다… 🤫🤫 Kong API Gateway 운영을 위하여 테라폼을 도입하게 되면서 많은 이득을 볼 수 있었습니다. Version Control 감사 로그(Audit Log) 없이 API Gateway 설정의 변경 이력 관리 Collaboration GitHub와 S3 상태 저장소를 사용하여 팀원과 설정을 함께 관리 No GUI Konga 혹은 Kong EE 와 같은 GUI 대시보드 없이 운영 가능 Automation 코드 실행 한 번으로 모든 설정을 빠르게 적용 Testing 운영 환경 적용 전 테스트용 API Gateway 설정 용이 Documentation 테라폼 코드 자체가 API Gateway 설정에 대한 문서 역할
  • 49. Copyright © 2018 All Rights Reserved. retrospective FUTURE WORKS Byungjin Park · posquit0.com · posquit0 또, 현재 테라폼 Kong Provider는 Consumer Credential 오브젝트를 지원하지 않으며, 그 외에도 부족한 기능이 존재하는게 사실 입니다. 아직 IaC 팀 문화 전파 및 자동화 측면에서 목표하는 바까지 도달하지는 못하였습니다. Access Control CI / CD 파이프라인 상의 특정 서비스 계정만 Admin API 접근 허가 Pull Request + Code Review GitHub 상에서 코드리뷰를 통해 PR이 병합되어야 변경사항 적용 CI / CD Pipeline Jenkins 와 통합하여 운영 / 스테이징 환경 배포 자동화 Terraform Kong Provider 오픈소스 기여를 통한 불완전한 기능 보완
  • 50. Copyright © 2018 All Rights Reserved. retrospective AWESOME KONG Byungjin Park · posquit0.com · posquit0 Kong CEO가 별풍선 주고 갔어요! 🤩 Kong API Gateway를 도입하면서 도움이 되었던 리소스를 큐레이션하여 GitHub에 공유하고 있습니다. https://github.com/posquit0/awesome-kong
  • 51. Copyright © 2018 All Rights Reserved. retrospective V1 RELEASE Byungjin Park · posquit0.com · posquit0 서비스 메시 패턴 지원이 기대 되네요! (Istio도 아직 못 써보았는데…😂😂) Kong 버전 1이 곧 정식 릴리즈 된다고 합니다.. v1.0 GA Release in 2018 !? AI / 머신러닝 기반의 비정상 행위 탐지 (Anomaly Detection) 서비스 메시(Service Mesh) 패턴 지원 쿠버네티스 지원 강화 https://konghq.com/blog/announcing-kong-1-0/
  • 52. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 API Gateway가 필요하다면 Kong을 추천한다. API Gateway의 관리에 Terraform을 도입해보자. SUMMARY
  • 53. Copyright © 2018 All Rights Reserved. recruiting 카사와 함께 성장할 개발자를 찾습니다. Byungjin Park · posquit0.com · posquit0 카사(Kasa)에서는 엔지니어 분들을 상시 채용하고 있으니 관심이 있으시다면 편하게 연락 주세요! 😁😁 Open Positions Backend / DevOps / BigData Platform / Security Compliance 카사는 전세계 모든 자산에 누구든 투자할 수 있게 한다는 미션 아래 부동산 투자의 높은 장벽을 블록체인을 활용한 기술 혁신으로 해결하는 프롭테크(PropTech) 기업입니다. Make the world’s assets accessible to all 카사 엔지니어링 채용에 관심이 있나요?
 간단한 본인 소개와 함께 레쥬메 형식의 이력서를 첨부하여 careers@kasa.network 로 연락주시면, 담당자가 확인 후 연락 드리겠습니다.
  • 54. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0 THE END Thank you for attention :) Visit my AMA (https://github.com/posquit0/ama) for any question! 감사합니다!
  • 55. Copyright © 2018 All Rights Reserved. Byungjin Park · posquit0.com · posquit0