e3dde656b0
Change-Id: If39440356ba8b4bcc01f4a44f82b7609922a2274
171 lines
4.3 KiB
YAML
171 lines
4.3 KiB
YAML
- name: Create mariadb configmaps
|
|
ignore_errors: yes
|
|
k8s_v1_config_map:
|
|
host: "{{coe_host}}"
|
|
context: "{{coe_config_context}}"
|
|
kubeconfig: "{{coe_config_file}}"
|
|
name: mariadb
|
|
namespace: "{{namespace}}"
|
|
state: present
|
|
debug: yes
|
|
labels:
|
|
service: mariadb
|
|
data:
|
|
kolla-config: |
|
|
{
|
|
"command": "/usr/bin/mysqld_safe",
|
|
"config_files": []
|
|
}
|
|
server-cnf: |
|
|
[mysqld]
|
|
pid-file=/var/lib/mysql/mariadb.pid
|
|
|
|
- include: hiera.yml
|
|
|
|
- name: Create mariadb service
|
|
k8s_v1_service:
|
|
host: "{{coe_host}}"
|
|
context: "{{coe_config_context}}"
|
|
kubeconfig: "{{coe_config_file}}"
|
|
name: mariadb
|
|
namespace: "{{namespace}}"
|
|
state: present
|
|
ports:
|
|
- port: 3306
|
|
name: db
|
|
selector:
|
|
app: mariadb
|
|
labels:
|
|
app: mariadb
|
|
debug: yes
|
|
annotations:
|
|
service.alpha.kubernetes.io/tolerate-unready-endpoints: "false"
|
|
register: create_service
|
|
|
|
- name: Create mariadb deployment
|
|
k8s_v1beta1_stateful_set:
|
|
host: "{{coe_host}}"
|
|
context: "{{coe_config_context}}"
|
|
kubeconfig: "{{coe_config_file}}"
|
|
name: mariadb
|
|
namespace: "{{namespace}}"
|
|
state: present
|
|
debug: yes
|
|
spec_service_name: mariadb
|
|
spec_template_metadata_name: mariadb
|
|
spec_template_metadata_labels:
|
|
app: mariadb
|
|
galera: enabled
|
|
spec_template_spec_init_containers:
|
|
- name: bootstrap
|
|
image: tripleoupstream/centos-binary-mariadb
|
|
env:
|
|
- name: KOLLA_KUBERNETES
|
|
value: ""
|
|
- name: KOLLA_BOOTSTRAP
|
|
value: ""
|
|
- name: KOLLA_CONFIG_STRATEGY
|
|
value: "COPY_ALWAYS"
|
|
- name: DB_ROOT_PASSWORD
|
|
value: "{{mariadb_config.root_password}}"
|
|
volumeMounts:
|
|
- name: kolla-config
|
|
mountPath: /var/lib/kolla/config_files/
|
|
- name: mariadb-config
|
|
mountPath: /etc/my.cnf.d
|
|
- name: mariadb-pvc
|
|
mountPath: /var/lib/mysql
|
|
volumes:
|
|
- name: mariadb-pvc
|
|
- name: kolla-config
|
|
config_map:
|
|
name: mariadb
|
|
items:
|
|
- key: kolla-config
|
|
path: config.json
|
|
- name: mariadb-config
|
|
config_map:
|
|
name: mariadb
|
|
items:
|
|
- key: server-cnf
|
|
path: server.cnf
|
|
|
|
containers:
|
|
- name: mariadb
|
|
image: tripleoupstream/centos-binary-mariadb
|
|
ports:
|
|
- container_port: 3306
|
|
- container_port: 4567
|
|
- container_port: 4444
|
|
env:
|
|
- name: KOLLA_CONFIG_STRATEGY
|
|
value: COPY_ALWAYS
|
|
- name: KOLLA_KUBERNETES
|
|
value: ""
|
|
- name: DB_ROOT_PASSWORD
|
|
value: '{{mariadb_config.root_password}}'
|
|
volume_mounts:
|
|
- name: kolla-config
|
|
mountPath: /var/lib/kolla/config_files/
|
|
- name: mariadb-config
|
|
mountPath: /etc/my.cnf.d
|
|
- name: mariadb-pvc
|
|
mountPath: /var/lib/mysql
|
|
replicas: 1
|
|
volumes:
|
|
- name: mariadb-pvc
|
|
- name: kolla-config
|
|
config_map:
|
|
name: mariadb
|
|
items:
|
|
- key: kolla-config
|
|
path: config.json
|
|
- name: mariadb-config
|
|
config_map:
|
|
name: mariadb
|
|
items:
|
|
- key: server-cnf
|
|
path: server.cnf
|
|
|
|
register: create_deployment
|
|
tags:
|
|
- statefulset
|
|
|
|
- set_fact:
|
|
my_cnf: |
|
|
[mysql]
|
|
user=root
|
|
host={{mariadb_config.host}}
|
|
password='{{mariadb_config.root_password}}'
|
|
|
|
[client]
|
|
user=root
|
|
host={{mariadb_config.host}}
|
|
password='{{mariadb_config.root_password}}'
|
|
|
|
[mysqldump]
|
|
user=root
|
|
host={{mariadb_config.host}}
|
|
password='{{mariadb_config.root_password}}'
|
|
|
|
[mysqladmin]
|
|
user=root
|
|
host={{mariadb_config.host}}
|
|
password='{{mariadb_config.root_password}}'
|
|
|
|
[mysqlcheck]
|
|
user=root
|
|
host={{mariadb_config.host}}
|
|
password='{{mariadb_config.root_password}}'
|
|
|
|
- name: Create mariadb root secret
|
|
k8s_v1_secret:
|
|
host: "{{coe_host}}"
|
|
context: "{{coe_config_context}}"
|
|
kubeconfig: "{{coe_config_file}}"
|
|
name: mariadb-root
|
|
namespace: "{{namespace}}"
|
|
state: present
|
|
data:
|
|
my.cnf: "{{ my_cnf | b64encode }}"
|