Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.59 KB | None | 0 0
  1. rabbit1:
  2. image: ipf-queue-node
  3. hostname: rabbit1
  4. cap_add:
  5. - ALL
  6. - NET_ADMIN
  7. - SYS_ADMIN
  8. ports:
  9. - "5671:5671"
  10. - "5672:5672"
  11. - "15672:15672"
  12.  
  13. rabbit2:
  14. image: ipf-queue-node
  15. hostname: rabbit2
  16. cap_add:
  17. - ALL
  18. - NET_ADMIN
  19. - SYS_ADMIN
  20. links:
  21. - rabbit1
  22. environment:
  23. - CLUSTERED=true
  24. - CLUSTER_WITH=rabbit1
  25. - RAM_NODE=true
  26. ports:
  27. - "5675:5671"
  28. - "5673:5672"
  29. - "15673:15672"
  30.  
  31. FROM queue-base
  32.  
  33. # Create directories
  34. RUN mkdir /opt/rabbit
  35. RUN mkdir /opt/simulator
  36. RUN mkdir /opt/simulator/tools
  37.  
  38. # Add the files from the local repository into the container
  39. ADD rabbitmq.config /etc/rabbitmq/
  40. ADD rabbitmq-env.conf /etc/rabbitmq/
  41. ADD erlang.cookie /var/lib/rabbitmq/.erlang.cookie
  42. ADD startclusternode.sh /opt/rabbit/
  43. ADD debugnodes.sh /opt/rabbit/
  44. ADD tl /bin/tl
  45. ADD rl /bin/rl
  46. ADD rst /bin/rst
  47.  
  48. # Add the simulator tooling
  49. ADD simulator_tools/ /opt/simulator/tools/
  50. ADD ./testca /tmp/ssl
  51. ADD ./server /tmp/ssl
  52.  
  53. # Set the file permissions in the container
  54. RUN chmod 644 /etc/rabbitmq/rabbitmq.config
  55. RUN chmod 644 /etc/rabbitmq/rabbitmq-env.conf
  56. RUN chmod 400 /var/lib/rabbitmq/.erlang.cookie
  57. RUN chmod 777 /opt/rabbit/startclusternode.sh
  58. RUN chmod 777 /opt/rabbit/debugnodes.sh
  59. RUN chmod 777 /bin/tl
  60. RUN chmod 777 /bin/rl
  61. RUN chmod 777 /bin/rst
  62. RUN chmod -R 777 /opt/simulator
  63.  
  64. # Set ownership permissions on files in the container
  65. RUN chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
  66.  
  67. # Expose ports inside the container to the host
  68. EXPOSE 5672
  69. EXPOSE 5671
  70. EXPOSE 15672
  71. EXPOSE 25672
  72.  
  73. # Run this to debug the cluster nodes by allowing ssh login
  74. #CMD /opt/rabbit/debugnodes.sh
  75.  
  76. # Run this to autostart the cluster nodes
  77. CMD /opt/rabbit/startclusternode.sh
  78.  
  79. #!/bin/bash
  80.  
  81. logfile="/tmp/rabbitnode.log"
  82. firsttimefile="/tmp/firsttimerunning"
  83.  
  84. curhostname=`hostname`
  85. username="<<username>>"
  86. password="<<password>>"
  87. echo "" > $logfile
  88. echo "New Start Date:" >> $logfile
  89. date >> $logfile
  90. echo "" >> $logfile
  91.  
  92. ( sleep 40 ;
  93. rabbitmqctl add_user $username $password ;
  94. rabbitmqctl set_user_tags $username administrator ;
  95. rabbitmqctl add_vhost $curhostname ;
  96. rabbitmqctl add_vhost localhost;
  97. rabbitmqctl set_permissions -p $curhostname $username ".*" ".*" ".*" ;
  98. rabbitmqctl set_permissions -p localhost $username ".*" ".*" ".*" ;
  99. rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
  100. ) &
  101.  
  102. sleep 5
  103.  
  104. # For version 3.5.6 the first time running the cluster needs to enable the plugins
  105. if [ -f $firsttimefile ]; then
  106. echo "First Time Running Enabling Plugins" >> $logfile
  107. /usr/sbin/rabbitmq-server -d &
  108. echo "Waiting for RabbitMQ Server to start" >> $logfile
  109. sleep 3
  110. echo "Enabling Plugins" >> $logfile
  111. /usr/sbin/rabbitmq-plugins enable rabbitmq_stomp rabbitmq_management rabbitmq_management_agent rabbitmq_management_visualiser rabbitmq_federation rabbitmq_federation_management sockjs >> $logfile
  112. echo "Waiting for Plugins to finish" >> $logfile
  113. sleep 1
  114. echo "Stopping the RabbitMQ using stop_app" >> $logfile
  115. /usr/sbin/rabbitmqctl stop_app
  116. echo "Stopping the RabbitMQ using stop" >> $logfile
  117. /usr/sbin/rabbitmqctl stop
  118.  
  119. echo "Stopping the RabbitMQ Server" >> $logfile
  120. kill -9 `ps auwwx | grep rabbitmq-server | awk '{print $2}'`
  121. sleep 1
  122.  
  123. echo "Done First Time Running Enabling Plugins" >> $logfile
  124. rm -f $firsttimefile >> $logfile
  125. echo "Done Cleanup First Time File" >> $logfile
  126.  
  127.  
  128. # Allow the cluster nodes to wait for the master to start the first time
  129. if [ -z "$CLUSTERED" ]; then
  130. echo "Ignoring as this is the server node" >> $logfile
  131. else
  132. if [ -z "$CLUSTER_WITH" ]; then
  133. echo "Ignoring as this is the cluster master node" >> $logfile
  134. else
  135. echo "Waiting for the master node to start up" >> $logfile
  136. sleep 5
  137. echo "Done waiting for the master node to start up" >> $logfile
  138. fi
  139. fi
  140. fi
  141.  
  142.  
  143. if [ -z "$CLUSTERED" ]; then
  144.  
  145. echo "Starting non-Clustered Server Instance" >> $logfile
  146. # if not clustered then start it normally as if it is a single server
  147. /usr/sbin/rabbitmq-server >> $logfile
  148. echo "Done Starting non-Clustered Server Instance" >> $logfile
  149.  
  150. # Tail to keep the foreground process active.
  151. tail -f /var/log/rabbitmq/*
  152.  
  153. else
  154. if [ -z "$CLUSTER_WITH" ]; then
  155. # If clustered, but cluster is not specified then start normally as this could be the first server in the cluster
  156. echo "Starting Single Server Instance" >> $logfile
  157. /usr/sbin/rabbitmq-server >> $logfile
  158.  
  159. echo "Done Starting Single Server Instance" >> $logfile
  160. else
  161. echo "Starting Clustered Server Instance as a DETACHED single instance" >> $logfile
  162. /usr/sbin/rabbitmq-server -detached >> $logfile
  163.  
  164. echo "Stopping App with /usr/sbin/rabbitmqctl stop_app" >> $logfile
  165. /usr/sbin/rabbitmqctl stop_app >> $logfile
  166.  
  167. # This should attempt to join a cluster master node from the yaml file
  168. if [ -z "$RAM_NODE" ]; then
  169. echo "Attempting to join as DISC node: /usr/sbin/rabbitmqctl join_cluster rabbit@$CLUSTER_WITH" >> $logfile
  170. /usr/sbin/rabbitmqctl join_cluster rabbit@$CLUSTER_WITH >> $logfile
  171. else
  172. echo "Attempting to join as RAM node: /usr/sbin/rabbitmqctl join_cluster --ram rabbit@$CLUSTER_WITH" >> $logfile
  173. /usr/sbin/rabbitmqctl join_cluster --ram rabbit@$CLUSTER_WITH >> $logfile
  174. fi
  175. echo "Starting App" >> $logfile
  176. /usr/sbin/rabbitmqctl start_app >> $logfile
  177.  
  178. echo "Done Starting Cluster Node" >> $logfile
  179. fi
  180.  
  181. # Tail to keep the foreground process active.
  182. tail -f /var/log/rabbitmq/*
  183.  
  184. fi
  185.  
  186. apiVersion: v1
  187. kind: Service
  188. metadata:
  189. name: rabbitmqsvc
  190. labels:
  191. app: queue-master
  192. spec:
  193. ports:
  194. - port: 5672
  195. name: queue-rw-port
  196. - port: 15672
  197. name: queue-mgt-port
  198. nodePort: 31606
  199. - port: 5671
  200. name: queue-ssl
  201. nodePort: 32718
  202. selector:
  203. app: queue-master
  204. type: NodePort
  205. clusterIP: 10.16.0.121
  206. ---
  207. apiVersion: v1
  208. kind: ReplicationController
  209. metadata:
  210. name: rabbitmq-controller
  211. labels:
  212. app: queue-master
  213. spec:
  214. replicas: 1
  215. selector:
  216. app: queue-master
  217. template:
  218. metadata:
  219. name: rabbitmq-pod
  220. labels:
  221. app: queue-master
  222. spec:
  223. nodeSelector:
  224. nodesize: small1
  225. containers:
  226. - name: rabbitmq-master
  227. image: 172.17.0.1:5000/queue-node
  228. ports:
  229. - containerPort: 5672
  230. name: queue-rw-port
  231. - containerPort: 15672
  232. name: queue-mgt-port
  233. - containerPort: 5671
  234. name: queue-ssl
  235.  
  236. apiVersion: v1
  237. kind: Service
  238. metadata:
  239. name: rabbitmqsvc-slave
  240. labels:
  241. app: queue-slave
  242. spec:
  243. ports:
  244. - port: 5672
  245. name: queue-rw-port
  246. - port: 15672
  247. name: queue-mgt-port
  248. nodePort: 31607
  249. - port: 5671
  250. name: queue-ssl
  251. nodePort: 32719
  252. selector:
  253. app: queue-slave
  254. type: NodePort
  255. clusterIP: 10.16.0.122
  256. ---
  257. apiVersion: v1
  258. kind: ReplicationController
  259. metadata:
  260. name: rabbitmq-controller-slave
  261. labels:
  262. app: queue-slave
  263. spec:
  264. replicas: 1
  265. selector:
  266. app: queue-slave
  267. template:
  268. metadata:
  269. name: rabbitmq-pod
  270. labels:
  271. app: queue-slave
  272. spec:
  273. nodeSelector:
  274. nodesize: small2
  275. containers:
  276. - name: rabbitmq-slave
  277. image: 172.17.0.1:5000/queue-node
  278. env:
  279. - name: CLUSTERED
  280. value: "true"
  281. - name: CLUSTER_WITH
  282. value: "rabbitmq-controller-2ll1s"
  283. - name: RAM_NODE
  284. value: "true"
  285. - name: HOST_NAME
  286. value: "rabbit2"
  287. ports:
  288. - containerPort: 5672
  289. name: queue-rw-port
  290. - containerPort: 15672
  291. name: queue-mgt-port
  292. - containerPort: 5671
  293. name: queue-ssl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement