侧边栏壁纸
博主头像
WinJay博主等级

博观而约取 厚积而薄发

  • 累计撰写 333 篇文章
  • 累计创建 168 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

k8s 运行单实例 mysql

WinJay
2021-12-30 / 0 评论 / 0 点赞 / 44 阅读 / 1,192 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-01-20,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
k8s 运行单实例 mysql

---
apiVersion: v1
kind: Service
metadata:
  name: mysqlonlyone
spec:
  ports:
  - port: 3306
  selector:
    app: mysqlonlyone
  clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysqlonlyone
  labels:
    app: mysqlonlyone
spec:
  selector:
    matchLabels:
      app: mysqlonlyone
  template:
    metadata:
      labels:
        app: mysqlonlyone
    spec:
      containers:
      - name: mysqlonlyone
        image: mysql:5.6.51
        resources:
          limits:
            memory: "512Mi"
            cpu: "1"
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: Nosleeping996
        volumeMounts:
        - name: mysqlonlyone-persistent-storage
          mountPath: /var/lib/mysql
        - name: mysqlonlyone-conf
          mountPath: /etc/mysql
      volumes:
      - name: mysqlonlyone-persistent-storage
        persistentVolumeClaim:
          claimName: mysqlonlyone-pvc
      - name: mysqlonlyone-conf
        configMap:
          name: mysqlonlyone.cfg
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysqlonlyone.cfg
data:
  my.cnf: |
    [mysqld]
    #skip-name-resolve
    port = 3306
    character-set-server=utf8mb4
    collation-server=utf8mb4_unicode_ci
    skip-character-set-client-handshake=1
    default-storage-engine=INNODB
    max_allowed_packet = 500M
    explicit_defaults_for_timestamp=1
    long_query_time = 10

手动创建的PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysqlonlyone-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
0

评论区