rook: add owner reference to the discover daemon

Attach owner reference to the discover daemon set so that when the
opetator goes away, the discover pod gets removed too.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2019-12-12 11:07:18 +01:00
1 parent 8a5aec0df0
commit 90b4e74457
1 file changed
+11 -1
+11 -1
View File
@@ -25,6 +25,8 @@ import (
"strings"
"time"
"github.com/pkg/errors"
"github.com/coreos/pkg/capnslog"
rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2"
"github.com/rook/rook/pkg/clusterd"
@@ -85,9 +87,17 @@ func (d *Discover) createDiscoverDaemonSet(namespace, discoverImage, securityAcc
discovery_parameters = append(discovery_parameters, "--use-ceph-volume")
}
// Get the operator pod details
// So that we can attach the owner reference to the discover daemon set
operatorPod, err := k8sutil.GetRunningPod(d.clientset)
if err != nil {
return errors.Wrapf(err, "failed to get operator pod")
}
ds := &apps.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: discoverDaemonsetName,
Name: discoverDaemonsetName,
OwnerReferences: operatorPod.OwnerReferences,
},
Spec: apps.DaemonSetSpec{
Selector: &metav1.LabelSelector{