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
질문됨 2달 전167회 조회
2개 답변
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
답변함 2달 전
  • 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
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