114 lines
3.0 KiB
YAML
114 lines
3.0 KiB
YAML
---
|
|
# tasks file for deploy-mariadb.yml
|
|
- name: Create a ConfigMap for database schema
|
|
k8s:
|
|
state: present
|
|
api_version: v1
|
|
kind: ConfigMap
|
|
name: cm-mariadb-eom-dev-production
|
|
namespace: production
|
|
definition:
|
|
data:
|
|
schema.sql: "{{ lookup('template', 'schema.sql.j2') }}"
|
|
|
|
- name: Create persistent volume for mariadb
|
|
k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: pv-mariadb-eom-dev-production
|
|
spec:
|
|
capacity:
|
|
storage: "{{ mariadb_production_storage }}"
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
persistentVolumeReclaimPolicy: Retain
|
|
storageClassName: standard
|
|
hostPath:
|
|
path: /data/store-0/pv-mariadb-eom-dev-production
|
|
nodeAffinity:
|
|
required:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: kubernetes.io/hostname
|
|
operator: In
|
|
values:
|
|
- alpha-worker-0
|
|
|
|
- name: Create persistent volume claim for mariadb
|
|
k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: pvc-mariadb-eom-dev-production
|
|
namespace: production
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: "{{ mariadb_production_storage }}"
|
|
storageClassName: standard
|
|
volumeName: pv-mariadb-eom-dev-production
|
|
|
|
- name: Create a deployment
|
|
k8s:
|
|
definition:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: deployment-mariadb-eom-dev-production
|
|
namespace: production
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: eom.dev
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: eom.dev
|
|
spec:
|
|
containers:
|
|
- name: mariadb
|
|
image: mariadb
|
|
volumeMounts:
|
|
- name: pv-mariadb-eom-dev-production
|
|
mountPath: /var/lib/mysql
|
|
- name: schema-sql
|
|
mountPath: /docker-entrypoint-initdb.d
|
|
ports:
|
|
- containerPort: 8086
|
|
env:
|
|
- name: MARIADB_ROOT_PASSWORD
|
|
value: "{{ mariadb_root_password }}"
|
|
volumes:
|
|
- name: schema-sql
|
|
configMap:
|
|
name: cm-mariadb-eom-dev-production
|
|
- name: pv-mariadb-eom-dev-production
|
|
persistentVolumeClaim:
|
|
claimName: pvc-mariadb-eom-dev-production
|
|
|
|
- name: Expose deployment as a service
|
|
k8s:
|
|
definition:
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: service-mariadb-eom-dev-production
|
|
namespace: production
|
|
spec:
|
|
selector:
|
|
app: eom.dev
|
|
ports:
|
|
- port: 3306
|
|
targetPort: 8086
|
|
protocol: TCP
|
|
name: mariadb-port-8086
|
|
type: ClusterIP
|