kubernetes-jobs

How to obtain Ip address of a kubernetes pod by querying DNS srv records?

ぃ、小莉子 提交于 2021-02-08 08:46:19
问题 I am trying to create a kubernetes job inside which I will run "dig srv" queries to find out the IP address of all the pods for any specific service running on the same cluster. Is this achievable ? I would like to elaborate a little more on the problem statement. There are a few services already running on the cluster. The requirement is to have a tool that can accept a service name and list down the IP addresses of all the pods belonging to that service. I was able to do this by using

Pods stuck in PodInitializing state indefinitely

扶醉桌前 提交于 2020-01-16 00:45:29
问题 I've got a k8s cronjob that consists of an init container and a one pod container. If the init container fails, the Pod in the main container never gets started, and stays in "PodInitializing" indefinitely. My intent is for the job to fail if the init container fails. --- apiVersion: batch/v1beta1 kind: CronJob metadata: name: job-name namespace: default labels: run: job-name spec: schedule: "15 23 * * *" startingDeadlineSeconds: 60 concurrencyPolicy: "Forbid" successfulJobsHistoryLimit: 30

Wait for kubernetes job to complete on either failure/success using command line

岁酱吖の 提交于 2020-01-01 08:52:50
问题 What is the best way to wait for kubernetes job to be complete? I noticed a lot of suggestions to use: kubectl wait --for=condition=complete job/myjob but i think that only works if the job is successful. if it fails, i have to do something like: kubectl wait --for=condition=failure job/myjob is there a way to wait for both conditions using wait? if not, what is the best way to wait for a job to either succeed or fail? 回答1: kubectl wait --for=condition=<condition name is waiting for a

Kubernetes - how to run job only once

二次信任 提交于 2019-12-18 14:48:11
问题 I have a job definition based on example from kubernetes website. apiVersion: batch/v1 kind: Job metadata: name: pi-with-timeout-6 spec: activeDeadlineSeconds: 30 completions: 1 paralleism: 1 template: metadata: name: pi spec: containers: - name: pi image: perl command: ["exit", "1"] restartPolicy: Never I would like run this job once and not restart if fails. With comand exit 1 kubernetes trying to run new pod to get exit 0 code until reach activeDeadlineSeconds timeout. How can avoid that?

How to run containers sequentially as a Kubernetes job?

馋奶兔 提交于 2019-12-17 18:07:52
问题 I'm trying to replace my legacy job scheduler with Kubernetes job and wondering how to write sequential jobs as a Kubernetes job. First, I wrote the following script to execute job1 and job2 in the written order but it didn't work as I expected. apiVersion: batch/v1 kind: Job metadata: name: sequential spec: activeDeadlineSeconds: 100 template: metadata: name: sequential_jobs spec: containers: - name: job1 image: image1 - name: job2 image: image2 restartPolicy: Never The job described above

kubectl list / delete all completed jobs

依然范特西╮ 提交于 2019-12-11 02:56:37
问题 I'm looking for a kubectl command to list / delete all completed jobs I've try: kubectl get job --field-selector status.succeeded=1 But I get: enfield selector "status.succeeded=1": field label "status.succeeded" not supported for batchv1.Jobter code here What are the possible fields for --fieldSelector when getting jobs ? Is there a better way to do this ? 回答1: What you can do to list all the succeeded jobs is first get all the jobs and then filter the output: kubectl get job --all

How to automatically remove completed Kubernetes Jobs created by a CronJob?

一曲冷凌霜 提交于 2019-12-03 08:06:19
问题 Is there a way to automatically remove completed Jobs besides making a CronJob to clean up completed Jobs? The K8s Job Documentation states that the intended behavior of completed Jobs is for them to remain in a completed state until manually deleted. Because I am running thousands of Jobs a day via CronJobs and I don't want to keep completed Jobs around. 回答1: You can now set history limits, or disable history altogether, so that failed or successful jobs are not kept around indefinitely. See