KubeMQ Targets
KubeMQ Targets connects KubeMQ Message Broker with external systems and cloud services.
KubeMQ Targets allows us to build a message-based microservices architecture on Kubernetes with minimal efforts and without developing connectivity interfaces between KubeMQ Message Broker and external systems such as databases, cache, messaging, and REST-base APIs.
Key Features:
- Runs anywhere - Kubernetes, Cloud, on-prem, anywhere
- Stand-alone - small docker container / binary
- Single Interface - One interface all the services
- Any Service - Support all major services types (databases, cache, messaging, serverless, HTTP, etc.)
- Plug-in Architecture Easy to extend, easy to connect
- Middleware Supports - Logs, Metrics, Retries, and Rate Limiters
- Easy Configuration - simple yaml file builds your topology
Concepts
KubeMQ Targets building blocks are:
- Binding
- Source
- Target
- Request/Response
Binding
Binding is a 1:1 connection between Source and Target. Every Binding runs independently.
Target
Target is an external service that exposes an API allowing to interact and serve his functionalists with other services.
Targets can be Cache systems such as Redis and Memcached, SQL Databases such as Postgres and MySql, and even an HTTP generic Rest interface.
KubeMQ Targets integrate each one of the supported targets and service requests based on the request data.
A list of supported targets is below.
Standalone Services
Amazon Web Service (AWS)
Microsoft Azure
Source
The source is a KubeMQ connection (in subscription mode), which listens to requests from services and route them to the appropriate target for action, and return back a response if needed.
KubeMQ Targets supports all of KubeMQ's messaging patterns: Queue, Events, Events-Store, Command, and Query.
Request / Response
Request
A request is an object that sends to a designated target with metadata and data fields, which contains the needed information to perform the requested data.
Request Object Structure
Field |
Type |
Description |
metadata |
string, string object |
contains metadata information for action |
data |
bytes array |
contains raw data for action |
Example
Request to get a data from Redis cache for the key "log"
{
"metadata": {
"method": "get",
"key": "log"
},
"data": null
}
Response
The response is an object that sends back as a result of executing an action in the target
Response Object Structure
Field |
Type |
Description |
metadata |
string, string object |
contains metadata information result for action |
data |
bytes array |
contains raw data result |
is_error |
bool |
indicate if the action ended with an error |
error |
string |
contains error information if any |
Example
Response received on request to get the data stored in Redis for key "log"
{
"metadata": {
"result": "ok",
"key": "log"
},
"data": "SU5TRVJUIElOVE8gcG9zdChJRCxUSVRMRSxDT05URU5UKSBWQUxVRVMKCSAgICAgICAgICAgICAgICAgICAgICA"
}
Installation
Kubernetes
- Install KubeMQ Cluster
kubectl apply -f https://get.kubemq.io/deploy
- Run Redis Cluster deployment yaml
kubectl apply -f https://raw.githubusercontent.com/kubemq-hub/kubemq-targets/master/redis-example.yaml
- Run KubeMQ Targets deployment yaml
kubectl apply -f https://raw.githubusercontent.com/kubemq-hub/kubemq-targets/master/deploy-example.yaml
Download the appropriate version for your platform from KubeMQ Targets Releases. Once downloaded, the binary can be run from anywhere.
Ideally, you should install it somewhere in your PATH for easy use. /usr/local/bin is the most probable location.
Running KubeMQ Targets
./kubemq-targets --config config.yaml
Windows Service
- Download the Windows version from KubeMQ Targets Releases. Once downloaded, the binary can be installed from anywhere.
- Create config.yaml configuration file and save it to the same location of the Windows binary.
Service Installation
Run:
kubemq-targets.exe --service install
Service Installation With Username and Password
Run:
kubemq-targets.exe --service install --username {your-username} --password {your-password}
Service UnInstall
Run:
kubemq-sources.exe --service uninstall
Service Start
Run:
kubemq-targets.exe --service start
Service Stop
Run:
kubemq-targets.exe --service stop
Service Restart
Run:
kubemq-targets.exe --service restart
NOTE: When running under Windows service, all logs will be emitted to Windows Events Logs.
Configuration
Build Wizard
KubeMQ Targets configuration can be build with Build and Deploy tool https://build.kubemq.io/#/sources
Structure
Config file structure:
apiPort: 8080 # kubemq targets api and health end-point port
bindings:
- name: clusters-sources # unique binding name
properties: # Bindings properties such middleware configurations
log_level: error
retry_attempts: 3
retry_delay_milliseconds: 1000
retry_max_jitter_milliseconds: 100
retry_delay_type: "back-off"
rate_per_second: 100
source:
kind: kubemq.query # source kind
name: name-of-sources # source name
properties: # a set of key/value settings per each source kind
.....
target:
kind:cache.redis # target kind
name: name-of-target # targets name
properties: # a set of key/value settings per each target kind
- .....
Build Wizard
KubeMQ Targets configuration can be build with --build flag
./kubemq-targets --build
Properties
In bindings configuration, KubeMQ targets support properties setting for each pair of source and target bindings.
These properties contain middleware information settings as follows:
Logs Middleware
KubeMQ targets support level based logging to console according to as follows:
Property |
Description |
Possible Values |
log_level |
log level setting |
"debug","info","error" |
|
|
"" - indicate no logging on this bindings |
An example for only error level log to console:
bindings:
- name: sample-binding
properties:
log_level: error
source:
......
Retry Middleware
KubeMQ targets support Retries' target execution before reporting of error back to the source on failed execution.
Retry middleware settings values:
Property |
Description |
Possible Values |
retry_attempts |
how many retries before giving up on target execution |
default - 1, or any int number |
retry_delay_milliseconds |
how long to wait between retries in milliseconds |
default - 100ms or any int number |
retry_max_jitter_milliseconds |
max delay jitter between retries |
default - 100ms or any int number |
retry_delay_type |
type of retry delay |
"back-off" - delay increase on each attempt |
|
|
"fixed" - fixed time delay |
|
|
"random" - random time delay |
An example for 3 retries with back-off strategy:
bindings:
- name: sample-binding
properties:
retry_attempts: 3
retry_delay_milliseconds: 1000
retry_max_jitter_milliseconds: 100
retry_delay_type: "back-off"
source:
......
Rate Limiter Middleware
KubeMQ targets support a Rate Limiting of target executions.
Rate Limiter middleware settings values:
Property |
Description |
Possible Values |
rate_per_second |
how many executions per second will be allowed |
0 - no limitation |
|
|
1 - n integer times per second |
An example for 100 executions per second:
bindings:
- name: sample-binding
properties:
rate_per_second: 100
source:
......
Source
Source section contains source configuration for Binding as follows:
Property |
Description |
Possible Values |
name |
sources name (will show up in logs) |
string without white spaces |
kind |
source kind type |
kubemq.queue |
|
|
kubemq.query |
|
|
kubemq.query-stream |
|
|
kubemq.command |
|
|
kubemq.events |
|
|
kubemq.events-store |
properties |
an array of key/value setting for source connection |
see above |
Target
Target section contains the target configuration for Binding as follows:
Property |
Description |
Possible Values |
name |
targets name (will show up in logs) |
string without white spaces |
kind |
source kind type |
type-of-target |
properties |
an array of key/value set for target connection |
see above |