From 257d68ee6b1db97588e2c7a648cfebf6fea44341 Mon Sep 17 00:00:00 2001 From: Serguei Bezverkhi Date: Sat, 13 Aug 2016 12:16:10 -0400 Subject: [PATCH] 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 --- services/mariadb/mariadb-pod.yml.j2 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/services/mariadb/mariadb-pod.yml.j2 b/services/mariadb/mariadb-pod.yml.j2 index ceae5bca1..7653501b8 100644 --- a/services/mariadb/mariadb-pod.yml.j2 +++ b/services/mariadb/mariadb-pod.yml.j2 @@ -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