zoukankan      html  css  js  c++  java
  • k8s 运行单实例 mysql

    配置文件mysql.yaml

    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: mysql-01
    spec:
      ports:
      - port: 3306
      selector:
        app: mysql-01
      clusterIP: None
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mysql-01
      labels:
        app: mysql-01
    spec:
      selector:
        matchLabels:
          app: mysql-01
      template:
        metadata:
          labels:
            app: mysql-01
        spec:
          containers:
          - name: mysql-01
            image: mysql:5.6
            resources:
              limits:
                memory: "512Mi"
                cpu: "1500m"
            ports:
            - containerPort: 3306
            env:
            - name: MYSQL_ROOT_PASSWORD
              value: Nosleeping996
            volumeMounts:
            - name: mysql-01-persistent-storage
              mountPath: /var/lib/mysql
            - name: mysql-01-conf
              mountPath: /etc/mysql
          volumes:
          - name: mysql-01-persistent-storage
            persistentVolumeClaim:
              claimName: mysql-01-pvc
          - name: mysql-01-conf
            configMap:
              name: my.cnf
    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: my.cnf
    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
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: mysql-01-pvc
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 5Gi
    

    应用部署
    kubectl apply -f mysql.yaml

    测试链接
    kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql-01 -pNosleeping996

    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    《PHP面试笔试真题库》——PHP面试的好帮手
    PHP面试常考之会话控制
    PHP面试常考内容之Memcache和Redis(2)
    PHP面试常考内容之Memcache和Redis(1)
    PHP面试常考内容之面向对象(3)
    SQL全表扫描优化基础知识
    Windows CMD命令大全
    Asp.net 获取客户端的信息
    sql日期创建
    sql语句去掉前面的0(前导零,零前缀)
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14276995.html
Copyright © 2011-2022 走看看