Create ConfigMap


ConfigMap allow you to decouple configuration artifacts and secrets from image content to keep containerized applications portable. Using ConfigMap, you can independently control MySQL configuration.

Create the mysql Namespace

We will create a new Namespace called mysql that will host all the components.

kubectl create namespace mysql

Create ConfigMap

Run the following commands to download the ConfigMap.

cd ${HOME}/environment/ebs_statefulset

cat << EoF > ${HOME}/environment/ebs_statefulset/mysql-configmap.yaml
apiVersion: v1
kind: ConfigMap
  name: mysql-config
  namespace: mysql
    app: mysql
  master.cnf: |
    # Apply this config only on the leader.
  slave.cnf: |
    # Apply this config only on followers.

The ConfigMap stores master.cnf, slave.cnf and passes them when initializing leader and follower pods defined in StatefulSet:

  • master.cnf is for the MySQL leader pod which has binary log option (log-bin) to provides a record of the data changes to be sent to follower servers.
  • slave.cnf is for follower pods which have super-read-only option.

Create “mysql-config” ConfigMap.

kubectl create -f ${HOME}/environment/ebs_statefulset/mysql-configmap.yaml