Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failure to create a job in kubernetes due to error

Tags:

kubernetes

When creating a Job in kubernetes 1.6, the following error occurs:

Error from server (BadRequest): error when creating "job.yaml": 
Job in version "v1" cannot be handled as a Job: [pos 217]: 
json: expect char '"' but got char '1'

The job.yaml in question is:

apiVersion: batch/v1
kind: Job
metadata:
  name: sysbench-oltp
spec:
  template:
    metadata:
      name: sysbench-oltp
    spec:
      containers:
      - name: sysbench-oltp
        image: sysbench-oltp:1.0
        env:
        - name: OLTP_TABLE_SIZE
          value: 10000
        - name: DB_NAME
          value: "test"
        - name: DB_USER
          value: "test_user"

Any variations on the API do not seem to matter at all. Anybody have any idea of what the problem is?

like image 430
Norbert van Nobelen Avatar asked Apr 21 '17 17:04

Norbert van Nobelen


People also ask

How do you fail a Kubernetes job?

A Kubernetes job is just a contrainer running. As with any container, the final exit code determines if the run was successful or not. So, to make your job fail you need to exit with a code other than 0.

How do I resolve Imagepullbackoff in Kubernetes?

To resolve it, double check the pod specification and ensure that the repository and image are specified correctly. If this still doesn't work, there may be a network issue preventing access to the container registry. Look in the describe pod text file to obtain the hostname of the Kubernetes node.


1 Answers

Found the solution:

The JSON parser returns a rather unrelated error on a piece of the data in the environment variables:

   env:
    - name: OLTP_TABLE_SIZE
      value: 10000

Should read:

   env:
    - name: OLTP_TABLE_SIZE
      value: "10000"

After which all the parsing works as it should.

like image 194
Norbert van Nobelen Avatar answered Nov 15 '22 10:11

Norbert van Nobelen