☁️Kubernetes Storage with Example (Huawei CCE)

Rabia Yılmaz
Huawei Developers
Published in
8 min readJul 28, 2023

Introduction

Storage services for Kubernetes provide scalable, reliable, and flexible storage solutions tailored specifically for containerized environments. These services enable seamless integration between Kubernetes clusters and cloud storage providers, empowering organizations to efficiently manage their data while leveraging the benefits of the cloud. 💪🌐

With cloud storage services, Kubernetes users can easily provision and attach persistent volumes to their containers, ensuring data persistence even when pods are rescheduled or scaled up/down. This eliminates the need for manual intervention and simplifies the management of stateful applications running on Kubernetes. 📊📂

⚡🔐 Moreover, these services offer advanced features such as data encryption, access control, and backup/restore capabilities, ensuring the security and integrity of your valuable data. They also provide high availability and fault tolerance mechanisms for seamless data replication and disaster recovery.

Kubernetes Storage Everest Add-on CSI

Why do We Need Storage Services for CCE

Data Persistence: 🔄 + 📦 = 💾 Kubernetes containers are ephemeral 🌬️, so data does not persist after restarts or termination. Storage services ensure that valuable data is stored and retrieved even if containers come and go.

Stateful Applications: 🏗️ + 🧩 = 💾 Kubernetes supports both stateless and stateful applications. Stateful apps require persistent storage to retain their state 🧾 across restarts or scaling operations. Storage services provide the necessary storage for application data, databases, logs, etc., keeping stateful apps happy.

Scaling and High Availability: ↔️ + ⬆️⬇️ = 💾 Kubernetes allows easy scaling by adding/removing replicas. Storage services offer scalable solutions that handle increased storage needs as app instances grow. They also enable data replication and redundancy, ensuring high availability and durability 🆙.

Specialized Storage Requirements: 📥📤🗂️ = 💾 Different apps have unique storage needs. Some require block-level storage 🔲, while others need file 📁 or object 🗃️ storage. Kubernetes storage services support various storage types, letting users choose the best fit for their apps.

Dynamic Provisioning: 🎯 + ⚡ = 💾 Kubernetes storage services include dynamic provisioning, simplifying storage resource management. It automates creating and allocating storage volumes as needed, removing manual configuration efforts.

Integration with PVCs: 🧩 + 📥⚙️ = 💾 Kubernetes uses Persistent Volume Claims (PVCs) to request storage resources from providers. Storage services integrate with PVCs, allowing users to define requirements and allocate suitable storage resources to apps.

Overall, storage services in Kubernetes (💾) enhance app functionality and reliability by providing data persistence, scalability, high availability, and flexibility to meet diverse storage demands.

Kubernetes Storage (Volumes)

What are Storage Types for CCE

Kubernetes provides various storage options to manage and persist data for applications running on the cluster. Here are some commonly used storage types in Kubernetes:

Volumes: Volumes are the simplest and most commonly used storage type in Kubernetes. They represent a directory accessible to containers in a pod. Kubernetes supports several volume types, including emptyDir (ephemeral volume), hostPath (mounts a file or directory from the host), persistentVolumeClaim (binds to a Persistent Volume), etc. Kubernetes supports multiple types of volumes. The most commonly used ones are as follows:

  • emptyDir: an empty volume used for temporary storage
  • hostPath: a volume that mounts a directory of the host into your pod
  • ConfigMap and secret: special volumes that inject or pass information to your pod. For details about how to mount ConfigMaps and secrets, see ConfigMap and Secret.

PersistentVolumes (PV): A PersistentVolume is a piece of network-attached storage in the cluster that can be dynamically provisioned and consumed by pods. PVs have a lifecycle independent of any individual pod and can be dynamically allocated and released based on demand.

PersistentVolumeClaims (PVC): A PersistentVolumeClaim is a request for storage by a user. It binds to a matching PersistentVolume and provides an abstraction layer that decouples the details of the underlying storage from the pod.

Storage Classes: Storage Classes provide a way to define different classes of storage with varying performance characteristics and availability. They allow dynamic provisioning of storage volumes based on the specified class, making it easier to manage storage in a cluster.

StatefulSets: StatefulSets are a higher-level abstraction in Kubernetes designed to manage stateful applications. They provide guarantees about the ordering and uniqueness of pods, which is important for applications that require stable network identities and persistent storage.

ConfigMaps: ConfigMaps are used to store non-confidential configuration data in key-value pairs. While not primarily intended for storage, they can inject configuration files or environment variables into pods.

