侧边栏壁纸
博主头像
★街角晚灯★博主等级

博观而约取 厚积而薄发

  • 累计撰写 463 篇文章
  • 累计创建 184 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

k8s 运行单实例 mysql

WinJay
2021-12-30 / 0 评论 / 0 点赞 / 142 阅读 / 1677 字 / 正在检测是否收录...
温馨提示:
文章发布较早,内容可能过时,阅读注意甄别。。。。
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
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区