K8s build -kubernetes build RabbitMQ

Thanks for sharing text - http://bjbsair.com/2020-04-03/tech-info/29908.html

1, RabbitMQ Profile

RabbitMQ is to achieve the Advanced Message Queuing Protocol (AMQP) is an open source message broker software (also known as message-oriented middleware). RabbitMQ server is written in Erlang, and clustering and failover is built on an open telecommunications platform framework. AMQP: Advanced Message Queue, Advanced Message Queuing Protocol. It is an open standard application-layer protocol for message-oriented middleware design, based on this protocol client and messaging middleware message can be transmitted, not by the product, limiting the development of language light conditions. AMQP has the following characteristics:

  • Reliability (Reliablity): Use some mechanism to ensure the reliability, such as persistence, transmission confirmation, confirm the release.
  • Flexible Routing (Flexible Routing): Before entering the message queue, the message is routed through the Exchange. For a typical routing functions, Rabbit has provided some built-in Exchange to achieve. For more sophisticated routing capabilities, multiple Exchange can bind together, but also realize their Exchange through a plug-in mechanism.
  • Cluster message (Clustering): a plurality of servers RabbitMQ can form a cluster, form a logical Broker.
  • HA (Highly Avaliable Queues): queue may be mirrored on the machines in the cluster, such that the queue remains available in case some of the nodes of the problem.
  • Multiple protocols (Multi-protocol): Support multiple Message Queuing Protocol, such as STOMP, MQTT like.
  • Multilingual client (Many Clients): supports almost all commonly used languages, such as Java, .NET, Ruby and so on.
  • Management Interface (Management UI): provides easy to use user interface, allowing users to monitor and manage many aspects of the message Broker.
  • Tracking Mechanism (Tracing): If the message is abnormal, RabbitMQ provides a mechanism for tracking messages, users can find out what happened.
  • Plug-in mechanism (Plugin System): provides a number of plug-ins to be extended in many ways, you can also edit your own plug-ins.

RabbitMQ messages can only be stored in the Queue, the producer (the lower figure P) production and eventually delivered to the Queue message, the consumer (C in the figure) may be obtained from the Queue message and consumption.

K8s deployment -kubernetes deployment RabbitMQ

2, RabbitMQ deployment

The following is RabbitMQ defined deployed code, this code consists of two parts, i.e. RabbitMQ Deploying and its proxy service. Mirroring the bitnami / rabbitmq: latest. Foreign exposed by NodePort mode ports 15672 and 5672, and by nfs file system RabbitMQ were persistent data.

#-------------定义RabbitMQ部署-----------------  
apiVersion: apps/v1beta2  
kind: Deployment  
metadata:  
 name: rabbit  
spec:  
 replicas: 1  
 selector:  
   matchLabels:  
     app: rabbit  
 strategy:  
   rollingUpdate:  
     maxSurge: 25%  
     maxUnavailable: 25%  
   type: RollingUpdate  
 template:  
   metadata:  
     labels:  
       app: rabbit  
   spec:  
     containers:  
     - image: bitnami/rabbitmq:latest  
       imagePullPolicy: IfNotPresent  
       name: rabbit  
       ports:  
       - containerPort: 15672  
         name: rabbit15672  
         protocol: TCP  
       - containerPort: 5672   
         name: rabbit5672   
         protocol: TCP  
       resources: {}  
       volumeMounts:  
       - mountPath: /bitnami  
         name: rabbit-persistent-storage  
      dnsPolicy: ClusterFirst  
      restartPolicy: Always  
      schedulerName: default-scheduler  
      securityContext: {}  
      terminationGracePeriodSeconds: 30  
      volumes:  
      - name: rabbit-persistent-storage  
        nfs:  
         path: /home/nfs-share/rabbit  
         server: 10.0.33.201  
  
#-----------------定义rabbit的代理服务--------------  
apiVersion: v1  
kind: Service  
metadata:  
 name: rabbit-service  
spec:  
 ports:  
 - name: rabbit15672  
   nodePort: 31199  
   port: 15672  
   protocol: TCP  
   targetPort: 15672  
 - name: rabbit15672   
   nodePort: 305672   
   port: 5672   
   protocol: TCP   
   targetPort: 5672  
 selector:  
   app: rabbit  
 type: NodePort  

By kubectl, execute the following command to deploy Oracle database Kubernetes cluster.

$ kubectl create -f rabbitmq.yaml --namespace=kube-public

After the deployment is complete, you can view RabbitMQ exposed port with the following command:

$ kubectl get svc --namespace=kube-public

3, deployment validation

In the browser input: http://10.0.33.203:31199/, visit deployed RabbitMQ. Enter your user name and password (where the initial user / bitnami) in the login page, the system will enter RabbitMQ home page.

K8s deployment -kubernetes deployment RabbitMQ

4, runtime configuration

At deployment time, the container can be changed by setting the operating environment following variables:

  • RABBITMQ_USERNAME: user name, default is user
  • RABBITMQ_PASSWORD: password, the default value bitnami
  • RABBITMQ_HASHED_PASSWORD: hashed password
  • RABBITMQ_VHOST: After starting the installation to create a virtual host, the default is /
  • RABBITMQ_ERL_COOKIE: Erlang cookie for determining whether each line to allow communications between different nodes.
  • RABBITMQ_NODE_TYPE: node type, there are limitations: stats, queue-ram or queue -disc. The default value stats
  • RABBITMQ_NODE_NAME: node name and host, for example: node @ hostname or node. The default value is rabbit @ localhost.
  • RABBITMQ_NODE_PORT_NUMBER: node port, the default value 5672
  • RABBITMQ_CLUSTER_NODE_NAME: cluster name, for example: clusternode @ hostname
  • RABBITMQ_CLUSTER_PARTITION_HANDLING: cluster partition recovery mechanism, the default value: the ignore
  • RABBITMQ_MANAGER_PORT_NUMBER: management port, the default is 15672
  • RABBITMQ_DISK_FREE_LIMIT: Rabbitmq space available for storing data limits when below this value, triggers the flow restriction. The default value {mem_relative, 1.0}
  • RABBITMQ_ULIMIT_NOFILES: resource constraints, the maximum number of open file descriptors, the default value is 65536

Guess you like

Origin www.cnblogs.com/lihanlin/p/12657669.html