0

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!

Soundarya
  • 153
  • 1
  • 2
  • 12

1 Answers1

0

Figured out the way, the following args is working. Please refer if needed,

args: ["mysql --defaults-extra-file=/home/mysql-config/mysql-config --host yyy.mysql.database.azure.com -e 'create database obortech_qa; ' && mysql --defaults-extra-file=/home/mysql-config/mysql-config --host yyy.mysql.database.azure.com obortech_qa < /home/schema/test-schema.sql"]
Soundarya
  • 153
  • 1
  • 2
  • 12