I am trying to create a job from pod in minikube. Below is my job.yaml
. I am using client-java-11.0.0
API. When I run the application from IDE, it creates the job. I load the file using Yaml.load(file)
apiVersion: batch/v1
kind: Job
metadata:
name: mansoor-hello-world-job
spec:
template:
spec:
containers:
- name: mansoor-hello-world-job-image
image: job/mansoor-hello-world-job
imagePullPolicy: Never
ports:
- containerPort: 8080
# command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
Now this application I am running in a container. When I do Yaml.load(file)
I get below error Unknown apiVersionKind batch/v1/Job is it registered?
. Any idea?
Below is my deployment.yaml for the app
apiVersion: apps/v1
kind: Deployment
metadata:
name: job-runner-pod
spec:
selector:
matchLabels:
app: job-runner-pod-app
template:
metadata:
labels:
app: job-runner-pod-app
spec:
containers:
- name: job-runner-pod
image: pods/job-runner-pod
imagePullPolicy: Never
ports:
- containerPort: 8080
# command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
2
Answers
When I try to craete docker image, the jar had issues. I was able to fix the issue like below:
And in
Dockerfile
used command likeCMD ["java","-Dloader.path=/app/lib","-jar","/app/app.jar"]
Dockerfile
Somehow, your
Job
object is not being correctly "detected" asJob
kind by the client library. According to this issue on the GitHub issue board of thejava-client
, you can specify the model of the object before loading it as a file.Afterwards, when you load your YAML, it will be interpreted appropriately.