To add more disk space to your brokers, you have to modify the storageConfigs section of the KafkaCluster custom resource.

  1. To retrieve the current configuration of a running Kafka cluster, run the following command:

    kubectl get kafkaclusters kafka -n kafka -o yaml > /tmp/kafkacluster.yaml
    
  2. In the default installation, the storageConfigs section of the KafkaCluster custom resource is similar to the following:

        storageConfigs:
            - mountPath: "/kafka-logs"
            pvcSpec:
                accessModes:
                - ReadWriteOnce
                resources:
                requests:
                    storage: 10Gi
    

    The following example adds a new disk under the kafka-logs-1 mount path.

    Note: Adding new disks doesn’t automatically guarantee that Kafka starts using the new disks. Which disk is used depends on the keys of the messages stored in the partitions. If those are not evenly distributed, then Kafka will store more messages on one of the disks.

        storageConfigs:
            - mountPath: "/kafka-logs"
            pvcSpec:
                accessModes:
                - ReadWriteOnce
                resources:
                requests:
                    storage: 10Gi
            - mountPath: "/kafka-logs-1"
            pvcSpec:
                accessModes:
                - ReadWriteOnce
                resources:
                requests:
                    storage: 10Gi
    
  3. Apply the modified CR to the cluster:

    kubectl apply -n kafka -f /tmp/kafkacluster-newdisk.yaml