#
# Copyright 2021 JSquad AB
#
# 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: flyway-pod
  labels:
    name: flyway
    zone: prod
    version: v1
spec:
  containers:
    - name: flyway
      image: flyway/flyway:6.0.6
      command: [ "/bin/sh", "-c", "/flyway/flyway -url=jdbc:postgresql://securitydb:5432/security -schemas=public -user=security_user -password=${SECURITY_PASSWORD} -connectRetries=60 migrate" ]
      volumeMounts:
        - name: ddl
          mountPath: /flyway/sql
          readOnly: true
      env:
        - name: SECURITY_PASSWORD
          valueFrom:
            secretKeyRef:
              name: openbank-spring-secret
              key: SECURITY_PASSWORD
  restartPolicy: Never
  volumes:
    - name: ddl
      configMap:
        name: flyway-ddl-volume