Skip to content

Instantly share code, notes, and snippets.

@lulf
Last active July 2, 2020 07:34
Show Gist options
  • Save lulf/7ceb3fab0c20564fc31d066bee42ddeb to your computer and use it in GitHub Desktop.
Save lulf/7ceb3fab0c20564fc31d066bee42ddeb to your computer and use it in GitHub Desktop.

Getting Started

This guide will walk through the process of setting up EnMasse and clients for sending and receiving messages.

Prerequisite
  • A Kubernetes cluster (or Kubernetes-compatible such as OpenShift). You can use minikube if you want to try EnMasse on your laptop.

  • A user on the Kubernetes cluster with permissions to create cluster roles and install Custom Resource Definitions (CRD).

Downloading EnMasse

Procedure
  1. Download one of the releases from GitHub and unpack it.

Installing EnMasse

Procedure
  1. Create the target namespace and deploy the installation bundle:

    kubectl create namespace enmasse-infra
    kubectl config set-context $(kubectl config current-context) --namespace=enmasse-infra
    kubectl apply -f install/bundles/enmasse

Creating messaging infrastructure

Procedure
  1. Create the messaging infrastructure with the default configuration:

    cat<<EOF | kubectl apply -f -
    apiVersion: enmasse.io/v1beta2
    kind: MessagingInfrastructure
    metadata:
      name: myinfra
      namespace: enmasse-infra
    spec: {}
    EOF

    This will deploy 1 router and 1 broker that are connected and can be used to serve multiple tenants on a cluster.

Configuring messaging for a namespace

Procedure
  1. Create a namespace for the messaging application:

    kubectl create namespace messaging-app
  2. Create a tenant named default (in any namespace):

    cat<<EOF | kubectl apply -f -
    apiVersion: enmasse.io/v1beta2
    kind: MessagingTenant
    metadata:
      name: default
      namespace: messaging-app
    spec: {}
    EOF

    This will enable messaging on the messaging-app namespace, so that the operator will act on the creation of addresses and endpoints. NOTE: The name must be default.

  3. Create a message queue:

    cat<<EOF | kubectl apply -f -
    apiVersion: enmasse.io/v1beta2
    kind: MessagingAddress
    metadata:
      name: myqueue
      namespace: messaging-app
    spec:
      queue: {}
    EOF

    This will create a queue named myqueue which you can use as a destination for sending and receiving messages.

  4. Create an endpoint for accessing the address:

    cat<<EOF | kubectl apply -f -
    apiVersion: enmasse.io/v1beta2
    kind: MessagingEndpoint
    metadata:
      name: cluster
      namespace: messaging-app
    spec:
      cluster: {}
      protocols: ["AMQP"]
    EOF

    This will create an endpoint that is accessible on the cluster only, using the AMQP 1.0 protocol.

Run messaging clients

  1. Procedure

  2. Start messaging client sending 10 messages to myqueue:

    kubectl run testsender -n messaging-app --image=quay.io/enmasse/testclient:latest -- -a amqp://messaging-app-cluster.enmasse-infra.svc:5672/myqueue -r sender -m 10
  3. View client logs to confirm messages was sent:

    kubectl logs testsender -n messaging-app
  4. Start messaging client receiving 10 messages from myqueue:

    kubectl run testreceiver -n messaging-app --image=quay.io/enmasse/testclient:latest -- -a amqp://messaging-app-cluster.enmasse-infra.svc:5672/myqueue -r receiver -m 10
  5. View client logs to confirm messages was received:

    kubectl logs testreceiver -n messaging-app

For code examples on messaging clients, see EnMasse Example Clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment