镜像:mysql:8.0.34
apiVersion: apps/v1 kind: Deployment metadata: name: mysql labels: workload.user.cattle.io/workloadselector: apps.deployment-wfs-test-mysql namespace: wfs-test selector: matchLabels: workload.user.cattle.io/workloadselector: apps.deployment-wfs-test-mysql spec: containers: - env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: key: mysql-root-password name: wfs-mysql-mysql-single optional: false - name: MYSQL_PASSWORD valueFrom: secretKeyRef: key: mysql-password name: wfs-mysql-mysql-single optional: false - name: MYSQL_USER value: xxxx - name: MYSQL_DATABASE value: xxxx image: harbor.goldwind.com/library/mysql:8.0.34 imagePullPolicy: Always livenessProbe: exec: command: - sh - '-c' - exec mysqladmin status -uroot -p$MYSQL_ROOT_PASSWORD failureThreshold: 3 initialDelaySeconds: 120 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 30 name: mysql ports: - containerPort: 3306 name: http3306 protocol: TCP _listeningPort: xxxx _serviceType: NodePort readinessProbe: exec: command: - sh - '-c' - exec mysqladmin status -uroot -p$MYSQL_ROOT_PASSWORD failureThreshold: 3 initialDelaySeconds: 60 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 30 resources: limits: cpu: '2' memory: 6Gi requests: cpu: 500m memory: 1Gi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /var/lib/mysql name: vol-dyrz2 - mountPath: /etc/mysql/conf.d/my.cnf name: vol-ofgpb subPath: my.cnf dnsPolicy: ClusterFirst nodeName: kubernetes-dev-worker-1 restartPolicy: Always schedulerName: default-scheduler serviceAccount: default serviceAccountName: default terminationGracePeriodSeconds: 30 volumes: - configMap: defaultMode: 420 name: xx-mysql-cnf name: vol-ofgpb - name: vol-dyrz2 persistentVolumeClaim: claimName: mysql-data-pvc __newPvc: type: persistentvolumeclaim metadata: namespace: wfs-test spec: storageClassName: '' volumeName: '' resources: requests: {} progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate
配置文件:
其中日志文件是上层目录需要是真实存在的
my.cnf [mysqld] basedir=/var/lib/mysql port=3306 socket=/var/run/mysqld/mysqld.sock pid-file=/var/run/mysqld/mysqld.pid max_allowed_packet=1G character-set-server=UTF8 collation-server=utf8_general_ci default-time-zone=timezone default-time_zone='+8:00' general_log=1 general_log_file=/var/lib/mysql/mysqld.log log_error=/var/lib/mysql/mysqld.err slow_query_log=1 long_query_time=10.0 slow_query_log_file=/var/lib/mysql/mysqld-slow.log [client] port=3306 socket=/var/run/mysqld/mysqld.sock default-character-set=UTF8 [manager] port=3306 socket=/var/run/mysqld/mysqld.sock pid-file=/var/run/mysqld/mysqld.pid
标签:name,default,mysqld,mysql,var,k8s,安装,log From: https://www.cnblogs.com/xiaoxiaomuyuyu/p/17869848.html