【kong系列一】之 API网关 & kong 概述

来源:互联网 发布:vb编写程序代码 编辑:程序博客网 时间:2024/06/08 10:01

在介绍kong之前,让我们先了解一下API网关的概念。

一、API网关

API 网关,即API Gateway,是大型分布式系统中,为了保护内部服务而设计的一道屏障,可以提供高性能、高可用的 API托管服务,从而帮助服务的开发者便捷地对外提供服务,而不用考虑安全控制、流量控制、审计日志等问题,统一在网关层将安全认证,流量控制,审计日志,黑白名单等实现。网关的下一层,是内部服务,内部服务只需开发和关注具体业务相关的实现。网关可以提供API发布、管理、维护等主要功能。开发者只需要简单的配置操作即可把自己开发的服务发布出去,同时置于网关的保护之下。


(▲图片版权来自网络,版权归作者所有。)

API Gateway网关使得搭建一个新的应用服务变得简单、快捷、高效,同时,开发者将精力更多放在和业务紧密相关的工作上。

二、kong简介

Kong是一款基于Nginx_Lua模块写的高可用,易扩展由Mashape公司开源的API Gateway项目。由于Kong是基于Nginx的,所以可以水平扩展多个Kong服务器,通过前置的负载均衡配置把请求均匀地分发到各个Server,来应对大批量的网络请求。

Kong主要有三个组件:

  • Kong Server :基于nginx的服务器,用来接收API请求。
  • Apache Cassandra/PostgreSQL :用来存储操作数据。
  • Kong dashboard:官方推荐UI管理工具,当然,也可以使用 restfull 方式 管理admin api。

Kong采用插件机制进行功能定制,插件集(可以是0或n个)在API请求响应循环的生命周期中被执行。插件使用Lua编写,目前已有几个基础功能HTTP基本认证、密钥认证、CORS Cross-origin Resource Sharing,跨域资源共享)、TCPUDP、文件日志、API请求限流、请求转发以及nginx监控。

Kong 官网:https://getkong.org/ 插件介绍,帮助文档等。

Kong 源码:https://github.com/Mashape/kong 

Kong UI管理工具:https://github.com/PGBI/kong-dashboard 浏览器UI管理工具

Kong 桌面管理工具:https://github.com/ajaysreedhar/kongdash 有linux版本,windows版本,mac版本。

社区资源和工具

安装KONG的方式

可以选择不同的方式进行安装 ->重要

  • Kong Docker: A Dockerfile for running Kong in Docker.
  • Kong Packages: Pre-built packages for Debian, Red Hat, and OS X distributions (shipped with each release).
  • Kong Vagrant: A Vagrantfile for provisioning a development ready environment for Kong.
  • Kong Homebrew: Homebrew Formula for Kong.
  • Kong CloudFormation: Kong in a 1-click deployment for AWS EC2
  • Kong AWS AMI: Kong AMI on the AWS Marketplace.
  • Kong on Microsoft Azure: Run Kong using Azure Resource Manager.
  • Kong on Heroku: Deploy Kong on Heroku in one click.
  • Kong and Instaclustr: Let Instaclustr manage your Cassandra cluster.

第三方管理维护工具 

  • Ansible role for Kong on Ubuntu
  • Biplane: declarative configuration in Crystal Crystal语言版本声明式配置管理工具,利用配置,一键批量执行。
  • Bonobo: key management (with Mashery migration scripts)
  • Chef cookbook
  • Django Kong Admin: Admin UI in Python Python版本UI界面管理工具
  • Jungle: Admin UI in JavaScript   JS版本UI界面管理工具
  • Kong Dashboard: Admin UI in JavaScript  JS版本UI界面管理工具
  • Kong for CanopyCloud 
  • Kong image waiting for Cassandra
  • Kong image for Tutum
  • Kong-UI: Admin UI in JavaScript  JS版本UI界面管理工具
  • Konga: CLI Admin tool in JavaScript  JS客户端管理工具
  • Kongfig: Declarative configuration in JavaScript  JS语言版本声明式配置管理工具,利用配置,一键批量执行。
  • Kongfig on Puppet Forge
  • Puppet recipe
  • Puppet module on Puppet Forge
  • Python-Kong: Admin client library for Python    Python客户端。
  • .NET-Kong: Admin client library for .NET        .NET客户端。
  • kong-java-client: Admin client library for Java   java客户端

资源

  • The story behind Kong
  • Kong mentioned for the Empire PaaS
  • Realtime API Management with Pushpin
  • How to create your own Kong plugin
  • Instaclustr partners with Kong
  • How to deploy Kong on Azure
  • Kong intro in Portuguese
  • Kong tutorial in Japanese 1   
  • Kong tutorial in Japanese 2   
  • HAProxy + Kong   
  • Learn Lua in 15 minutes 
  • A Question about Microservices 
  • Kong Intro in Chinese

参考文献

参考文章1:KONG API Gateway-用户指南 https://github.com/cloudframeworks-apigateway/user-guide-apigateway#%E6%A1%86%E6%9E%B6%E8%AF%B4%E6%98%8E-%E4%B8%9A%E5%8A%A1

参考文章2:易观API网关—Kong分享篇https://www.analysys.cn/media/technology/detail/20014914/

参考文章3 KongNginx支持的API管理解决方案https://sdk.cn/news/1596


原创粉丝点击