0

I'm running a spring boot task inside a k8s pod. This is the k8s specification:

kind: CronJob
metadata:
  name: data-transmission
spec:
  schedule: "*/2 * * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: print-date
              image: fredde:latest
              imagePullPolicy: IfNotPresent
              livenessProbe:
                httpGet:
                  path: /actuator/health/liveness
                  port: 8080
                initialDelaySeconds: 2
                failureThreshold: 2
              readinessProbe: null
          restartPolicy: OnFailure

The pod starts as it should each 2 min. The task in the spring boot application is running and shutting down itself when it's done. But my issue is that the pod is still running even when the spring boot application has exited but it changes status to NotReady, i was expecting it to be complete or terminated.

user2354898
  • 253
  • 2
  • 15

2 Answers2

0

A Job creates one or more Pods and will continue to retry execution of the Pods until a specified number of them successfully terminate. As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created. Suspending a Job will delete its active Pods until the Job is resumed again. A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example due to a node hardware failure or a node reboot). (Source: Kubernetes)

In general jobs won’t get deleted from API as soon as they are successfully completed, they are kept for some time in order to have the information on whether a job is successful or not. Kubernetes' TTL-after-finished controller will take care of this, you can set an expiration time for jobs for deleting them from the API.

Note: This is taken from the official kubernetes documentation, go through the links for the exact point of reference.

0

I found a solution that works.

It seems like when my spring application is done and shutting down itself the k8s pod is still up and running because of istio.

There is an open pull request: https://github.com/istio/istio/issues/11659

user2354898
  • 253
  • 2
  • 15