Apache Kafka - Volume Mapping for Message Log files in Kubernetes (K8s)

4/3/2019

When we deploy apache kafka on Linux/Windows, we have log.dirs and broker.id properties. on bare metal, the files are saved on the individual host instances. However, when deployed via K8s on public cloud - there must be some form of volume mounting to make sure that the transaction log fils are saved somewhere?

Has anyone done this on K8s? I am not referring to Confluent (because it's a paid subscription).

-- ha9u63ar
apache-kafka
kubernetes

1 Answer

5/28/2019

As far as I understand you are just asking how to deal with storage in Kubernetes.

Here is a great clip that talks about Kubernetes Storage that I would recommend to You.

In Kubernetes you are using Volumes

On-disk files in a Container are ephemeral, which presents some problems for non-trivial applications when running in Containers. First, when a Container crashes, kubelet will restart it, but the files will be lost - the Container starts with a clean state. Second, when running Containers together in a Pod it is often necessary to share files between those Containers. The Kubernetes Volume abstraction solves both of these problems.

There is many types of Volumes, some are cloud specific like awsElasticBlockStore, gcePersistentDisk, azureDisk and azureFile.

There are also other types like glusterfs, iscsi, nfs and many more that are listed here.

You can also use Persistent Volumes which provides an API for users and administrators that abstracts details of how storage is provided from how it is consumed:

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.

A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., can be mounted once read/write or many times read-only).

Here is a link to Portworx Kafka Kubernetes in production: How to Run HA Kafka on Amazon EKS, GKE and AKS which might be handy for you as well.

And if you would be interested in performance then Kubernetes Storage Performance Comparison is a great 10min read.

I hope those materials will help you understand Kubernetes storage.

-- Crou
Source: StackOverflow