skip to Main Content

I am trying to install RabbitMQ operator from this link on K8S cluster

I created the following setup on our environment

Example

K8S Control Plane (Cent OS)   - 192.168.1.2
Worker Node - 1   (Cent OS)   - 192.168.1.3
Worker Node - 2   (WindowS)   - 192.168.1.4

When I execute kubectl apply -f https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml by default it tries to install RabbitMQ on Windows Node

As the RabbitMQ Operator YAML file is too big I am not sure where and all nodeSelector should be changed

However, I want to install RabbitMQ on Linux node and I don’t know how to change / set the default node for Kubernetes

EDIT

[root@re-ctrl1 ~]# kubectl get nodes -o wide --show-labels
NAME                                    STATUS   ROLES                  AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE                       KERNEL-VERSION          CONTAINER-RUNTIME   LABELS
re-devcentos                            Ready    <none>                 83d   v1.21.0   192.168.1.3    <none>        CentOS Linux 7 (Core)          3.10.0-862.el7.x86_64   docker://1.13.1     beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=re-devcentos,kubernetes.io/os=linux
re-ctrl1                                Ready    control-plane,master   91d   v1.21.0   192.168.1.2    <none>        CentOS Linux 7 (Core)          3.10.0-862.el7.x86_64   docker://20.10.6    beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=re-ctrl1,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=
win-lj7gtbktpgg                         Ready    <none>                 8d    v1.21.1   192.168.1.4    <none>        Windows Server 2019 Standard   10.0.17763.2061         docker://20.10.7    beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=windows,kubernetes.io/arch=amd64,kubernetes.io/hostname=win-lj7gtbktpgg,kubernetes.io/os=windows,node.kubernetes.io/windows-build=10.0.17763

2

Answers


  1. In your node labels, there is an useful label called kubernetes.io/os=linux,you should use this label to schedule pod on the node with this label.

    Eg: (partial file)….

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app.kubernetes.io/component: rabbitmq-operator
        app.kubernetes.io/name: rabbitmq-cluster-operator
        app.kubernetes.io/part-of: rabbitmq
      name: rabbitmq-cluster-operator
      namespace: rabbitmq-system
    spec:
      replicas: 1
      selector:
        matchLabels:
          app.kubernetes.io/name: rabbitmq-cluster-operator
      template:
        metadata:
          labels:
            app.kubernetes.io/component: rabbitmq-operator
            app.kubernetes.io/name: rabbitmq-cluster-operator
            app.kubernetes.io/part-of: rabbitmq
        spec:
          nodeSelector:
            kubernetes.io/os: linux #<----this is making deployment's pod to choose node with this label. 
          containers:
          - command:
            - /manager
            env:
            - name: OPERATOR_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            image: rabbitmqoperator/cluster-operator:1.8.0
            name: operator
            ports:
    
    Login or Signup to reply.
  2. You can use the multiple options for same, You can use the Node selector, Node affinity & taint-toleration.

    Node affinity is a property of Pods that attracts them to a set of nodes (either as a preference or a hard requirement). Taints are the opposite — they allow a node to repel a set of pods.

    https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity

    apiVersion: v1
    kind: Pod
    metadata:
      name: with-node-affinity
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/e2e-az-name
                operator: In
                values:
                - e2e-az1
                - e2e-az2
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: another-node-label-key
                operator: In
                values:
                - another-node-label-value
      containers:
      - name: with-node-affinity
        image: k8s.gcr.io/pause:2.0
    

    for rabbitMQ it could be something like

    apiVersion: apps/v1beta1
    kind: StatefulSet
    metadata:
      name: rabbitmq
    spec:
      replicas: 1
      serviceName: rabbitmq
      selector:
        matchLabels:
          app: rabbitmq
      template:
        metadata:
          labels:
            app: rabbitmq
        spec:
          affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/os
            operator: In
            values:
            - linux
            - ubuntu
          containers:
          - name: rabbitmq
            image: rabbitmq:3-management
            env:
            - name: "RABBITMQ_ERLANG_COOKIE"
              value: "dsfsadfsfsd+0t36lQ="
            volumeMounts:
            - mountPath: /var/lib/rabbitmq
              name: rabbitmq-data
          volumes:
            - name: rabbitmq-data
              hostPath:
                path: /data/rabbitmq
                type: DirectoryOrCreate
    

    Taint & toleration example : https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search