简体   繁体   English

Minikube 上的 RabbitMQ 集群 Kubernetes Operator

[英]RabbitMQ Cluster Kubernetes Operator on minikube

I'm trying to set up RabbitMQ on Minikube using the RabbitMQ Cluster Operator :我正在尝试使用RabbitMQ Cluster Operator在 Minikube 上设置 RabbitMQ:

When I try to attach a persistent volume, I get the following error:当我尝试附加持久卷时,出现以下错误:

$ kubectl logs -f rabbitmq-rabbitmq-server-0

Configuring logger redirection
20:04:40.081 [warning] Failed to write PID file "/var/lib/rabbitmq/mnesia/rabbit@rabbitmq-rabbitmq-server-0.rabbitmq-rabbitmq-headless.default.pid": permission denied
20:04:40.264 [error] Failed to create Ra data directory at '/var/lib/rabbitmq/mnesia/rabbit@rabbitmq-rabbitmq-server-0.rabbitmq-rabbitmq-headless.default/quorum/rabbit@rabbitmq-rabbitmq-server-0.rabbitmq-rabbitmq-headless.default', file system operation error: enoent
20:04:40.265 [error] Supervisor ra_sup had child ra_system_sup started with ra_system_sup:start_link() at undefined exit with reason {error,"Ra could not create its data directory. See the log for details."} in context start_error
20:04:40.266 [error] CRASH REPORT Process <0.247.0> with 0 neighbours exited with reason: {error,"Ra could not create its data directory. See the log for details."} in ra_system_sup:init/1 line 43
20:04:40.267 [error] CRASH REPORT Process <0.241.0> with 0 neighbours exited with reason: {{shutdown,{failed_to_start_child,ra_system_sup,{error,"Ra could not create its data directory. See the log for details."}}},{ra_app,start,[normal,[]]}} in application_master:init/4 line 138
{"Kernel pid terminated",application_controller,"{application_start_failure,ra,{{shutdown,{failed_to_start_child,ra_system_sup,{error,\"Ra could not create its data directory. See the log for details.\"}}},{ra_app,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,ra,{{shutdown,{failed_to_start_child,ra_system_sup,{error,"Ra could not create its data directory. See the log for details."}

Crash dump is being written to: erl_crash.dump...

The issue is that RabbitMQ is not able to set up its data files in the data directory /var/lib/rabbitmq/mnesia due to a lack of permission.问题是由于缺少权限,RabbitMQ 无法在数据目录/var/lib/rabbitmq/mnesia中设置其数据文件。

My initial guess was that I needed to specify the data directory as a volumeMount, but that doesn't seem to be configurable according to the documentation .我最初的猜测是我需要将数据目录指定为volumeMount,但这似乎无法根据文档进行配置。

RabbitMQ's troubleshooting documentation on persistence results in a 404 . RabbitMQ 关于持久性的故障排除文档导致404

I tried to find other resources online with the same problem but none of them were using the RabbitMQ Cluster Operator.我试图在网上找到其他有同样问题的资源,但他们都没有使用 RabbitMQ Cluster Operator。 I plan on following that route if I'm not able to find a solution but I really would like to solve this issue somehow.如果我无法找到解决方案,我计划遵循这条路线,但我真的很想以某种方式解决这个问题。

Does anyone have any ideas?有没有人有任何想法?

The setup that I have is as follows:我的设置如下:

apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: rabbitmq
spec:
  replicas: 1
  service:
    type: NodePort
  persistence:
    storageClassName: local-storage
    storage: 20Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rabbitmq-pvc
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: rabbitmq-pv
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 20Gi
  hostPath:
    path: /mnt/app/rabbitmq
    type: DirectoryOrCreate

To reproduce this issue on minikube:要在 minikube 上重现此问题:

  1. Install the rabbitmq operator:安装 rabbitmq 操作符:
kubectl apply -f "https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml"
  1. Apply the manifest file above应用上面的清单文件
kubectl apply -f rabbitmq.yml
  1. Running kubectl get po displays a pod named rabbitmq-rabbitmq-server-0 .运行kubectl get po会显示一个名为rabbitmq-rabbitmq-server-0的 pod。

  2. Running kubectl logs -f rabbitmq-rabbitmq-server-0 to view the logs displays the above error.运行kubectl logs -f rabbitmq-rabbitmq-server-0查看日志会出现上述错误。

As I alread suggested in comments, you can solve it running:正如我已经在评论中建议的那样,您可以运行它来解决它:

minikube ssh -- sudo chmod g+w /mnt/app/rabbitmq/ 

Answering to your question:回答你的问题:

Is there a way I can add that to my manifest file rather than having to do it manually?有没有办法可以将它添加到我的清单文件中,而不必手动执行?

You can override the rabbitmq statefulset manifest fields to change last line in initContainer command script from chgrp 999 /var/lib/rabbitmq/mnesia/ to this: chown 999:999 /var/lib/rabbitmq/mnesia/ .您可以覆盖 rabbitmq statefulset manifest 字段以将 initContainer 命令脚本中的最后一行从chgrp 999 /var/lib/rabbitmq/mnesia/更改为: chown 999:999 /var/lib/rabbitmq/mnesia/

Complete RabbitmqCluster yaml manifest looks like following:完整的 RabbitmqCluster yaml 清单如下所示:

apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: rabbitmq
spec:
  replicas: 1
  service:
    type: NodePort
  persistence:
    storageClassName: local-storage
    storage: 20Gi
  override:
    statefulSet:
      spec:
        template:
          spec:
            containers: []
            initContainers:
            - name: setup-container
              command:
              - sh
              - -c
              - cp /tmp/rabbitmq/rabbitmq.conf /etc/rabbitmq/rabbitmq.conf && chown 999:999
                /etc/rabbitmq/rabbitmq.conf && echo '' >> /etc/rabbitmq/rabbitmq.conf ; cp /tmp/rabbitmq/advanced.config
                /etc/rabbitmq/advanced.config && chown 999:999 /etc/rabbitmq/advanced.config
                ; cp /tmp/rabbitmq/rabbitmq-env.conf /etc/rabbitmq/rabbitmq-env.conf && chown
                999:999 /etc/rabbitmq/rabbitmq-env.conf ; cp /tmp/erlang-cookie-secret/.erlang.cookie
                /var/lib/rabbitmq/.erlang.cookie && chown 999:999 /var/lib/rabbitmq/.erlang.cookie
                && chmod 600 /var/lib/rabbitmq/.erlang.cookie ; cp /tmp/rabbitmq-plugins/enabled_plugins
                /etc/rabbitmq/enabled_plugins && chown 999:999 /etc/rabbitmq/enabled_plugins
                ; chown 999:999 /var/lib/rabbitmq/mnesia/ # <- CHANGED THIS LINE

I had the same issue when deploying RabbitMQ in kubernetes inside Vagrant (not minikube though).在 Vagrant 的 kubernetes 中部署 RabbitMQ 时,我遇到了同样的问题(虽然不是 minikube)。 I was using this setup.我正在使用这个设置。 I tried running sudo chmod g+w /mnt/app/rabbitmq/ but had no luck... Eventually gave up and ended up running minikube inside vagrant using this box and everything worked perfectly fine out of the box!我尝试运行sudo chmod g+w /mnt/app/rabbitmq/但没有运气......最终放弃并最终使用这个盒子在 vagrant 内运行 minikube 并且开箱即用一切正常! Didn't have to do anything special... Not event manually creating the persistent volume...不必做任何特别的事情......不是手动创建持久卷的事件......

inside my nodes在我的节点内

我在实时版本中遇到了这个问题,当时 minikube 不允许运行 SSH 命令。所以我所做的是将 chmod 运行到我的主机路径配置程序并重新创建了我的 rabbitmq-cluster

chmod 777 /tmp/hostpath-provisioner/default/*

I found the answer for this issue.我找到了这个问题的答案。 It happen when there is few nodes in cluster.当集群中的节点很少时会发生这种情况。 Solution is to add securityContext: {}解决方案是添加securityContext: {}

https://github.com/rabbitmq/rabbitmq-website/blob/3ee8e72a7c4fe52e323ba1039eecbf3a67c554f7/site/kubernetes/operator/using-on-openshift.md#arbitrary-user-ids https://github.com/rabbitmq/rabbitmq-website/blob/3ee8e72a7c4fe52e323ba1039eecbf3a67c554f7/site/kubernetes/operator/using-on-openshift.md#arbitrary-user-ids

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM