This topic describes the available fields of the VMware MySQL Custom Resource Definition.

Synopsis

apiVersion: with.sql.tanzu.vmware.com/v1
kind: MySQL
metadata:
  name: mysql-sample
spec:

#### Specify the MySQL Version
#  mysqlVersion:
#    name: mysql-8.0.31

#### Set the storage size for the database persistent storage volume
#  storageSize: 1Gi

#  imagePullSecretName: tanzu-image-registry

#### Set the storage class name to change storage class of the PVC associated with this resource
#  storageClassName: standard

#### Set the type of Service used to provide access to the MySQL database.
#  serviceType: LoadBalancer

#### Set the name of the Secret used for TLS
#  tls:
#    secret:
#      name: mysql-tls-secret

#### Enable highly available cluster
#  highAvailability:
#    enabled: true

#### Enable affinity
#  databasePodConfig:
#    affinity:
#      podAntiAffinity:
#        preferredDuringSchedulingIgnoredDuringExecution:
#          - weight: 1
#            podAffinityTerm:
#              topologyKey: "kubernetes.io/hostname"
#              labelSelector:
#                matchExpressions:
#                  - key: "app.kubernetes.io/component"
#                    operator: In
#                    values:
#                      - database
#                  - key: "app.kubernetes.io/instance"
#                    operator: In
#                    values:
#                      - mysql-sample
#    tolerations:
#    - key: node.kubernetes.io/disk-pressure
#      operator: "Exists"
#      effect: "NoExecute"
#      tolerationSeconds: 3600
#  proxyPodConfig:
#    affinity:
#      podAntiAffinity:
#        preferredDuringSchedulingIgnoredDuringExecution:
#          - weight: 1
#            podAffinityTerm:
#              topologyKey: "kubernetes.io/hostname"
#              labelSelector:
#                matchExpressions:
#                  - key: "app.kubernetes.io/component"
#                    operator: In
#                    values:
#                      - proxy
#                  - key: "app.kubernetes.io/instance"
#                    operator: In
#                    values:
#                      - mysql-sample
#    tolerations:
#    - key: node.kubernetes.io/memory-pressure
#      operator: "Exists"
#      effect: "NoExecute"
#      tolerationSeconds: 3600

#### Examples to set resource limit/request for mysql/backup containers.
#  resources:

#### This is the container running the mysql server.
#    mysql:
#      requests:
#        cpu: 750m
#        memory: 500Mi
#      limits:
#        cpu: '1.0'
#        memory: 1Gi

#### This is the sidecar container that manages backups and innodb cluster operations
#    mysqlSidecar:
#      requests:
#        cpu: 100m
#        memory: 50Mi
#      limits:
#        cpu: 250m
#        memory: 256Mi

#### This is the container that proxies connections to MySQL
#    proxy:
#      requests:
#        cpu: 200m
#        memory: 48Mi
#      limits:
#        cpu: '1.0'
#        memory: 256Mi

#### This is the container that exports metrics
#    metrics:
#      requests:
#        cpu: 100m
#        memory: 32Mi
#      limits:
#        cpu: 250m
#        memory: 75Mi

Description

Applying this resource causes the Kubernetes Operator to create a StatefulSet with a single Pod and three containers. One container runs the MySQL database software, one runs the components to support backups, and the third runs the mysqld_exporter (for monitoring). The MySQL pod mounts a persistent volume claim (PVC) which holds the MySQL data.

You specify MySQL instance configuration properties to the MySQL operator with a YAML-formatted manifest file. A sample manifest file is provided in mysql.yaml. See also Creating and Deleting Instance for information about deploying a new MySQL instance using a manifest file.

The list below explains the properties that you can set in your MySQL resource.

Metadata

name: <string>
Required
Default: standard
The name of the MySQL instance. Must be unique within a namespace. Cannot be modified after the MySQL instance has been created. The metadata can set the name, namespace, labels, annotations, and more for the MySQL object. For more information, see the Kubernetes documentation.
Example: mysql-sample

Spec

mysqlVersion: <String>
Optional
Default:
The MySQL version that will be used for creating an instance. If the user does not specify a value, the latest supported version will be used as the default. For example, if the VMware MySQL Operator supports mysql-8.0.27, mysql-8.0.28, mysql-8.0.29, and mysql-8.0.31 this value defaults to mysql-8.0.31.
Each Operator release supports several MySQL versions. Only the permitted version strings are valid input for the field. Entries that do not match a supported version generate an error. Use kubectl get mysqlversion to verify the MySQL versions of your Operator release.
Use the "floating version tag" mysql-latest to configure your instance to always upgrade to the latest MySQL version supported by future Operator upgrades.
Example: mysql-8.0.31

