Set a Pod as owner reference for another pod in client go program

12/10/2019

Is it possible to set a running pod as owner of another pod which is to be created. I tired but in that case pod creation fails.

-- PREETI BANSAL
kubernetes
kubernetes-pod

2 Answers

12/10/2019

I think you can use Kubernetes Jobs.

A Job creates one or more Pods and ensures that 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.

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).

More information you can find here: jobs-kubernetes.

-- MaggieO
Source: StackOverflow

12/10/2019

This is not directly supported by Kubernetes. When you have a Pod that depends on the existence of another one (e.g. needs a Database or similar), you could use a Init Container. This will delay the container start until the init container finishes. This is a good way to apply e.g. waiting conditions.

-- Alex
Source: StackOverflow