hamburger icon close icon
Kubernetes Storage

How to Set Up MySQL Kubernetes Deployments with Cloud Volumes ONTAP

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:

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.

  1. 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 “” to use the CSI Trident provisioner. apiVersion: kind: StorageClass metadata: name: mysql-sc provisioner: reclaimPolicy: Retain mountOptions: - debug parameters: backendType:ontap-nas
  2. 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.

  3. 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.

New call-to-action
Michael Shaul, Principal Technologist

Principal Technologist