美文网首页
k8s 搭建mysql

k8s 搭建mysql

作者: 繁华丶凋零 | 来源:发表于2022-11-03 10:00 被阅读0次

    2.yaml文件

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: mysql-pv
      namespace: default
    spec:
      capacity:
        storage: 1Gi
      accessModes:
        - ReadWriteMany
      persistentVolumeReclaimPolicy: Retain
      storageClassName: nfs-mysql
      nfs:
        path: /data/mysql/pv
        server: 1.1.1.1
    
    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: mysql-pvc
      namespace: default
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 1Gi
      storageClassName: nfs-mysql
    
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: mysql-svc
      namespace: default
    spec:
      type: NodePort
      ports:
        - name: mysql
          port: 3306
          targetPort: 3306
          nodePort: 3306
          protocol: TCP
      selector:
        app: mysql
    
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mysql-deploy
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mysql
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
            - name: mysql
              image: 1.1.1.1:5000/mysql:8.0
              imagePullPolicy: IfNotPresent
              env:
              - name: MYSQL_ROOT_PASSWORD
                value: "password"
              ports:
                - containerPort: 3306
              volumeMounts:
                - name: mysql-pvc
                  mountPath: /var/lib/mysql
          volumes:
            - name: mysql-pvc
              persistentVolumeClaim:
                claimName: mysql-pvc
    
    

    相关文章

      网友评论

          本文标题:k8s 搭建mysql

          本文链接:https://www.haomeiwen.com/subject/sgostdtx.html