Adding Mariadb shutdown command to POD delete event

This PS adds mysqladmin shutdown command to gracefully shutdown Mariadb.
POD's lifecycle PreStop hook is used for this purpose. It also switches
to PetSet for mariadb pod.

Partially-implements: blueprint deployments
Partially-implements: blueprint api-termination

Change-Id: I582b35fe2cfd28ee23fbd9012d9420083291feb3
This commit is contained in:
Serguei Bezverkhi 2016-08-13 12:16:10 -04:00
parent 5800b04729
commit 257d68ee6b
1 changed files with 15 additions and 4 deletions

View File

@ -1,18 +1,24 @@
{%- set resourceName = kolla_kubernetes.cli.args.service_name %}
apiVersion: v1
kind: ReplicationController
apiVersion: apps/v1alpha1
kind: PetSet
spec:
serviceName: "mariadb"
replicas: 1
selector:
service: mariadb
template:
metadata:
labels:
service: mariadb
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 120
containers:
- image: "{{ mariadb_image_full }}"
name: mariadb
lifecycle:
preStop:
exec:
command: ["mysqladmin -u {{ database_user }} -p$DATABASE_PASSWORD shutdown"]
volumeMounts:
- mountPath: {{ container_config_directory }}
name: mariadb-config
@ -25,6 +31,11 @@ spec:
value: ""
- name: KOLLA_CONFIG_STRATEGY
value: {{ config_strategy }}
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: database-password
key: password
ports:
- containerPort: {{ mariadb_port }}
name: mariadb