apiVersion: v1
kind: Pod
metadata:
  name: mariadb-demo
  labels:
    app: mariadb
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: topology.kubernetes.io/zone
            operator: In
            values:
            - us-west1-a # The region of the disk
  containers:
  - name: mariadb-container
    image: mariadb:latest
    volumeMounts:
    - mountPath: /var/lib/mysql
      name: mariadb-volume
    env:
      - name: MYSQL_ROOT_PASSWORD
        value: "your database password"
  volumes:
  - name: mariadb-volume
    gcePersistentDisk:
      pdName: mariadb-disk # A disk with this name must exist in the region used above. See instructions below.
      fsType: ext4

# Note: This method of attaching disks to Pods is completely manual.
#       You need to create the disk resource outside of Kubernetes first.
#       Be sure that the region of the disk and the Pod match (update the nodeAffinity if needed).
#       For this example in GCP using the zone us-west-1a, and a disk with the name `mariadb-disk` you
#       can run:
#       `gcloud compute disks create --size=10GB --zone=us-west1-a mariadb-disk`

