Home

Awesome

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:

Concepts

KubeMQ Targets building blocks are:

Binding

Binding is a 1:1 connection between Source and Target. Every Binding runs independently.

binding

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

CategoryTargetKindConfigurationExample
Cache
Rediscache.redisUsageExample
Memcachedcache.memcachedUsageExample
Hazelcastcache.hazelcastUsageExample
Stores/db
Postgresstores.postgresUsageExample
Mysqlstores.mysqlUsageExample
MSSqlstores.mssqlUsageExample
MongoDBstores.mongodbUsageExample
Elastic Searchstores.elastic-searchUsageExample
Cassandrastores.cassandraUsageExample
Couchbasestores.couchbaseUsageExample
Perconastores.perconaUsageExample
Cockroachdbstores.cockroachdbUsageExample
Aerospikestores.aerospikeUsageExample
RethinkDBstores.rethinkdbUsageExample
SingleStorestores.singlestoreUsageExample
Crate.iostores.crateUsageSimilar to postgres
Messaging
Kafkamessaging.kafkaUsageExample
Natsmessaging.natsUsageExample
RabbitMQmessaging.rabbitmqUsageExample
MQTTmessaging.mqttUsageExample
ActiveMQmessaging.activemqUsageExample
AMQPmessaging.amqpUsageExample
Storage
Minio/S3storage.minioUsageExample
hadoop/hdfsstorage.hdfsUsageExample
Filesystemstorage.filesystemUsage
Serverless
OpenFaasserverless.openfaasUsageExample
Http
HttphttpUsageExample
Testing
EchoechoUsage

Google Cloud Platform (GCP)

CategoryTargetKindConfigurationExample
Cache
Redisgcp.cache.redisUsageExample
Memcachedgcp.cache.memcachedUsageExample
Stores/db
Postgresgcp.stores.postgresUsageExample
Mysqlgcp.stores.mysqlUsageExample
BigQuerygcp.bigqueryUsageExample
BigTablegcp.bigtableUsageExample
Firestoregcp.firestoreUsageExample
Spannergcp.spannerUsageExample
Firebasegcp.firebaseUsageExample
Messaging
Pub/Subgcp.pubsubUsageExample
Storage
Storagegcp.storageUsageExample
Serverless
Functionsgcp.cloudfunctionsUsageExample

Amazon Web Service (AWS)

CategoryTargetKindConfigurationExample
Stores/db
Athenaaws.athenaUsageExample
DynamoDBaws.dynamodbUsageExample
Elasticsearchaws.elasticsearchUsageExample
KeySpacesaws.keyspacesUsageExample
MariaDBaws.rds.mariadbUsageExample
MSSqlaws.rds.mssqlUsageExample
MySQLaws.rds.mysqlUsageExample
Postgresaws.rds.postgresUsageExample
RedShiftaws.rds.redshiftUsageExample
RedShiftSVCaws.rds.redshift.serviceUsageExample
Messaging
AmazonMQaws.amazonmqUsageExample
mskaws.mskUsageExample
Kinesisaws.kinesisUsageExample
SQSaws.sqsUsageExample
SNSaws.snsUsageExample
Storage
s3aws.s3UsageExample
Serverless
lambdaaws.lambdaUsageExample
Other
Cloud Watch Logsaws.cloudwatch.logsUsageExample
Cloud Watch Eventsaws.cloudwatch.eventsUsageExample
Cloud Watch Metrics aws.cloudwatch.metricsUsageExample

Microsoft Azure

CategoryTargetKindConfigurationExample
Stores/db
Azuresqlazure.stores.azuresqlUsageExample
Mysqlazure.stores.mysqlUsageExample
Postgresazure.stores.postgresUsageExample
Storage
Blobazure.storage.blobUsageExample
Filesazure.storage.filesUsageExample
Queueazure.storage.queueUsageExample
EventHubs
EventHubsazure.eventhubsUsageExample
ServiceBus
ServiceBusazure.servicebusUsageExample

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.

TypeKindConfiguration
Queuekubemq.queueUsage
Queue-Streamkubemq.queue-streamUsage
Eventskubemq.eventsUsage
Events Storekubemq.events-storeUsage
Commandkubemq.commandUsage
Querykubemq.queryUsage

Request / Response

concept

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
FieldTypeDescription
metadatastring, string objectcontains metadata information for action
databytes arraycontains 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
FieldTypeDescription
metadatastring, string objectcontains metadata information result for action
databytes arraycontains raw data result
is_errorboolindicate if the action ended with an error
errorstringcontains 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

  1. Install KubeMQ Cluster
kubectl apply -f https://get.kubemq.io/deploy
  1. Run Redis Cluster deployment yaml
kubectl apply -f https://raw.githubusercontent.com/kubemq-hub/kubemq-targets/master/redis-example.yaml
  1. Run KubeMQ Targets deployment yaml
kubectl apply -f https://raw.githubusercontent.com/kubemq-hub/kubemq-targets/master/deploy-example.yaml

Binary (Cross-platform)

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

  1. Download the Windows version from KubeMQ Targets Releases. Once downloaded, the binary can be installed from anywhere.
  2. 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:

PropertyDescriptionPossible Values
log_levellog 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:

PropertyDescriptionPossible Values
retry_attemptshow many retries before giving up on target executiondefault - 1, or any int number
retry_delay_millisecondshow long to wait between retries in millisecondsdefault - 100ms or any int number
retry_max_jitter_millisecondsmax delay jitter between retriesdefault - 100ms or any int number
retry_delay_typetype 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:

PropertyDescriptionPossible Values
rate_per_secondhow many executions per second will be allowed0 - 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:

PropertyDescriptionPossible Values
namesources name (will show up in logs)string without white spaces
kindsource kind typekubemq.queue
kubemq.query
kubemq.query-stream
kubemq.command
kubemq.events
kubemq.events-store
propertiesan array of key/value setting for source connectionsee above

Target

Target section contains the target configuration for Binding as follows:

PropertyDescriptionPossible Values
nametargets name (will show up in logs)string without white spaces
kindsource kind typetype-of-target
propertiesan array of key/value set for target connectionsee above