Kubernetes快速部署mariadb:10.5.8

  sre

DHOZEd.png

PVC mariadb-test

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mariadb-test
  namespace: sre
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: "250Gi"
  volumeName: 
  storageClassName: nfs

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mariadb-test
  namespace: sre
  labels:
    app: mariadb-test
spec:
  selector:
    matchLabels:
      app: mariadb-test
  template:
    metadata:
      labels:
        app: mariadb-test
    spec:
      containers:
      - name: mariadb
        image: mariadb:10.5.8
        imagePullPolicy: IfNotPresent
        args:
        - --default_authentication_plugin=mysql_native_password
        - --character-set-server=utf8mb4
        - --collation-server=utf8mb4_unicode_ci
        ports:
        - containerPort: 3306
          name: dbport
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: test111111
        - name: MYSQL_ROOT_HOST
          value: "%"
        - name: MYSQL_DATABASE
          value: test
        volumeMounts:
        - name: db-data
          mountPath: /var/lib/mysql
      volumes:
      - name: db-data
        persistentVolumeClaim:
          claimName: mariadb-test

svc

apiVersion: v1
kind: Service
metadata:
  name: mariadb-test
  namespace: sre
spec:
  type: NodePort
  ports:
  - name: mysqlport
    protocol: TCP
    port: 3306
    targetPort: dbport
    nodePort: 30005
  selector:
    app: mariadb-test

LEAVE A COMMENT

Captcha Code