Giter Club home page Giter Club logo

Comments (4)

Gsantomaggio avatar Gsantomaggio commented on August 11, 2024

Hi @CORRTAIN,
Can you please provide more context?
Are you using the last Operator version?
Can you post the definition yaml file are you using to deploy RabbitMQ cluster?

And are you sure you are using the right tools? this is rabbitmq-autocluster, please have a look on https://github.com/rabbitmq/cluster-operator

from rabbitmq-autocluster.

corrtia avatar corrtia commented on August 11, 2024

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: rabbitmq-config
data:
  enabled_plugins: |
      [rabbitmq_management,rabbitmq_peer_discovery_k8s].
  rabbitmq.conf: |
      cluster_formation.peer_discovery_backend  = rabbit_peer_discovery_k8s
      cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
      cluster_formation.k8s.address_type = hostname
      cluster_formation.node_cleanup.interval = 30
      cluster_formation.node_cleanup.only_log_warning = true
      cluster_partition_handling = autoheal
      queue_master_locator=min-masters
      loopback_users.guest = false

rbac.yaml

---
# RabbitMQ ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: rabbitmq
---
# RabbitMQ Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: endpoint-reader
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get"]
---
# RabbitMQ RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: endpoint-reader
subjects:
  - kind: ServiceAccount
    name: rabbitmq
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: endpoint-reader

svc.yaml

---
# RabbitMQ Service
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-cluster
  labels:
    app: rabbitmq-cluster
    type: LoadBalancer
spec:
  selector:
    app: rabbitmq-cluster
  ports:
    - name: amqp-port
      port: 5672
      targetPort: 5672
      protocol: TCP
    - name: mgmt-port
      port: 15672
      targetPort: 15672
      protocol: TCP
---
# RabbitMQ NodePort Service
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-nodeport
  labels:
    app: rabbitmq-nodeport
    type: LoadBalancer
spec:
  type: NodePort
  selector:
    app: rabbitmq-cluster
  ports:
    - name: amqp-port
      nodePort: 30001
      port: 5672
      targetPort: 5672
      protocol: TCP
    - name: mgmt-port
      nodePort: 30002
      port: 15672
      targetPort: 15672
      protocol: TCP

statefulset.yaml

# RabbitMQ-Cluster StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: rabbitmq-cluster
spec:
  replicas: 3
  selector:
    matchLabels:
      app: rabbitmq-cluster
  serviceName: rabbitmq-internal
  template:
    metadata:
      labels:
        app: rabbitmq-cluster
    spec:
      serviceAccountName: rabbitmq
      containers:
        - name: rabbitmq
          image: rabbitmq:3
          livenessProbe:
            exec:
              # Stage 2 check, more detail at https://www.rabbitmq.com/monitoring.html#health-checks
              command: ["rabbitmq-diagnostics", "status"]
            initialDelaySeconds: 60
            periodSeconds: 60
            timeoutSeconds: 10
          readinessProbe:
            exec:
              # Stage 2 check, more detail at https://www.rabbitmq.com/monitoring.html#health-checks
              command: ["rabbitmq-diagnostics", "status"]
            initialDelaySeconds: 60
            periodSeconds: 60
            timeoutSeconds: 10
          ports:
            - containerPort: 5672
              protocol: TCP
            - containerPort: 15672
              protocol: TCP
          env:
            - name: MY_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name  # get pod.metadata.name, e.g. rabbitmq-cluster-0
            - name: MY_POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace  # get pod.metadata.namespace
            - name: RABBITMQ_DEFAULT_USER
              value: "admin"
            - name: RABBITMQ_DEFAULT_PASS
              value: "admin"
            - name: RABBITMQ_USE_LONGNAME
              value: "true"
            - name: K8S_SERVICE_NAME
              value: "rabbitmq-internal"
            - name: RABBITMQ_NODENAME
              value: "rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local"
            - name: K8S_HOSTNAME_SUFFIX
              value: .$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.cluster.local
            - name: RABBITMQ_ERLANG_COOKIE
              value: "SWvCP0Hrqv43NG7GybHC95ntCJKoW8UyNFWnBEWG8TY="    # generator by: echo $(openssl rand -base64 32)
          volumeMounts:
            - name: config-volume
              mountPath: /etc/rabbitmq
      volumes:
        - name: config-volume
          configMap:
            name: rabbitmq-config
            items:
              - key: rabbitmq.conf
                path: rabbitmq.conf
              - key: enabled_plugins
                path: enabled_plugins

kubernetes version:1.16.2
docker version:19.03.8

from rabbitmq-autocluster.

Gsantomaggio avatar Gsantomaggio commented on August 11, 2024

@CORRTAIN
I suggest to use our RabbitMQ Operator for Kubernetes.

We don't maintain this kind of deploy anymore (as you see from our old RabbitMQ k8s examples repo).

I will close this issue, let us know if you have problems with the operator.

from rabbitmq-autocluster.

corrtia avatar corrtia commented on August 11, 2024

thinks

from rabbitmq-autocluster.

Related Issues (20)

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.