简体   繁体   中英

Can't run mysql with an EBS volume in EKS kubernetes

I am trying to run mysql in EKS (kubernetes v 1.15).

At first I tried to run it using a local volume and it worked well.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/data/mysql"

When I moved to an EBS volume it ceases to work. I tried using a pvc to the default StorageClass (and to a custom StorageClass I created manually)

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

I tried to attach it to the pod directly using awsBlockStore

volumes:
    - name: mysql-data
      awsElasticBlockStore:
        volumeID: "vol-09df5a8d4c0f2da62"
        fsType: ext4

And nothing seamed to work. the output of kubectl logs mysql-pod is he following:

2020-04-09 11:23:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
2020-04-09 11:23:26+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-04-09 11:23:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
2020-04-09 11:23:26+00:00 [Note] [Entrypoint]: Initializing database files
2020-04-09T11:23:26.919072Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-09T11:23:26.920523Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2020-04-09T11:23:26.920548Z 0 [ERROR] Aborting

When running in EKS in order to initiate storage (EBS) you need to use storageClass object.

You can find more information on how to initiate that here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM