Kong and Consul Lab For Golang

Overview

Kong and Consul Lab

Prerequisites

  1. docker

Deploy Consul Server

docker run -d -p 8500:8500 -p 8600:8600/udp --name=consul-server consul agent -server -ui -node=consul-server-1 -bootstrap-expect=1 -client=0.0.0.0  -log-level=debug

Deploy Home APP

docker build -t home-image .
docker run -d -p 8070:8070 --name=home-app home-image

Deploy Product APP

docker build -t product-image .
docker run -d -p 8090:8090 --name=product-app product-image

Deploy Career APP

docker build -t career-image .
docker run -d -p 8080:8080 --name=career-app career-image

Test DNS

please refer to this doc: https://www.consul.io/docs/discovery/dns

dig @127.0.0.1 -p 8600 home-app.service.consul ANY
dig @127.0.0.1 -p 8600 career-app.service.consul ANY
dig @127.0.0.1 -p 8600 product-app.service.consul ANY

Deploy Kong

  1. deploy postgress
docker run -d --name kong-database \
  -p 5432:5432 \
  -e "POSTGRES_USER=kong" \
  -e "POSTGRES_DB=kong" \
  -e "POSTGRES_PASSWORD=kong" \
  postgres:9.6
  1. Migrate postgress
docker run --rm --link kong-database:kong-database \
  -e "KONG_DATABASE=postgres" \
  -e "KONG_PG_HOST=kong-database" \
  -e "KONG_PG_PASSWORD=kong" \
  -e "KONG_PASSWORD=kong" \
  kong:latest kong migrations bootstrap
  1. Start Kong gateway
docker run -d --name kong \
  --link kong-database:kong-database\
  -e "KONG_DATABASE=postgres" \
  -e "KONG_PG_HOST=kong-database" \
  -e "KONG_PG_USER=kong" \
  -e "KONG_PG_PASSWORD=kong" \
  -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" \
  -e "KONG_DNS_RESOLVER=172.17.0.2:8600" \
  -p 8000:8000 \
  -p 8443:8443 \
  -p 8001:8001 \
  -p 8444:8444 \
  kong:latest

Add service and routes to KONG

Please refer to this doc: https://docs.konghq.com/gateway-oss/2.5.x/admin-api/#service-object

curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=home-svc' \
--data 'host=home-app.service.consul'

curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=product-svc' \
--data 'host=product-app.service.consul' \
--data 'path=/product'

curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=career-svc' \
--data 'host=career-app.service.consul' \
--data 'path=/career'

curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=blog-svc' \
--data 'host=career-app.service.consul' \
--data 'path=/blog'

Please refer to this doc: https://docs.konghq.com/gateway-oss/2.5.x/admin-api/#route-object

curl -i -X POST \
--url http://localhost:8001/services/home-svc/routes \
--data 'hosts[]=localhost' \
--data 'paths=/home'

curl -i -X POST \
--url http://localhost:8001/services/product-svc/routes \
--data 'hosts[]=localhost' \
--data 'paths=/product'

curl -i -X POST \
--url http://localhost:8001/services/career-svc/routes \
--data 'hosts[]=localhost' \
--data 'paths=/career'

curl -i -X POST \
--url http://localhost:8001/services/blog-svc/routes \
--data 'hosts[]=localhost' \
--data 'paths=/blog'

Deploy Konga

docker run --rm --link kong-database:kong-database \
pantsel/konga -c prepare -a postgres -u postgresql://kong:[email protected]:5432/konga_db

docker run -d --name konga \
-p 1337:1337 \
--link kong-database:kong-database \
-e "DB_ADAPTER=postgres" \
-e "DB_HOST=kong-database" \
-e "DB_USER=kong" \
-e "DB_PASSWORD=kong" \
-e "DB_DATABASE=konga_db" \
-e "KONGA_HOOK_TIMEOUT=120000" \
-e "NODE_ENV=production" \
pantsel/konga
Owner
Ridwan Dwi Siswanto
Jr. DevOps Engineer | System Administrator | Network Engineer
Ridwan Dwi Siswanto
golang consul tools

中文文档 consult A consul key/value tool for golang Usage install go get -u github.com/xxjwxc/[email protected] New Config conf := consulkv.NewConfig() With

xxj 4 Nov 11, 2021
Use Consul to do service discovery, use gRPC +kafka to do message produce and consume. Use redis to store result.