Caution

After an Operator upgrade, instances with mysqlVersion.name as mysql-latest will automatically reboot and upgrade to the latest supported MySQL version for that Operator. storageSize: <Quantity>
Optional
Default: 1Gi
The size of the persistent volume claims (PVCs) for MySQL instance Pods. Specify a suffix for the units (for example: 100G, 1T). After being set, cannot be reduced, but can be increased. For information about allowed size units, see the discussion about resource quantities in the The Kubernetes resource model in the community GitHub repository.
Example: 50Gi

imagePullSecretName: <string>
Optional
Default: Defaults to the imagePullSecretName: used during Operator deployment, as set in the Operator's values.yaml. See Configure a Kubernetes Secret for Accessing the Private Container Registry.
Note that the secret may need to be recreated within your pod's namespace in order for your pod to access it.
An existing Kubernetes docker-registry secret that can access the registry containing the MySQL image.
Example: tanzu-image-registry

storageClassName: <string>
Optional
Default: standard
The StorageClass used for PVCs associated with MySQL instance Pods. Cannot be modified after the MySQL instance has been created. For available types, contact your Kubernetes admin. For information about the StorageClass concept, see the Kubernetes documentation.
Example: standard

serviceType: <string>
Optional
Default: ClusterIP
The type of Service used to provide access to the MySQL database. Only ClusterIP and LoadBalancer are supported. For more information about Kubernetes ServiceTypes, see the Service Types in the Kubernetes documentation.
Example: LoadBalancer

tls.secret.name: <string>
Optional
Default: n/a
The name of the Kubernetes secret containing the TLS certificate and private key used to support encrypted connections by clients. For more configuration details, see Configuring TLS for MySQL Instances
Example: mysql-tls-secret

highAvailability.enabled: <boolean>
Optional
Default: false
Whether the instance is a high-availability cluster (not single-node). After being set to true, it cannot be modified. For information about high availability, see Configuring MySQL Instances for High Availability. Example: true

databasePodConfig.affinity: <corev1.Affinity>
Optional
Default: Database pods for a given instance are scheduled in unique Kubernetes nodes.
The affinity rules for the MySQL database pods must follow the affinity defined by the Kubernetes api, can be updated, and are not required when creating resources. For more information regarding the various fields, see the Affinity and Anti-Affinity in the Kubernetes documention.
Example:

apiVersion: with.sql.tanzu.vmware.com/v1
kind: MySQL
metadata:
    name: my-instance
spec:
  databasePodConfig:
    affinity:
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            podAffinityTerm:
              topologyKey: "kubernetes.io/hostname"
              labelSelector:
                matchExpressions:
                  - key: "app.kubernetes.io/component"
                    operator: In
                    values:
                      - database
                  - key: "app.kubernetes.io/instance"
                    operator: In
                    values:
                      - <instance.name>

databasePodConfig.tolerations: <corev1.Toleration>
Optional
Default: No default tolerations are configured by the VMware MySQL Operator.
Configures Kubernetes Tolerations for the MySQL instance's database Pods. The Tolerations can be updated, and are not required when creating resources. For more details on the Kubernetes Taints and Tolerations concept, see Taints and Tolerations in the Kubernetes documentation.
Example:

---
apiVersion: with.sql.tanzu.vmware.com/v1
kind: MySQL
metadata:
    name: my-instance
spec:
  databasePodConfig:
    tolerations:
    - key: node.kubernetes.io/memory-pressure
      operator: "Exists"
      effect: "NoExecute"
      tolerationSeconds: 3600

proxyPodConfig.affinity: <corev1.Affinity>
Optional
Default: Preference is to avoid scheduling the two proxy pods on the same Kubernetes node.
Affinity rules for the Proxy database pods. Used only when spec.highAvailability.enabled = true. For more information regarding the various fields, see the Affinity and Anti-Affinity in the Kubernetes documention.
Example:

apiVersion: with.sql.tanzu.vmware.com/v1
kind: MySQL
metadata:
    name: my-instance
