I'm currently working on project which is using Kubernetes pods to deploy applications on local machine. To avoid traffic on the Development server DB, I am migrating that process on local development environment. For this I am using Liquibase to allow DB changelogs to automatically apply once the kube pods are initialized.
I already have a mssql pod running on my cluster which consists of the target Database I want to update.
This is my docker file which contains the liquibase image, the credentials are same as my mssql pod.
FROM liquibase/liquibase
ENV URL=jdbc:sqlserver://localhost:1433;database=PlayerDB
ENV USERNAME=sa
ENV PASSWORD=pl@y123
ENV CHANGELOGFILE=changelog.xml
CMD ["sh", "-c", "docker-entrypoint.sh --url=${URL} --username=${USERNAME} --password=${PASSWORD} --classpath=/liquibase/changelog --changeLogFile=${CHANGELOGFILE} update"]
This is my changelog file which contains the sql statements I want to trigger on my DB inside mssql pod
change-map.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: player-changelog-v1
data:
changelog.sql: |-
--liquibase formatted sql
--changeset play:1
--Database: PlayerDB
CREATE TABLE test_table (test_id INT, test_column VARCHAR, PRIMARY KEY (test_id));
Finally I have created a job which intends to update the Database by creating the new table
apiVersion: batch/v1
kind: Job
metadata:
name: liquibase-job-v1
spec:
template:
spec:
containers:
- name: liquibase
image: play/liquibase
env:
- name: URL
value: jdbc:sqlserver://localhost:1433;database=PlayerDB
- name: USERNAME
value: sa
- name: PASSWORD
value: pl@y123
- name: CHANGELOGFILE
value: changelog.sql
volumeMounts:
- name: config-vol
mountPath: /liquibase/changelog
restartPolicy: Never
volumes:
- name: config-vol
configMap:
name: player-changelog-v1
The pod runs and then terminates on it's own but the table is not getting created.
If you logs are giving out the Starting Liquibase Liquibase Community 3.8.0 by Datical Errors: The option --url is required. The option --changeLogFile is required.
then why don't you define parameters in the commands as well? They are mandatory Liquibase parameters to run the liquibase updates