• 已删除用户
Administrator
发布于 2023-07-23 / 5 阅读
0

K8S部署MySQL(单机版)

以下YAML文件从本地搭建的KubeSphere工作负载中导出,可能因关联保密字典Secret、配置字典ConfigMap、服务Service等无法直接运行,仅供参考。

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: mysql
  namespace: supports
  labels:
    app: mysql
  annotations:
    kubesphere.io/creator: admin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mysql
      annotations:
        kubesphere.io/creator: admin
        kubesphere.io/imagepullsecrets: '{}'
        kubesphere.io/restartedAt: '2023-07-24T07:55:55.248Z'
        logging.kubesphere.io/logsidecar-config: '{}'
    spec:
      volumes:
        - name: mysql-data
          hostPath:
            path: /mydata/mysql/data/
            type: ''
        - name: host-time
          hostPath:
            path: /etc/localtime
            type: ''
      containers:
        - name: container-mysql
          image: 'mysql:5.7'
          ports:
            - name: tcp-3306
              containerPort: 3306
              protocol: TCP
            - name: tcp-33060
              containerPort: 33060
              protocol: TCP
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-root-password
                  key: password
          resources: {}
          volumeMounts:
            - name: mysql-data
              mountPath: /var/lib/mysql
            - name: host-time
              readOnly: true
              mountPath: /etc/localtime
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      schedulerName: default-scheduler
  serviceName: mysql-dv3k
  podManagementPolicy: OrderedReady
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
  revisionHistoryLimit: 10