# Copyright (c) 2017 SUSE LLC. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: Pod
metadata:
  name: velum-private
  labels:
    name: velum-private
spec:
  hostNetwork: False
  initContainers:
  - name: mariadb-secrets
    image: sles12/velum:__TAG__
    command: ["sh", "-c", "umask 377;
                           if [ ! -f /infra-secrets/mariadb-root-password ]; then
                             head -n 10 /dev/random | base64 | head -n 10 | tail -n 1 > /infra-secrets/mariadb-root-password;
                           fi;
                           exit 0"]
    volumeMounts:
    - mountPath: /infra-secrets
      name: infra-secrets
  containers:
  - name: velum-mariadb
    image: sles12/mariadb:__TAG__
    env:
    - name: MYSQL_DISABLE_REMOTE_ROOT
      value: "true"
    - name: MYSQL_ROOT_PASSWORD_FILE
      value: /var/lib/misc/infra-secrets/mariadb-root-password
    - name: MYSQLD_CONFIG
      value: "skip-networking;max_allowed_packet=16M;innodb_log_file_size=128M"
    volumeMounts:
    - mountPath: /var/lib/mysql
      name: mariadb-data
    - mountPath: /var/run/mysql
      name: mariadb-unix-socket
    - mountPath: /var/lib/misc/infra-secrets
      name: infra-secrets
      readOnly: True
  volumes:
  - name: mariadb-data
    hostPath:
      path: /var/lib/mysql
  - name: mariadb-unix-socket
    hostPath:
      path: /var/run/mysql
  - name: infra-secrets
    hostPath:
      path: /var/lib/misc/infra-secrets
