Xin chào mọi người ạ, mọi người xem giúp em với sao em tạo mysql trong kubernetes mà bị lỗi ạ:
secrets.yaml
apiVersion: v1
kind: Secret
metadata:
  name: systemsecret
type: Opaque
data:
  MYSQL_ROOT_PASSWORD: cGFzc3dvcmQK
mysql-persistent-storage.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
mysql.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:latest
        args:
        - "--ignore-db-dir=lost+found"
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: systemsecret
              key: MYSQL_ROOT_PASSWORD
              optional: false
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
  selector:
    app: mysql
  clusterIP: None
Nó ra lỗi thế này:
2022-11-25 11:35:29+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started.
2022-11-25 11:35:29+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-11-25 11:35:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started.
2022-11-25 11:35:30+00:00 [Note] [Entrypoint]: Initializing database files
2022-11-25T11:35:30.546317Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2022-11-25T11:35:30.546411Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 81
2022-11-25T11:35:30.547739Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2022-11-25T11:35:30.547744Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2022-11-25T11:35:30.547804Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-25T11:35:30.547913Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31)  MySQL Community Server - GPL
Em noob boy kubernete nhờ mọi người giúp ạ 
      
    

    83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?