I am trying to create a k8s job with the below yaml,
apiVersion: batch/v1
kind: Job
metadata:
name: mysql-with-ttl
spec:
ttlSecondsAfterFinished: 100
template:
spec:
containers:
- name: mysql
image: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: "test1234"
command: ["/bin/sh","-c"]
args: ["mysql --defaults-extra-file=/home/mysql-config/mysql-config --host yyy.mysql.database.azure.com -e"create database test; show databases" && mysql --defaults-extra-file=/home/mysql-config/mysql-config --host yyy.mysql.database.azure.com test < /home/schema/test-schema.sql"]
volumeMounts:
- name: mysql-config-vol
mountPath: /home/mysql-config
- name: schema-config-vol
mountPath: /home/schema
volumes:
- name: mysql-config-vol
configMap:
name: mysql-config
- name: schema-config-vol
configMap:
name: test-schema
restartPolicy: Never
Some issue with the args given above, so I am getting the below error:
error: error parsing k8s-job.yaml: error converting YAML to JSON: yaml: line 15: did not find expected ',' or ']'
I have to pass the commands in args to 1) login to mysql server 2) create database called "test" 3) import the sql schema to the created database in mysql. But, there's an error with the syntax and I am unable to figure out where exactly the issue is.
Can anyone please help me to fix this? Thanks in Advance!