spec:
  databasePodConfig:
    affinity:
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 1
          podAffinityTerm:
            topologyKey: "kubernetes.io/hostname"
            labelSelector:
              matchExpressions:
                - key: "app.kubernetes.io/component"
                  operator: In
                  values:
                    - proxy
                - key: "app.kubernetes.io/instance"
                  operator: In
                  values:
                    - <instance.name>

proxyPodConfig.tolerations: <corev1.Toleration>
Optional
Default: No default tolerations are configured by the VMware MySQL Operator
Configures Kubernetes Tolerations for the MySQL instance's database Pods. For more details on the Kubernetes Taints and Tolerations concept, see Taints and Tolerations in the Kubernetes documentation.
Example:

---
apiVersion: with.sql.tanzu.vmware.com/v1
kind: MySQL
metadata:
  name: my-instance
spec:
  databasePodConfig:
    tolerations:
    - key: node.kubernetes.io/memory-pressure
      operator: "Exists"
      effect: "NoExecute"
      tolerationSeconds: 3600

Resources

resources.mysql: <limits.cpu, limits.memory>
Optional
Default: Best effort
The maximum CPU and memory allowed for the MySQL container. If not specified, Kubernetes does its best effort to allocate necessary compute resources for this container. For more information about managing resources for containers, see Manage Resources in the Kubernetes documentation. Example:

...
resources:
  mysql:
    limits:
      cpu: '1.0'
      memory: 1Gi
...

resources.mysql: <requests.cpu, requests.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL container. If not specified, defaults to limits, if limits have been explicitly specified. For more information about limits, see theFor more information about managing resources for containers, see Manage Resources in the Kubernetes documentation. Example:

...
resources:
  mysql:
    requests:
      cpu: 750m
      memory: 500Mi
...

resources.mysqlSidecar: <limits.cpu, limits.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL Sidecar container. This sidecar container manages backups and highAvailability cluster operations. If not specified, Kubernetes does its best effort to allocate necessary compute resources for this container. For more information about managing resources for containers, see Manage Resources in the Kubernetes documentation.
Example:

...
resources:
  mysqlSidecar:
    limits:
      cpu: 250m
      memory: 256Mi

...

resources.mysqlSidecar: <requests.cpu, requests.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL Sidecar container. This sidecar container manages backups and highAvailability cluster operations. If not specified, defaults to limits, if limits have been explicitly specified. For more information about limits, see theFor more information about managing resources for containers, see Manage Resources in the Kubernetes documentation.
Example:

...
resources:
  mysqlSidecar:
    requests:
      cpu: 100m
      memory: 50Mi
...

resources.metrics: <limits.cpu, limits.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL metrics container. This container is created during MySQL instance initialization. If not specified, Kubernetes does its best effort to allocate necessary compute resources for this container. For more information about managing resources for containers, see Manage Resources in the Kubernetes documentation.
Example:

...
resources:
  metrics:
    limits:
      cpu: 250m
      memory: 75Mi
...

resources.metrics: <requests.cpu, requests.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL metrics container. This container is created during MySQL instance initialization. If not specified, defaults to limits, if limits have been explicitly specified. For more information about limits, see Manage Resources in the Kubernetes documentation.
Example:

...
resources:
  metrics:
    requests:
      cpu: 100m
      memory: 32Mi
...

resources.proxy: <limits.cpu, limits.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL proxy container that handles connections to MySQL when highAvailability.enabled is true. If not specified, Kubernetes does its best effort to allocate necessary compute resources for this container. For more information about managing resources for containers, see Manage Resources in the Kubernetes documentation.
Example:

...
resources:
  proxy:
    limits:
      cpu: '1.0''
      memory: 256Mi
...

resources.proxy: <requests.cpu, requests.memory>
Optional
Default: Best effort
The minimum CPU and memory allowed for the MySQL proxy container that handles connections to MySQL when highAvailability.enabled is true. If not specified, defaults to limits, if limits have been explicitly specified. For more information see Manage Resources in the Kubernetes documentation.
Example:

...
resources:
  proxy:
    requests:
      cpu: 200m
      memory: 48Mi

...

persistentVolumeClaimPolicy: <string>
Optional
Default: Retain
Describes the PVC retention policy when the associated MySQL instance is deleted. Values can be Retain or Delete.
Example: Delete

check-circle-line exclamation-circle-line close-line
Scroll to top icon