StatefulSet: Use ControllerRef to route watch events.

This is part of the completion of ControllerRef, as described here:

https://github.com/kubernetes/community/blob/master/contributors/design-proposals/controller-ref.md#watches
This commit is contained in:
Anthony Yeh
2017-02-24 12:56:10 -08:00
parent e4f67c8170
commit ea85a201c7
4 changed files with 248 additions and 111 deletions

View File

@@ -22,7 +22,6 @@ import (
"strconv"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api/v1"
podapi "k8s.io/kubernetes/pkg/api/v1/pod"
apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
@@ -232,16 +231,12 @@ func isHealthy(pod *v1.Pod) bool {
return isRunningAndReady(pod) && !isTerminated(pod)
}
func getSSKind() schema.GroupVersionKind {
return apps.SchemeGroupVersion.WithKind("StatefulSet")
}
// newControllerRef returns an ControllerRef pointing to a given StatefulSet.
func newControllerRef(set *apps.StatefulSet) *metav1.OwnerReference {
isController := true
return &metav1.OwnerReference{
APIVersion: apps.SchemeGroupVersion.String(),
Kind: "StatefulSet",
APIVersion: controllerKind.GroupVersion().String(),
Kind: controllerKind.Kind,
Name: set.Name,
UID: set.UID,
Controller: &isController,