單例項mysql.yaml kubernetes

manshu發表於2019-01-26

藉助於容器和k8s管理平臺,mysql的部署和使用都很方便,能滿足平時開發測試環境使用

client

叢集內:

mysql -h mysql.default.svc.cluster.local -P3306 -uroot -p mysql

image

percona:5.7.22

yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      name: mysql
  template:
    metadata:
      labels:
        name: mysql
    spec:
      containers:
      - name: mysql
        image: percona:5.7.22
        imagePullPolicy: Always
        ports:
        - containerPort: 3306
        resources:
          limits:
            memory: "500Mi"
            cpu: "500m"
          requests:
            memory: "500Mi"
            cpu: "250m"
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "mysql"
        volumeMounts:
        - name: mysql-pvc
          mountPath: /var/lib/mysql
      volumes:
       - name: mysql-pvc
         persistentVolumeClaim:
           claimName: mysql
---
kind: Service
apiVersion: v1
metadata:
  name: mysql
spec:
  type: ClusterIP
  ports:
  - name: mysql
    port: 3306
    targetPort: 3306
    protocol: TCP
  selector:
    name: mysql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: "5Gi"
  volumeName: 
  storageClassName: glusterfs

相關文章