• 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

    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    spark实验四(2)
    spark实验四
    神奇的一天
    Spark实验三
    Scala实验任务三
    Scala实验任务二
    Scala语言实验任务一
    kettle的基本使用
    质量属性之安全性战术
    datax相关
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14276995.html
Copyright © 2020-2023  润新知