Kubernetes Cassandra Load Balance On Two Servers With Replication

4/16/2021

I have two ubuntu servers (On same network) I need to install Cassandra on Kubernetes on both of them. (4 Nodes each) Can anyone please help me with that.

Here's my cluster.yaml file (On server 1)

Not sure how to configure server 2.

Below is how the setup should be:

Number of servers: 2 (Ubuntu OS) Number of nodes in each server: 4

kind: StatefulSet
metadata:
  name: cassandra
  namespace: cassandra
  labels:
    app: cassandra
spec:
  serviceName: cassandra
  replicas: 4
  selector:
    matchLabels:
      app: cassandra
  template:
    metadata:
      labels:
        app: cassandra
    spec:
      terminationGracePeriodSeconds: 1800
      containers:
      - name: cassandra
        image: datastax/dse-server:6.7.7
        imagePullPolicy: Always
        ports:
        - containerPort: 7000
          name: intra-node
        - containerPort: 7001
          name: tls-intra-node
        - containerPort: 7199
          name: jmx
        - containerPort: 9042
          name: cql
        resources:
          limits:
            cpu: "8000m"
            memory: 16Gi
          requests:
            cpu: "8000m"
            memory: 16Gi
        securityContext:
          capabilities:
            add:
              - IPC_LOCK
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - nodetool drain

        env:
          - name: MAX_HEAP_SIZE
            value: 8G
          - name: HEAP_NEWSIZE
            value: 8G
          - name: SEEDS
            value: "10.32.0.4,10.32.0.5"
          - name: CLUSTER_NAME
            value: "HEROIC Cluster"
          - name: DC
            value: "dc1"
          - name: RACK
            value: "rack1"
          - name: NUM_TOKENS
            value: "128"
          - name: DS_LICENSE
            value: "accept"
          - name: POD_IP
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
        readinessProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - "cp /ready_probe.sh /tmp/ready_probe.sh && chmod 777 /tmp/ready_probe.sh && /tmp/ready_probe.sh"
          initialDelaySeconds: 20
          timeoutSeconds: 5                
        volumeMounts:
        - name: cassandra-data
          mountPath: /var/lib/cassandra
          subPath: cassandra
        - name: cassandra-data
          mountPath: /var/lib/spark
          subPath: spark
        - name: cassandra-data
          mountPath: /var/lib/dsefs
          subPath: dsefs
        - name: cassandra-data
          mountPath: /var/log/cassandra
          subPath: log-cassandra
        - name: cassandra-data
          mountPath: /var/log/spark
          subPath: log-spark
        - name: cassandra-data
          mountPath: /config
          subPath: config
        - name: cassandra-data
          mountPath: /var/lib/opscenter
          subPath: opscenter
        - name: cassandra-data
          mountPath: /var/lib/datastax-studio
          subPath: datastax-studio
        - name: script
          mountPath: /ready_probe.sh
          subPath: ready.sh
      volumes:
      - name: script
        configMap:
          name: script
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - ubuntuserver          
  volumeClaimTemplates:
  - metadata:
      name: cassandra-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: local-storage
      resources:
        requests:
          storage: 2Gi

Can anyone please help me with that.

-- Mohammad Abbas Sayed
cassandra
kubectl
kubernetes
load-balancing

0 Answers