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

    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    Javascript-DOM笔记
    JavaScript面向切面编程入门
    JavaScript面向对象编程入门
    AngularJS入门笔记
    Windows 安装 mysql-5.7.12-winx64(CommunityServer) 备忘
    PowerDesigner 16.5 链接SQL Server 2008R2
    C# GDI
    C# I/O
    Aspose.Words CookieBook
    EasyUI datagrid 多条件查询
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14276995.html
Copyright © 2011-2022 走看看