Using a MySQL service

The YAML code below creates two objects: a ExoscaleMySQL instance and a pod accessing it to show information about the instance. The latter references the mysql-creds secret that will contain the access keys required to connect to the instance.

apiVersion: exoscale.appcat.vshn.io/v1
kind: ExoscaleMySQL
metadata:
  name: my-mysql-example
  namespace: my-namespace
spec:
  parameters:
    backup:
      timeOfDay: "12:00:00"
    service:
      zone: ch-dk-2
      majorVersion: "14"
    size:
      plan: hobbyist-2
  writeConnectionSecretToRef:
    name: mysql-creds (1)
---
apiVersion: v1
kind: Pod
metadata:
  name: mysql-client
spec:
  containers:
  - name: mysql
    image: mysql:14
    command:
      - /bin/sh
      - -c
    args:
      - mysql --host=$MYSQL_HOST --user=$MYSQL_USER --port=$MYSQL_PORT --password=$MYSQL_PASSWORD -e 'SHOW TABLES' $MYSQL_DB
    envFrom:
      - secretRef:
          name: mysql-creds (2)
1 The operator will create a secret with the access keys to connect to the instance.
2 The pod will use the secret to connect to the instance.