Skip to content

Commit

Permalink
add owner references pod option (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
kale-amruta authored Jan 4, 2022
1 parent 24689ac commit c7ad60e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/kube/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type PodOptions struct {
PodOverride crv1alpha1.JSONMap
Resources v1.ResourceRequirements
RestartPolicy v1.RestartPolicy
OwnerReferences []metav1.OwnerReference
}

// CreatePod creates a pod with a single container based on the specified image
Expand Down Expand Up @@ -138,6 +139,11 @@ func CreatePod(ctx context.Context, cli kubernetes.Interface, opts *PodOptions)
if pod.ObjectMeta.Labels == nil {
pod.ObjectMeta.Labels = map[string]string{}
}

if opts.OwnerReferences != nil {
pod.SetOwnerReferences(opts.OwnerReferences)
}

for key, value := range opts.Labels {
pod.ObjectMeta.Labels[key] = value
}
Expand Down

0 comments on commit c7ad60e

Please sign in to comment.