Secrets: Secrets are similar to ConfigMaps but specifically designed for storing sensitive information, such as passwords, API keys, and TLS certificates. They are encrypted at rest and can be mounted as files or exposed as environment variables in pods.

These are some of the commonly used storage types in Kubernetes. The choice of storage type depends on the specific requirements of your application and the available infrastructure in your Kubernetes cluster.

Kubernetes PVC and PV

What is CSI Driver

CSI (Container Storage Interface) Drivers for Kubernetes are plugins that enable persistent storage provisioning and management in a Kubernetes cluster. CSI is a standardized interface for connecting storage systems to container orchestrators like Kubernetes.

Traditionally, Kubernetes used in-tree storage plugins that were tightly coupled with the core Kubernetes codebase. This approach had limitations in terms of extensibility, maintainability, and the ability to support a wide range of storage systems.

CSI Drivers provide a more flexible and modular way to integrate different storage solutions with Kubernetes. They allow third-party storage vendors to develop their own drivers that can be independently deployed and updated without modifying the Kubernetes core code. With CSI, storage vendors can offer their own features, capabilities, and performance optimizations.

The CSI specification defines a set of RPC (Remote Procedure Call) calls and interfaces that storage providers must implement. These calls include volume provisioning, attaching/detaching volumes to/from nodes, mounting/unmounting volumes, and snapshotting. The CSI drivers act as intermediaries between Kubernetes and the underlying storage systems, translating these RPC calls into operations on the storage systems.

By using CSI drivers, Kubernetes users can provision and manage persistent volumes using a unified interface, regardless of the specific storage solution being used. It simplifies storage integration, allows for more seamless upgrades, and enables compatibility with a wide range of storage platforms.

CSI Drivers are typically installed as daemon sets in a Kubernetes cluster, ensuring that the driver pods run on every node and can interact with the local storage resources. Once installed, users can create PersistentVolumes (PVs) and PersistentVolumeClaims (PVCs) to request storage resources from the underlying storage systems through the CSI drivers. Click more information for CSI.

CSI Volumes

CCE supports the following types of cloud volumes:

  • EVS: EVS offers scalable block storage for cloud servers. With high reliability, high performance, and rich specifications, EVS disks can be used for distributed file systems, dev/test environments, data warehouses, and high-performance computing (HPC) applications.
  • SFS Turbo: Expandable to 320 TB, SFS Turbo provides a fully hosted shared file storage, highly available and stable to support small files and applications requiring low latency and high IOPS. You can use SFS Turbo in high-traffic websites, log storage, compression/decompression, DevOps, enterprise OA, and containerized applications.
  • OBS: OBS is a stable, secure, and easy-to-use object storage service that lets you inexpensively store data of any format and size. You can use it in enterprise backup/archiving, video on demand (VoD), video surveillance, and many other scenarios.

Visit for more information.

CSI driver differences

Example with Huawei Cloud Container Engine (MySQL)

This example is for those with intermediate knowledge of Kubernetes.

Huawei CCE
  • Click or search Cloud Container Engine under the container
  • Buy a CCE, node pool (3 nodes)
Huawei Cloud Container Engine — CCE Node Pool
  • Bind an EIP
CCE Information Page EIP binding
Buy an EIP — Huawei Cloud
  • Then go to the Workloads from the side menu and create a StatefulSet (MySQL). We need also deployment for PhpMyAdmin. Using the SWR image in this article. If you need more information about image registry follow this article.
PhpMyAdmin - deployment environment
PhpMyAdmin — Loadbalancer Service
MySQL — StatefulSet environment
PhpMyAdmin — Deployment Login Page
  • Everything is okay. But this a database if a node or pod is recreated all data are deleted so we need to keep data with volume. Let’s look at what is claimed. Go to your statefulSet page and select database then click container. Edit the page and choose storage from the side menu.
Creating an EVS PVC
Finally adding a PVC for the database
Kubernetes Database Storage

Conclusion

We learned Kubernetes storage types, why we need storage for Kubernetes or CCEs, and how to create PVC for any database. See you with a real scenario in our next article.

In conclusion, cloud storage services for Kubernetes empower organizations to manage their data within containerized environments effectively. By leveraging the cloud's scalability, reliability, and flexibility, businesses can ensure seamless data persistence, security, and availability for their applications. So, if you’re looking to harness the full potential of Kubernetes while optimizing your data management strategy, it’s time to explore the world of cloud storage services! ☁️📊💡

References

--

--