Coder Social home page Coder Social logo

amqbrokerinitcustom's Introduction

Procedimiento instalación y configuración Broker AMQ con replicacion multi cluster

Broker 1

  1. Creamos el namespace
kind: Project
apiVersion: project.openshift.io/v1
metadata:
  name: pocamqbroker1
  1. Instalamos operador

Red Hat Integration - AMQ Broker for RHEL 8 (Multiarch) 7.10.2-opr-2+0.1676475747.p provided by Red Hat

  1. Creamos secret con las credenciales del broker
kind: Secret
apiVersion: v1
metadata:
  name: ex-aao-credentials-secret
  namespace: pocamqbroker1
data:
  AMQ_CLUSTER_PASSWORD: dnZmSng2MUw=
  AMQ_CLUSTER_USER: RUlKVWRiQ1Q=
  AMQ_PASSWORD: cmVkYWh0MDE=
  AMQ_USER: YWRtaW4=
  1. Creamos la imagen que vamos a usar como initImage en el CRD
kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
  name: amqbrokerinitcustom
  namespace: pocamqbroker1
spec:
  lookupPolicy:
    local: false
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
  name: amqbrokerinitcustom
  namespace: pocamqbroker1
spec:
  nodeSelector: null
  output:
    to:
      kind: ImageStreamTag
      name: 'amqbrokerinitcustom:latest'
  resources: {}
  successfulBuildsHistoryLimit: 5
  failedBuildsHistoryLimit: 5
  strategy:
    type: Docker
    dockerStrategy:
      dockerfilePath: Dockerfile
      buildArgs:
        - name: "PROFILE"
          value: "clustering"
  postCommit: {}
  source:
    type: Git
    git:
      uri: 'https://github.com/damianlezcano/amqbrokerinitcustom.git'
      ref: 'amq1'
    contextDir: /
  runPolicy: Serial
  1. Creamos el CRD de Artemis
apiVersion: broker.amq.io/v1beta1
kind: ActiveMQArtemis
metadata:
  name: ex-aao
  namespace: pocamqbroker1
spec:
  acceptors:
    - port: 61616
      verifyHost: false
      wantClientAuth: false
      expose: true
      needClientAuth: false
      multicastPrefix: /topic/
      name: artemis
      sslEnabled: false
      protocols: 'CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE'
      sslProvider: JDK
      anycastPrefix: jms.topic.
      bindToAllInterfaces: true
  adminPassword: redaht01
  adminUser: admin
  connectors:
    - host: ex-aao-artemis-0-svc.pocamqbroker2.svc.cluster.local
      name: broker2-connector
      port: 61616
      sslEnabled: false
  console:
    expose: true
  deploymentPlan:
    size: 1
    initImage: image-registry.openshift-image-registry.svc:5000/pocamqbroker1/amqbrokerinitcustom:latest
    persistenceEnabled: false
    messageMigration: true
    requireLogin: false
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
            - matchExpressions:
                - key: kubernetes.io/hostname
                  operator: In
                  values:
                    - ip-10-0-206-91
    managementRBACEnabled: true
    journalType: nio
    jolokiaAgentEnabled: false
    image: placeholder

En el caso de querer probar mirror, quitar la configuracion de connectors en el CR

Para este ejemplo no se contaba con 2 cluster de OCP. Por tal motivo se crearon 2 namespaces y en cada uno de ellos se desplego una instancia del broker con un nodeAffinity para garantizar que cada broker este en workers separados. Quite la seccion de nodeAffinity si cuenta con otro cluster.


Broker 2

  1. Creamos el namespace
kind: Project
apiVersion: project.openshift.io/v1
metadata:
  name: pocamqbroker2
  1. Instalamos operador

Red Hat Integration - AMQ Broker for RHEL 8 (Multiarch) 7.10.2-opr-2+0.1676475747.p provided by Red Hat

  1. Creamos secret con las credenciales del broker
kind: Secret
apiVersion: v1
metadata:
  name: ex-aao-credentials-secret
  namespace: pocamqbroker2
data:
  AMQ_CLUSTER_PASSWORD: dnZmSng2MUw=
  AMQ_CLUSTER_USER: RUlKVWRiQ1Q=
  AMQ_PASSWORD: cmVkYWh0MDE=
  AMQ_USER: YWRtaW4=
  1. Creamos la imagen que vamos a usar como initImage en el CRD
kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
  name: amqbrokerinitcustom
  namespace: pocamqbroker2
spec:
  lookupPolicy:
    local: false
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
  name: amqbrokerinitcustom
  namespace: pocamqbroker2
spec:
  nodeSelector: null
  output:
    to:
      kind: ImageStreamTag
      name: 'amqbrokerinitcustom:latest'
  resources: {}
  successfulBuildsHistoryLimit: 5
  failedBuildsHistoryLimit: 5
  strategy:
    type: Docker
    dockerStrategy:
      dockerfilePath: Dockerfile
      buildArgs:
        - name: "PROFILE"
          value: "clustering"
  postCommit: {}
  source:
    type: Git
    git:
      uri: 'https://github.com/damianlezcano/amqbrokerinitcustom.git'
      ref: 'amq2'
    contextDir: /
  runPolicy: Serial
  1. Creamos el CRD de Artemis
apiVersion: broker.amq.io/v1beta1
kind: ActiveMQArtemis
metadata:
  name: ex-aao
  namespace: pocamqbroker2
spec:
  acceptors:
    - port: 61616
      verifyHost: false
      wantClientAuth: false
      expose: true
      needClientAuth: false
      multicastPrefix: /topic/
      name: artemis
      sslEnabled: false
      protocols: 'CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE'
      sslProvider: JDK
      anycastPrefix: jms.topic.
      bindToAllInterfaces: true
  adminPassword: redaht01
  adminUser: admin
  connectors:
    - host: ex-aao-artemis-0-svc.pocamqbroker1.svc.cluster.local
      name: broker2-connector
      port: 61616
      sslEnabled: false
  console:
    expose: true
  deploymentPlan:
    size: 1
    initImage: image-registry.openshift-image-registry.svc:5000/pocamqbroker2/amqbrokerinitcustom:latest
    persistenceEnabled: false
    messageMigration: true
    requireLogin: false
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
            - matchExpressions:
                - key: kubernetes.io/hostname
                  operator: In
                  values:
                    - ip-10-0-230-102
    managementRBACEnabled: true
    journalType: nio
    jolokiaAgentEnabled: false
    image: placeholder

En el caso de querer probar mirror, quitar la configuracion de connectors en el CR

Verificacion

Verifiquemos que los nodos del broker conformen el cluster. Para esto ingresemos a la consola del cualquiera de las instancias del broker y verifiquemos en la seccion Cluster Info que diga Lives: 2 como se muestra en la imagen

Producimos un mensaje al tipic test

oc exec ex-aao-ss-0 -n pocamqbroker1 -- /bin/bash /home/jboss/amq-broker/bin/artemis producer --user admin --password redhat01 --url tcp://ex-aao-ss-0:61616 --destination topic://exampleTopic --message-count 1

oc exec ex-aao-ss-0 -n pocamqbroker2 -- /bin/bash /home/jboss/amq-broker/bin/artemis producer --user admin --password redhat01 --url tcp://ex-aao-ss-0:61616 --destination topic://exampleTopic --message-count 1

Verificamos las colas en ambos brokers

oc exec ex-aao-ss-0 -n pocamqbroker1 -- /bin/bash /home/jboss/amq-broker/bin/artemis queue stat --user admin --password redhat01 --url tcp://ex-aao-ss-0:61616

oc exec ex-aao-ss-0 -n pocamqbroker2 -- /bin/bash /home/jboss/amq-broker/bin/artemis queue stat --user admin --password redhat01 --url tcp://ex-aao-ss-0:61616

Consumimos los mensajes desde cualquier broker

oc exec ex-aao-ss-0 -n pocamqbroker1 -- /bin/bash /home/jboss/amq-broker/bin/artemis consumer --destination topic://exampleTopic  --message-count=1 --url tcp://ex-aao-ss-0:61616

oc exec ex-aao-ss-0 -n pocamqbroker2 -- /bin/bash /home/jboss/amq-broker/bin/artemis consumer --destination topic://exampleTopic  --message-count=1 --url tcp://ex-aao-ss-0:61616

Referencias

Chapter 16. Configuring a multi-site, fault-tolerant messaging system using broker connections

AMQP Server Connection Operations

amqbrokerinitcustom's People

Contributors

damianlezcano avatar

Stargazers

Rodrigo Ramalho avatar Hugo Melendez avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.