Does fargate charge for complete jobs scheduled by cronjob after associated pod is terminated?

0

I deployed a cronjob in fargate eks cluster. The cronjob keeps 10 successful jobs and 2 failed jobs. Any pod created from a scheduled job is immediately terminated after the job completes. Unlike my expectation, I was told I'll be still charged for the job until all resources for the job is cleaned up because Fargate keeps a spot instance to a job even though it completed. So, I have to set ttlSecondsAfterFinished to get all resource are cleaned up. Problem I have is due to short ttl, I can't tell whether my previous job succeeded or failed after set ttl time. Is this true?

junwoo
asked 2 months ago157 views
2 Answers
1

Hello,

With Kubernetes Jobs, when a Job completes, no more Pods are created, but the Pods are usually not deleted either. Keeping them around allows you to still view the logs of completed pods to check for errors, warnings, or other diagnostic output.

In EKS/Fargate the lifecyle of the Fargate node and costs are tied to the pod. As long as the pod is not removed the fargate node supporting it will be there. Given the pod is not deleted you are charged for it.

There are some tools in the Kubernetes ecosystem that can help with job cleanup. Some examples are below.

https://github.com/lwolf/kube-cleanup-operator

https://github.com/aramse/k8s-job-reaper

A fargate logging configuration should be leveraged to send the logs to a centralized location like Cloudwatch or OpenSearch before the pod is removed.

Hope that helps.

AWS
Ryan_S
answered 2 months ago
  • Thanks for the answer! Could you confirm if "kubeutil get pods" no longer lists created pods from a job confirm the pods are all deleted? In other words, is there a way I can confirm all pods are deleted after a job completed.

0

Kubectl get pods will show the pods associated with the job. Here's an example

kubectl get pods --selector=batch.kubernetes.io/job-name=examplejob

The documentation below outlines this.

https://kubernetes.io/docs/concepts/workloads/controllers/job/#running-an-example-job

AWS
Ryan_S
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions