K8S部署Mysql5.7.32

  • 通过configMap的方式配置mysql
  • 把mysql数据目录挂载到本地,先要保证本地目录存在 /var/lib/mysql
  • nodeSelector标明了主机标签,需要通过kubectl label [nodeName] key=value的方式给主机打上标签
  • kubectl -f mysql.yml之后,可以通过33306端口访问
    mysql.yml如下:
apiVersion: v1
data:
  mysqld.cnf: |-
    [client]
    default-character-set=utf8
    [mysqld]
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    datadir         = /var/lib/mysql
    skip_external_locking
    skip-symbolic-links
    memlock=true
    max_connect_errors = 20000
    max_connections = 3000   
    skip-name-resolve
    default-time-zone = system
    default-storage-engine = InnoDB
    explicit_defaults_for_timestamp = 1
    lower_case_table_names = 1
    key_buffer_size = 4096M
    table_open_cache = 1024
    sort_buffer_size = 4M
    read_buffer_size = 4M
    thread_cache_size = 128
    query_cache_size = 512M
    char

你可能感兴趣的:(【KUBERNETES,】)