More about Kubernetes Storage
- How to Provision Persistent Volumes for Kubernetes with the NetApp BlueXP Console
- Fundamentals of Securing Kubernetes Clusters in the Cloud
- Kubernetes Storage Master Class: A Free Webinar Series by NetApp
- Kubernetes StorageClass: Concepts and Common Operations
- Kubernetes Data Mobility with Cloud Volumes ONTAP
- Scaling Kubernetes Persistent Volumes with Cloud Volumes ONTAP
- What's New in K8S 1.23?
- Kubernetes Topology-Aware Volumes and How to Set Them Up
- Kubernetes vs. Nomad: Understanding the Tradeoffs
- How to Set Up MySQL Kubernetes Deployments with Cloud Volumes ONTAP
- Kubernetes Volume Cloning with Cloud Volumes ONTAP
- Container Storage Interface: The Foundation of K8s Storage
- Kubernetes Deployment vs StatefulSet: Which is Right for You?
- Kubernetes for Developers: Overview, Insights, and Tips
- Kubernetes StatefulSet: A Practical Guide
- Kubernetes CSI: Basics of CSI Volumes and How to Build a CSI Driver
- Kubernetes Management and Orchestration Services: An Interview with Michael Shaul
- Kubernetes Database: How to Deploy and Manage Databases on Kubernetes
- Kubernetes and Persistent Apps: An Interview with Michael Shaul
- Kubernetes: Dynamic Provisioning with Cloud Volumes ONTAP and Astra Trident
- Kubernetes Cloud Storage Efficiency with Cloud Volumes ONTAP
- Data Protection for Persistent Data Storage in Kubernetes Workloads
- Managing Stateful Applications in Kubernetes
- Kubernetes: Provisioning Persistent Volumes
- An Introduction to Kubernetes
- Google Kubernetes Engine: Ultimate Quick Start Guide
- Azure Kubernetes Service Tutorial: How to Integrate AKS with Azure Container Instances
- Kubernetes Workloads with Cloud Volumes ONTAP: Success Stories
- Container Management in the Cloud Age: New Insights from 451 Research
- Kubernetes Storage: An In-Depth Look
- Monolith vs. Microservices: How Are You Running Your Applications?
- Kubernetes Shared Storage: The Basics and a Quick Tutorial
- Kubernetes NFS Provisioning with Cloud Volumes ONTAP and Trident
- Azure Kubernetes Service How-To: Configure Persistent Volumes for Containers in AKS
- Kubernetes NFS: Quick Tutorials
- NetApp Trident and Docker Volume Tutorial
Subscribe to our blog
Thanks for subscribing to the blog.
Kubernetes provides excellent support for stateful applications, such as MySQL, through the use of persistent volumes. These persistent volumes are used to create permanent Kubernetes storage for pods and containers. This allows you to deploy and manage all of the constituent services that make up your enterprise architecture using a single, scalable platform.
With NetApp Astra Trident, the Container Storage Interface (CSI)-compliant dynamic storage provisioner, underlying storage for persistent volumes can be allocated across NetApp storage solutions. With Cloud Volumes ONTAP and Trident, you can add enterprise-grade persistent data management capabilities to containerized applications in your Kubernetes cluster.
In this article, we discuss the benefits of deploying database storage with Cloud Volumes ONTAP, and demonstrate how to set it up with your MySQL Kubernetes deployments using Trident.
Click to jump directly to the How to Set Up a Kubernetes MySQL Deployment with Cloud Volumes ONTAP section.
The Advantage of Self-Managed MySQL Deployments
Before we go into the details of how to set up MySQL Kubernetes deployments with Cloud Volumes ONTAP, let’s take a look at why you’d choose to do that in the first place.
As one of the most popular database solutions, there are both managed and self-managed options to deploy MySQL. In a managed service approach like AWS RDS, Azure MySQL, or GCP Cloud SQL, users don’t need to take care of underlying database infrastructure. But in self-managed or DIY SQL deployments, which appeal to enterprise-scale companies, there’s room for design.
Self-Managed Database Quick Look
- More customizable: Control how you configure your database
- Containerization: Leverage containers and Kubernetes
- Scalability: Avoid managed service limitations
- Data protection: Built to meet your unique requirements
Self-managed MySQL deployments can either be VM-based or built on containers, if you follow a fully containerized microservices-based architecture for your applications. In such deployment you have to use the right storage layer to ensure that your database performance is not impacted. That’s where Cloud Volumes ONTAP can become essential.
Kubernetes with Cloud Volumes ONTAP
Cloud Volumes ONTAP is NetApp’s cloud-based data management platform for AWS, Google Cloud and Azure. NetApp Astra Trident is a CSI-compliant provisioner for Kubernetes that performs dynamic storage provisioning using Cloud Volumes ONTAP for cloud as well as on-premises ONTAP storage systems. Together they offer a comprehensive set of features for working with persistent data storage:
- Storage space efficiencies that reduce cloud storage costs by up to 70%
- Data protection with NetApp Snapshot™ technology provides instant and consistent backup and restore for databases of any size
- High availability for Kubernetes persistent volumes is possible with the dual-node Cloud Volumes ONTAP HA configuration which provides cross-AZ redundancy
- Data mobility and replication is easy with NetApp SnapMirror®, which provides efficient, block-level data replications across hybrid and multicloud ONTAP clusters
- Storage tiering reduces persistent volume costs by automatically and transparently moving data between block storage to low-cost object storage as usage demands
- Instant, writable persistent volume clones can be created by DevOps and database administrators with NetApp FlexClone®
How to Set Up a Kubernetes MySQL Deployment with Cloud Volumes ONTAP
The following provides an example of deploying a single Kubernetes MySQL instance using Trident.
- First, we will create a persistent volume claim for the storage we need. As Trident uses dynamic provisioning, we will specify a StorageClass, which must have been setup prior to executing this manifest. Each storage class defines the provisioner to be used, along with any other provisioner-specific settings that will determine how the storage is provisioned. Ensure that the storage provisioner is set to “csi.trident.netapp.io” to use the CSI Trident provisioner.
apiVersion: storage.k8s.io/v1beta1 kind: StorageClass metadata: name: mysql-sc provisioner: csi.trident.netapp.io reclaimPolicy: Retain mountOptions: - debug parameters: backendType:ontap-nas
- Next, we need to create a PersistentVolumeClaim that uses the StorageClass created earlier and provisions a volume through CSI Trident:
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mysql-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Gi storageClassName: mysql-sc
The volume gets provisioned by Trident when the claim is created. This claim is then used by a pod to mount and use the provisioned volume. A reclaim policy of retain has also been specified in the StorageClass definition, which will prevent the persistent volume from being deleted if the pod releases the claim.
- We can now bind a pod to this storage by referencing it in our MySQL deployment manifest.
As shown below, we simply need to reference our previously defined PersistentVolumeClaim and specify where the bound persistent volume should be mounted within our MySQL Kubernetes container.
apiVersion: apps/v1 kind: Deployment metadata: name: mysql-server labels: app: mysqldb spec: selector: matchLabels: app: mysqldb tier: db strategy: type: Recreate template: metadata: labels: app: mysqldb tier: db spec: containers: - image: mysql:5.6 name: mysql env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name:mysql-pass key:password< ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-pv mountPath: /var/lib/mysql volumes: - name: mysql-pv persistentVolumeClaim: claimName: mysql-pvc
And that is it—your Kubernetes MySQL deployment is now set up.
We can additionally set up test instances of our Kubernetes MySQL database by creating snapshots of existing volumes using the K8s Volume Snapshot feature. With Trident, the FlexClone technology is used in the backend to create persistent volumes from these snapshots. The first step in the process is creation of a VolumeSnapshotClass. That command is then used to create a VolumeSnapshot from an existing PVC. Get step-by-step instructions on setting up Kubernetes volume cloning process here. In this case, the cloning operation is handled transparently by Astra Trident from the underlying storage volume.
Kubernetes provides a complete solution for running both stateless and stateful applications, with the extensible flexibility to integrate with various cloud storage solutions through its persistent volumes and provisioner paradigms. Trident makes it possible to integrate Kubernetes with Cloud Volumes ONTAP, giving access to a whole host of data protection and data management benefits that are vital for running database platforms, including MySQL Kubernetes deployments.