目录 gRPC/consul/kafka简介 gRPC+kafka的Demo gRPC+kafka整体示意图 限流器 基于redis计数器生成唯一ID kafka生产消费 kafka生产消费示意图 本文kafka生产消费过程 基于pprof的性能分析Demo 使用pprof统计CPU/HEAP数据的

null 38 Jan 31, 2021
Service registration and discovery, support etcd, zookeeper, consul, etc.

discox 支持类型 zookeeper etcd consul 示例 zookeeper server package main import ( "fmt" "github.com/goeasya/discox" "os" ) func main() { cfg := discox

goeasya 2 Oct 22, 2021
Consul Load-Balancing made simple

Notes From release 1.5.15 onward, fabio changes the default GOGC from 800 back to the golang default of 100.

fabio 6.8k Dec 2, 2021
Consul Load-Balancing made simple

Notes From release 1.5.15 onward, fabio changes the default GOGC from 800 back to the golang default of 100. Apparently this made some sense back in t

fabio 6.8k Dec 2, 2021
Consul K/V Store Implementation For Go

Consul K/V Store Implementation For Go Enables Consul to be used as a configuration source in go applications Dynamic Configuration with Consul's Key/

null 3 Dec 4, 2021
A golang library about socks5, supports all socks5 commands. That Provides server and client and easy to use. Compatible with socks4 and socks4a.

socks5 This is a Golang implementation of the Socks5 protocol library. To see in this SOCKS Protocol Version 5. This library is also compatible with S

chenhao zhang 31 Nov 12, 2021
Squzy - is a high-performance open-source monitoring, incident and alert system written in Golang with Bazel and love.

Squzy - opensource monitoring, incident and alerting system About Squzy - is a high-performance open-source monitoring and alerting system written in

Squzy 423 Dec 6, 2021
Hprose 1.0 for Golang (Deprecated). Hprose 2.0 for Golang is here:

Hprose for Golang Introduction Installation Usage Http Server Http Client Synchronous Invoking Synchronous Exception Handling Asynchronous Invoking As

Hprose 137 Oct 8, 2021
Transparent TLS and HTTP proxy serve and operate on all 65535 ports, with domain regex whitelist and rest api control

goshkan Transparent TLS and HTTP proxy serve & operating on all 65535 ports, with domain regex whitelist and rest api control tls and http on same por

Sina Ghaderi 7 Nov 30, 2021
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.1.1 and V5 in golang

中文文档 Gmqtt News: MQTT V5 is now supported. But due to those new features in v5, there area lots of breaking changes. If you have any migration problem

null 519 Dec 4, 2021
A LWM2M Client and Server implementation (For Go/Golang)

Betwixt - A LWM2M Client and Server in Go Betwixt is a Lightweight M2M implementation written in Go OMA Lightweight M2M is a protocol from the Open Mo

Zubair Hamed 51 Aug 28, 2021
Simple, fast and scalable golang rpc library for high load

gorpc Simple, fast and scalable golang RPC library for high load and microservices. Gorpc provides the following features useful for highly loaded pro

Aliaksandr Valialkin 647 Nov 18, 2021
Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.

Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.

gRPC Ecosystem 4.1k Dec 3, 2021
High-performance PHP application server, load-balancer and process manager written in Golang

RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supports running as a serv

Spiral Scout 6.1k Dec 5, 2021
protoc-gen-grpc-gateway-ts is a Typescript client generator for the grpc-gateway project. It generates idiomatic Typescript clients that connect the web frontend and golang backend fronted by grpc-gateway.

protoc-gen-grpc-gateway-ts protoc-gen-grpc-gateway-ts is a Typescript client generator for the grpc-gateway project. It generates idiomatic Typescript

gRPC Ecosystem 41 Nov 23, 2021
EasyTCP is a light-weight and less painful TCP server framework written in Go (Golang) based on the standard net package.

EasyTCP is a light-weight TCP framework written in Go (Golang), built with message router. EasyTCP helps you build a TCP server easily fast and less painful.

zxl 206 Nov 26, 2021
A lightweight and simplistic Tor library for golang

gotor A lightweight and simplistic Tor library for golang go get github.com/ripmeep/gotor import "github.com/ripmeep/gotor" Usage t := tor.TorConnecti

ripmeep 1 Nov 15, 2021
gRPC Web implementation for Golang and TypeScript

gRPC-Web: Typed Frontend Development gRPC is a modern, HTTP2-based protocol, that provides RPC semantics using the strongly-typed binary data format o

Improbable Engineering 3.7k Nov 30, 2021