1
0
mirror of https://github.com/jcwimer/startup-infrastructure synced 2026-05-20 19:57:43 +00:00

Switched from docker swarm to Kubernetes with rke

This commit is contained in:
2020-05-11 19:39:13 -04:00
parent 01f384ac14
commit 1e5724ec1d
30 changed files with 458 additions and 488 deletions

View File

@@ -0,0 +1,4 @@
---
mysql_root_password: password
mysql_replicas: 3
mysql_cluster_name: mysql-cluster

View File

@@ -0,0 +1,45 @@
---
- name: Create Mysql Directory
file:
path: "{{ startup_infrastructure_directory }}/presslabs-mysql-operator"
state: directory
- name: Add presslabs helm repo
command: helm repo add presslabs https://presslabs.github.io/charts
- name: Install the presslabs mysql operator
command: helm install presslabs/mysql-operator --name presslabs-mysql-operator
- name: Wait for mysql-operator to be Running
command: >
bash -c "kubectl get pods --all-namespaces | grep presslabs-mysql-operator | grep Running"
retries: 10
delay: 30
register: mysql_operator_init
until: mysql_operator_init.rc == 0
- name: Put mysql cluster yaml in place
template:
src: presslabs-mysql-cluster.yaml.j2
dest: "{{ startup_infrastructure_directory }}/presslabs-mysql-operator/presslabs-mysql-cluster.yaml"
- name: Deploy mysql cluster
command: >
kubectl apply -f {{ startup_infrastructure_directory }}/presslabs-mysql-operator/presslabs-mysql-cluster.yaml
- name: Wait for cluster to be Running
command: >
bash -c "kubectl get mysql | grep {{ mysql_cluster_name }} | grep True"
retries: 10
delay: 60
register: mysql_cluster_init
until: mysql_cluster_init.rc == 0
- name: Test a query on the cluster
command: >
kubectl run mysql-client --image=mysql:5.7 -it --rm --restart=Never \
-- mysql -h {{ mysql_cluster_name }}-mysql -u root -p{{ mysql_root_password }} -e "show databases; show slave status;"
retries: 10
delay: 20
register: mysql_cluster_query
until: mysql_cluster_query.rc == 0

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ mysql_cluster_name }}-secret
type: Opaque
# use data if password is base64 encoded
#data:
# ROOT_PASSWORD: {{ mysql_root_password }}
stringData:
ROOT_PASSWORD: {{ mysql_root_password }}
---
apiVersion: mysql.presslabs.org/v1alpha1
kind: MysqlCluster
metadata:
name: {{ mysql_cluster_name }}
spec:
replicas: {{ mysql_replicas }}
secretName: {{ mysql_cluster_name }}-secret