apiVersion: v1 kind: Service metadata: name: mysql namespace: iloom spec: clusterIP: None ports: - port: 3306 targetPort: 3306 selector: app: mysql --- apiVersion: apps/v1 kind: StatefulSet metadata: name: mysql namespace: iloom spec: serviceName: mysql replicas: 1 selector: matchLabels: app: mysql template: metadata: labels: app: mysql spec: imagePullSecrets: - name: harbor-pull-secret containers: - name: mysql image: harbor-in-k3s.cheverjohn.me/iloom/mysql:8.0 ports: - containerPort: 3306 env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: db-secret key: MYSQL_ROOT_PASSWORD - name: MYSQL_DATABASE valueFrom: secretKeyRef: name: db-secret key: MYSQL_DATABASE - name: TZ value: Asia/Shanghai args: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci volumeMounts: - name: mysql-data mountPath: /var/lib/mysql - name: init-scripts mountPath: /docker-entrypoint-initdb.d resources: requests: cpu: 250m memory: 512Mi limits: cpu: "1" memory: 1Gi readinessProbe: exec: command: ["mysqladmin", "ping", "-h", "localhost"] initialDelaySeconds: 30 periodSeconds: 10 livenessProbe: exec: command: ["mysqladmin", "ping", "-h", "localhost"] initialDelaySeconds: 60 periodSeconds: 30 volumes: - name: init-scripts configMap: name: mysql-init-scripts volumeClaimTemplates: - metadata: name: mysql-data spec: accessModes: ["ReadWriteOnce"] storageClassName: longhorn resources: requests: storage: 5Gi