mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
federation
This commit is contained in:
parent
bb675d395f
commit
eca157588d
@ -143,7 +143,7 @@ func Run(s *options.ServerRunOptions) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to create clientset: %v", err)
|
glog.Errorf("Failed to create clientset: %v", err)
|
||||||
}
|
}
|
||||||
sharedInformers := informers.NewSharedInformerFactory(client, 10*time.Minute)
|
sharedInformers := informers.NewSharedInformerFactory(nil, client, 10*time.Minute)
|
||||||
|
|
||||||
authorizationConfig := authorizer.AuthorizationConfig{
|
authorizationConfig := authorizer.AuthorizationConfig{
|
||||||
PolicyFile: s.GenericServerRunOptions.AuthorizationPolicyFile,
|
PolicyFile: s.GenericServerRunOptions.AuthorizationPolicyFile,
|
||||||
|
@ -24,8 +24,6 @@ import (
|
|||||||
federation_v1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
federation_v1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||||
cluster_cache "k8s.io/kubernetes/federation/client/cache"
|
cluster_cache "k8s.io/kubernetes/federation/client/cache"
|
||||||
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
|
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
|
||||||
"k8s.io/kubernetes/federation/pkg/federation-controller/util"
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
|
||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/cache"
|
"k8s.io/kubernetes/pkg/client/cache"
|
||||||
"k8s.io/kubernetes/pkg/controller"
|
"k8s.io/kubernetes/pkg/controller"
|
||||||
@ -66,13 +64,11 @@ func NewclusterController(federationClient federationclientset.Interface, cluste
|
|||||||
}
|
}
|
||||||
cc.clusterStore.Store, cc.clusterController = cache.NewInformer(
|
cc.clusterStore.Store, cc.clusterController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return cc.federationClient.Federation().Clusters().List(options)
|
||||||
return cc.federationClient.Federation().Clusters().List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return cc.federationClient.Federation().Clusters().Watch(options)
|
||||||
return cc.federationClient.Federation().Clusters().Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&federation_v1beta1.Cluster{},
|
&federation_v1beta1.Cluster{},
|
||||||
|
@ -79,7 +79,7 @@ type ConfigMapController struct {
|
|||||||
func NewConfigMapController(client federationclientset.Interface) *ConfigMapController {
|
func NewConfigMapController(client federationclientset.Interface) *ConfigMapController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-configmaps-controller"})
|
recorder := broadcaster.NewRecorder(api_v1.EventSource{Component: "federated-configmaps-controller"})
|
||||||
|
|
||||||
configmapcontroller := &ConfigMapController{
|
configmapcontroller := &ConfigMapController{
|
||||||
federatedApiClient: client,
|
federatedApiClient: client,
|
||||||
@ -98,13 +98,11 @@ func NewConfigMapController(client federationclientset.Interface) *ConfigMapCont
|
|||||||
// Start informer on federated API servers on configmaps that should be federated.
|
// Start informer on federated API servers on configmaps that should be federated.
|
||||||
configmapcontroller.configmapInformerStore, configmapcontroller.configmapInformerController = cache.NewInformer(
|
configmapcontroller.configmapInformerStore, configmapcontroller.configmapInformerController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Core().ConfigMaps(api_v1.NamespaceAll).List(options)
|
||||||
return client.Core().ConfigMaps(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Core().ConfigMaps(api_v1.NamespaceAll).Watch(options)
|
||||||
return client.Core().ConfigMaps(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.ConfigMap{},
|
&api_v1.ConfigMap{},
|
||||||
@ -117,13 +115,11 @@ func NewConfigMapController(client federationclientset.Interface) *ConfigMapCont
|
|||||||
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().ConfigMaps(api_v1.NamespaceAll).List(options)
|
||||||
return targetClient.Core().ConfigMaps(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().ConfigMaps(api_v1.NamespaceAll).Watch(options)
|
||||||
return targetClient.Core().ConfigMaps(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.ConfigMap{},
|
&api_v1.ConfigMap{},
|
||||||
|
@ -87,7 +87,7 @@ type DaemonSetController struct {
|
|||||||
func NewDaemonSetController(client federationclientset.Interface) *DaemonSetController {
|
func NewDaemonSetController(client federationclientset.Interface) *DaemonSetController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-daemonset-controller"})
|
recorder := broadcaster.NewRecorder(api_v1.EventSource{Component: "federated-daemonset-controller"})
|
||||||
|
|
||||||
daemonsetcontroller := &DaemonSetController{
|
daemonsetcontroller := &DaemonSetController{
|
||||||
federatedApiClient: client,
|
federatedApiClient: client,
|
||||||
@ -106,13 +106,11 @@ func NewDaemonSetController(client federationclientset.Interface) *DaemonSetCont
|
|||||||
// Start informer in federated API servers on daemonsets that should be federated.
|
// Start informer in federated API servers on daemonsets that should be federated.
|
||||||
daemonsetcontroller.daemonsetInformerStore, daemonsetcontroller.daemonsetInformerController = cache.NewInformer(
|
daemonsetcontroller.daemonsetInformerStore, daemonsetcontroller.daemonsetInformerController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Extensions().DaemonSets(api_v1.NamespaceAll).List(options)
|
||||||
return client.Extensions().DaemonSets(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Extensions().DaemonSets(api_v1.NamespaceAll).Watch(options)
|
||||||
return client.Extensions().DaemonSets(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensionsv1.DaemonSet{},
|
&extensionsv1.DaemonSet{},
|
||||||
@ -125,13 +123,11 @@ func NewDaemonSetController(client federationclientset.Interface) *DaemonSetCont
|
|||||||
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Extensions().DaemonSets(api_v1.NamespaceAll).List(options)
|
||||||
return targetClient.Extensions().DaemonSets(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Extensions().DaemonSets(api_v1.NamespaceAll).Watch(options)
|
||||||
return targetClient.Extensions().DaemonSets(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensionsv1.DaemonSet{},
|
&extensionsv1.DaemonSet{},
|
||||||
|
@ -104,7 +104,7 @@ type DeploymentController struct {
|
|||||||
func NewDeploymentController(federationClient fedclientset.Interface) *DeploymentController {
|
func NewDeploymentController(federationClient fedclientset.Interface) *DeploymentController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(federationClient))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(federationClient))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-deployment-controller"})
|
recorder := broadcaster.NewRecorder(apiv1.EventSource{Component: "federated-deployment-controller"})
|
||||||
|
|
||||||
fdc := &DeploymentController{
|
fdc := &DeploymentController{
|
||||||
fedClient: federationClient,
|
fedClient: federationClient,
|
||||||
@ -123,13 +123,11 @@ func NewDeploymentController(federationClient fedclientset.Interface) *Deploymen
|
|||||||
deploymentFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
deploymentFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Extensions().Deployments(apiv1.NamespaceAll).List(options)
|
||||||
return clientset.Extensions().Deployments(apiv1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Extensions().Deployments(apiv1.NamespaceAll).Watch(options)
|
||||||
return clientset.Extensions().Deployments(apiv1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensionsv1.Deployment{},
|
&extensionsv1.Deployment{},
|
||||||
@ -152,13 +150,11 @@ func NewDeploymentController(federationClient fedclientset.Interface) *Deploymen
|
|||||||
podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Core().Pods(apiv1.NamespaceAll).List(options)
|
||||||
return clientset.Core().Pods(apiv1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Core().Pods(apiv1.NamespaceAll).Watch(options)
|
||||||
return clientset.Core().Pods(apiv1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&apiv1.Pod{},
|
&apiv1.Pod{},
|
||||||
@ -174,13 +170,11 @@ func NewDeploymentController(federationClient fedclientset.Interface) *Deploymen
|
|||||||
|
|
||||||
fdc.deploymentStore, fdc.deploymentController = cache.NewInformer(
|
fdc.deploymentStore, fdc.deploymentController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return fdc.fedClient.Extensions().Deployments(apiv1.NamespaceAll).List(options)
|
||||||
return fdc.fedClient.Extensions().Deployments(apiv1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return fdc.fedClient.Extensions().Deployments(apiv1.NamespaceAll).Watch(options)
|
||||||
return fdc.fedClient.Extensions().Deployments(apiv1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensionsv1.Deployment{},
|
&extensionsv1.Deployment{},
|
||||||
|
@ -108,7 +108,7 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
|
|||||||
glog.V(4).Infof("->NewIngressController V(4)")
|
glog.V(4).Infof("->NewIngressController V(4)")
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-ingress-controller"})
|
recorder := broadcaster.NewRecorder(v1.EventSource{Component: "federated-ingress-controller"})
|
||||||
ic := &IngressController{
|
ic := &IngressController{
|
||||||
federatedApiClient: client,
|
federatedApiClient: client,
|
||||||
ingressReviewDelay: time.Second * 10,
|
ingressReviewDelay: time.Second * 10,
|
||||||
@ -129,13 +129,11 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
|
|||||||
// Start informer in federated API servers on ingresses that should be federated.
|
// Start informer in federated API servers on ingresses that should be federated.
|
||||||
ic.ingressInformerStore, ic.ingressInformerController = cache.NewInformer(
|
ic.ingressInformerStore, ic.ingressInformerController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Extensions().Ingresses(api.NamespaceAll).List(options)
|
||||||
return client.Extensions().Ingresses(api.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Extensions().Ingresses(api.NamespaceAll).Watch(options)
|
||||||
return client.Extensions().Ingresses(api.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensions_v1beta1.Ingress{},
|
&extensions_v1beta1.Ingress{},
|
||||||
@ -152,13 +150,11 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
|
|||||||
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Extensions().Ingresses(api.NamespaceAll).List(options)
|
||||||
return targetClient.Extensions().Ingresses(api.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Extensions().Ingresses(api.NamespaceAll).Watch(options)
|
||||||
return targetClient.Extensions().Ingresses(api.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensions_v1beta1.Ingress{},
|
&extensions_v1beta1.Ingress{},
|
||||||
@ -187,19 +183,17 @@ func NewIngressController(client federationclientset.Interface) *IngressControll
|
|||||||
glog.V(4).Infof("Returning new informer for cluster %q", cluster.Name)
|
glog.V(4).Infof("Returning new informer for cluster %q", cluster.Name)
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
if targetClient == nil {
|
if targetClient == nil {
|
||||||
glog.Errorf("Internal error: targetClient is nil")
|
glog.Errorf("Internal error: targetClient is nil")
|
||||||
}
|
}
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().ConfigMaps(uidConfigMapNamespace).List(options) // we only want to list one by name - unfortunately Kubernetes don't have a selector for that.
|
||||||
return targetClient.Core().ConfigMaps(uidConfigMapNamespace).List(versionedOptions) // we only want to list one by name - unfortunately Kubernetes don't have a selector for that.
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
if targetClient == nil {
|
if targetClient == nil {
|
||||||
glog.Errorf("Internal error: targetClient is nil")
|
glog.Errorf("Internal error: targetClient is nil")
|
||||||
}
|
}
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().ConfigMaps(uidConfigMapNamespace).Watch(options) // as above
|
||||||
return targetClient.Core().ConfigMaps(uidConfigMapNamespace).Watch(versionedOptions) // as above
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&v1.ConfigMap{},
|
&v1.ConfigMap{},
|
||||||
|
@ -84,7 +84,7 @@ type NamespaceController struct {
|
|||||||
func NewNamespaceController(client federationclientset.Interface) *NamespaceController {
|
func NewNamespaceController(client federationclientset.Interface) *NamespaceController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-namespace-controller"})
|
recorder := broadcaster.NewRecorder(api_v1.EventSource{Component: "federated-namespace-controller"})
|
||||||
|
|
||||||
nc := &NamespaceController{
|
nc := &NamespaceController{
|
||||||
federatedApiClient: client,
|
federatedApiClient: client,
|
||||||
@ -103,13 +103,11 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
|
|||||||
// Start informer in federated API servers on namespaces that should be federated.
|
// Start informer in federated API servers on namespaces that should be federated.
|
||||||
nc.namespaceInformerStore, nc.namespaceInformerController = cache.NewInformer(
|
nc.namespaceInformerStore, nc.namespaceInformerController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Core().Namespaces().List(options)
|
||||||
return client.Core().Namespaces().List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Core().Namespaces().Watch(options)
|
||||||
return client.Core().Namespaces().Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.Namespace{},
|
&api_v1.Namespace{},
|
||||||
@ -122,13 +120,11 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
|
|||||||
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().Namespaces().List(options)
|
||||||
return targetClient.Core().Namespaces().List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().Namespaces().Watch(options)
|
||||||
return targetClient.Core().Namespaces().Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.Namespace{},
|
&api_v1.Namespace{},
|
||||||
|
@ -106,7 +106,7 @@ type ReplicaSetController struct {
|
|||||||
func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSetController {
|
func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSetController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(federationClient))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(federationClient))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-replicaset-controller"})
|
recorder := broadcaster.NewRecorder(apiv1.EventSource{Component: "federated-replicaset-controller"})
|
||||||
|
|
||||||
frsc := &ReplicaSetController{
|
frsc := &ReplicaSetController{
|
||||||
fedClient: federationClient,
|
fedClient: federationClient,
|
||||||
@ -125,13 +125,11 @@ func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSe
|
|||||||
replicaSetFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
replicaSetFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Extensions().ReplicaSets(apiv1.NamespaceAll).List(options)
|
||||||
return clientset.Extensions().ReplicaSets(apiv1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Extensions().ReplicaSets(apiv1.NamespaceAll).Watch(options)
|
||||||
return clientset.Extensions().ReplicaSets(apiv1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensionsv1.ReplicaSet{},
|
&extensionsv1.ReplicaSet{},
|
||||||
@ -154,13 +152,11 @@ func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSe
|
|||||||
podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
podFedInformerFactory := func(cluster *fedv1.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Core().Pods(apiv1.NamespaceAll).List(options)
|
||||||
return clientset.Core().Pods(apiv1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return clientset.Core().Pods(apiv1.NamespaceAll).Watch(options)
|
||||||
return clientset.Core().Pods(apiv1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&apiv1.Pod{},
|
&apiv1.Pod{},
|
||||||
@ -176,13 +172,11 @@ func NewReplicaSetController(federationClient fedclientset.Interface) *ReplicaSe
|
|||||||
|
|
||||||
frsc.replicaSetStore.Indexer, frsc.replicaSetController = cache.NewIndexerInformer(
|
frsc.replicaSetStore.Indexer, frsc.replicaSetController = cache.NewIndexerInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options apiv1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return frsc.fedClient.Extensions().ReplicaSets(apiv1.NamespaceAll).List(options)
|
||||||
return frsc.fedClient.Extensions().ReplicaSets(apiv1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options apiv1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := fedutil.VersionizeV1ListOptions(options)
|
return frsc.fedClient.Extensions().ReplicaSets(apiv1.NamespaceAll).Watch(options)
|
||||||
return frsc.fedClient.Extensions().ReplicaSets(apiv1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&extensionsv1.ReplicaSet{},
|
&extensionsv1.ReplicaSet{},
|
||||||
|
@ -85,7 +85,7 @@ type SecretController struct {
|
|||||||
func NewSecretController(client federationclientset.Interface) *SecretController {
|
func NewSecretController(client federationclientset.Interface) *SecretController {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
broadcaster.StartRecordingToSink(eventsink.NewFederatedEventSink(client))
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: "federated-secrets-controller"})
|
recorder := broadcaster.NewRecorder(api_v1.EventSource{Component: "federated-secrets-controller"})
|
||||||
|
|
||||||
secretcontroller := &SecretController{
|
secretcontroller := &SecretController{
|
||||||
federatedApiClient: client,
|
federatedApiClient: client,
|
||||||
@ -104,13 +104,11 @@ func NewSecretController(client federationclientset.Interface) *SecretController
|
|||||||
// Start informer in federated API servers on secrets that should be federated.
|
// Start informer in federated API servers on secrets that should be federated.
|
||||||
secretcontroller.secretInformerStore, secretcontroller.secretInformerController = cache.NewInformer(
|
secretcontroller.secretInformerStore, secretcontroller.secretInformerController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Core().Secrets(api_v1.NamespaceAll).List(options)
|
||||||
return client.Core().Secrets(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return client.Core().Secrets(api_v1.NamespaceAll).Watch(options)
|
||||||
return client.Core().Secrets(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.Secret{},
|
&api_v1.Secret{},
|
||||||
@ -123,13 +121,11 @@ func NewSecretController(client federationclientset.Interface) *SecretController
|
|||||||
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
func(cluster *federation_api.Cluster, targetClient kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().Secrets(api_v1.NamespaceAll).List(options)
|
||||||
return targetClient.Core().Secrets(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return targetClient.Core().Secrets(api_v1.NamespaceAll).Watch(options)
|
||||||
return targetClient.Core().Secrets(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.Secret{},
|
&api_v1.Secret{},
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
v1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
v1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
|
||||||
v1 "k8s.io/kubernetes/pkg/api/v1"
|
v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||||
cache "k8s.io/kubernetes/pkg/client/cache"
|
cache "k8s.io/kubernetes/pkg/client/cache"
|
||||||
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
|
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
|
||||||
@ -92,13 +91,11 @@ func (cc *clusterClientCache) startClusterLW(cluster *v1beta1.Cluster, clusterNa
|
|||||||
}
|
}
|
||||||
cachedClusterClient.endpointStore.Store, cachedClusterClient.endpointController = cache.NewInformer(
|
cachedClusterClient.endpointStore.Store, cachedClusterClient.endpointController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return clientset.Core().Endpoints(v1.NamespaceAll).List(options)
|
||||||
return clientset.Core().Endpoints(v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return clientset.Core().Endpoints(v1.NamespaceAll).Watch(options)
|
||||||
return clientset.Core().Endpoints(v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&v1.Endpoints{},
|
&v1.Endpoints{},
|
||||||
@ -118,13 +115,11 @@ func (cc *clusterClientCache) startClusterLW(cluster *v1beta1.Cluster, clusterNa
|
|||||||
|
|
||||||
cachedClusterClient.serviceStore.Indexer, cachedClusterClient.serviceController = cache.NewIndexerInformer(
|
cachedClusterClient.serviceStore.Indexer, cachedClusterClient.serviceController = cache.NewIndexerInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return clientset.Core().Services(v1.NamespaceAll).List(options)
|
||||||
return clientset.Core().Services(v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return clientset.Core().Services(v1.NamespaceAll).Watch(options)
|
||||||
return clientset.Core().Services(v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&v1.Service{},
|
&v1.Service{},
|
||||||
|
@ -22,9 +22,10 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
"strings"
|
||||||
|
|
||||||
"k8s.io/kubernetes/federation/pkg/dnsprovider"
|
"k8s.io/kubernetes/federation/pkg/dnsprovider"
|
||||||
"k8s.io/kubernetes/federation/pkg/dnsprovider/rrstype"
|
"k8s.io/kubernetes/federation/pkg/dnsprovider/rrstype"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -21,12 +21,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
"k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||||
"k8s.io/kubernetes/federation/pkg/dnsprovider/providers/google/clouddns" // Only for unit testing purposes.
|
"k8s.io/kubernetes/federation/pkg/dnsprovider/providers/google/clouddns" // Only for unit testing purposes.
|
||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/util/sets"
|
"k8s.io/kubernetes/pkg/util/sets"
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServiceController_ensureDnsRecords(t *testing.T) {
|
func TestServiceController_ensureDnsRecords(t *testing.T) {
|
||||||
|
@ -28,8 +28,6 @@ import (
|
|||||||
federationcache "k8s.io/kubernetes/federation/client/cache"
|
federationcache "k8s.io/kubernetes/federation/client/cache"
|
||||||
fedclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
|
fedclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
|
||||||
"k8s.io/kubernetes/federation/pkg/dnsprovider"
|
"k8s.io/kubernetes/federation/pkg/dnsprovider"
|
||||||
"k8s.io/kubernetes/federation/pkg/federation-controller/util"
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
|
||||||
"k8s.io/kubernetes/pkg/api/errors"
|
"k8s.io/kubernetes/pkg/api/errors"
|
||||||
v1 "k8s.io/kubernetes/pkg/api/v1"
|
v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||||
cache "k8s.io/kubernetes/pkg/client/cache"
|
cache "k8s.io/kubernetes/pkg/client/cache"
|
||||||
@ -145,7 +143,7 @@ func New(federationClient fedclientset.Interface, dns dnsprovider.Interface,
|
|||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
// federationClient event is not supported yet
|
// federationClient event is not supported yet
|
||||||
// broadcaster.StartRecordingToSink(&unversioned_core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
|
// broadcaster.StartRecordingToSink(&unversioned_core.EventSinkImpl{Interface: kubeClient.Core().Events("")})
|
||||||
recorder := broadcaster.NewRecorder(api.EventSource{Component: UserAgentName})
|
recorder := broadcaster.NewRecorder(v1.EventSource{Component: UserAgentName})
|
||||||
|
|
||||||
s := &ServiceController{
|
s := &ServiceController{
|
||||||
dns: dns,
|
dns: dns,
|
||||||
@ -166,13 +164,11 @@ func New(federationClient fedclientset.Interface, dns dnsprovider.Interface,
|
|||||||
}
|
}
|
||||||
s.serviceStore.Indexer, s.serviceController = cache.NewIndexerInformer(
|
s.serviceStore.Indexer, s.serviceController = cache.NewIndexerInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return s.federationClient.Core().Services(v1.NamespaceAll).List(options)
|
||||||
return s.federationClient.Core().Services(v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return s.federationClient.Core().Services(v1.NamespaceAll).Watch(options)
|
||||||
return s.federationClient.Core().Services(v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&v1.Service{},
|
&v1.Service{},
|
||||||
@ -191,13 +187,11 @@ func New(federationClient fedclientset.Interface, dns dnsprovider.Interface,
|
|||||||
)
|
)
|
||||||
s.clusterStore.Store, s.clusterController = cache.NewInformer(
|
s.clusterStore.Store, s.clusterController = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return s.federationClient.Federation().Clusters().List(options)
|
||||||
return s.federationClient.Federation().Clusters().List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := util.VersionizeV1ListOptions(options)
|
return s.federationClient.Federation().Clusters().Watch(options)
|
||||||
return s.federationClient.Federation().Clusters().Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&v1beta1.Cluster{},
|
&v1beta1.Cluster{},
|
||||||
|
@ -37,36 +37,14 @@ func NewFederatedEventSink(clientset fedclientset.Interface) *FederatedEventSink
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fes *FederatedEventSink) Create(event *api.Event) (*api.Event, error) {
|
func (fes *FederatedEventSink) Create(event *api_v1.Event) (*api_v1.Event, error) {
|
||||||
return fes.executeOperation(event, func(eventV1 *api_v1.Event) (*api_v1.Event, error) {
|
return fes.clientset.Core().Events(event.Namespace).Create(event)
|
||||||
return fes.clientset.Core().Events(event.Namespace).Create(eventV1)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fes *FederatedEventSink) Update(event *api.Event) (*api.Event, error) {
|
func (fes *FederatedEventSink) Update(event *api_v1.Event) (*api_v1.Event, error) {
|
||||||
return fes.executeOperation(event, func(eventV1 *api_v1.Event) (*api_v1.Event, error) {
|
return fes.clientset.Core().Events(event.Namespace).Update(event)
|
||||||
return fes.clientset.Core().Events(event.Namespace).Update(eventV1)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fes *FederatedEventSink) Patch(event *api.Event, data []byte) (*api.Event, error) {
|
func (fes *FederatedEventSink) Patch(event *api_v1.Event, data []byte) (*api_v1.Event, error) {
|
||||||
return fes.executeOperation(event, func(eventV1 *api_v1.Event) (*api_v1.Event, error) {
|
return fes.clientset.Core().Events(event.Namespace).Patch(event.Name, api.StrategicMergePatchType, data)
|
||||||
return fes.clientset.Core().Events(event.Namespace).Patch(event.Name, api.StrategicMergePatchType, data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fes *FederatedEventSink) executeOperation(event *api.Event, operation func(*api_v1.Event) (*api_v1.Event, error)) (*api.Event, error) {
|
|
||||||
var versionedEvent api_v1.Event
|
|
||||||
if err := api.Scheme.Convert(event, &versionedEvent, nil); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
versionedEventPtr, err := operation(&versionedEvent)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var unversionedEvent api.Event
|
|
||||||
if err := api.Scheme.Convert(versionedEventPtr, &unversionedEvent, nil); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &unversionedEvent, nil
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
fake_fedclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5/fake"
|
fake_fedclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5/fake"
|
||||||
. "k8s.io/kubernetes/federation/pkg/federation-controller/util/test"
|
. "k8s.io/kubernetes/federation/pkg/federation-controller/util/test"
|
||||||
api "k8s.io/kubernetes/pkg/api"
|
|
||||||
api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/testing/core"
|
"k8s.io/kubernetes/pkg/client/testing/core"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
@ -46,8 +45,8 @@ func TestEventSink(t *testing.T) {
|
|||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
event := api.Event{
|
event := api_v1.Event{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api_v1.ObjectMeta{
|
||||||
Name: "bzium",
|
Name: "bzium",
|
||||||
Namespace: "ns",
|
Namespace: "ns",
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
|
|
||||||
federation_api "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
federation_api "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||||
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
|
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
|
||||||
api "k8s.io/kubernetes/pkg/api"
|
|
||||||
api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/cache"
|
"k8s.io/kubernetes/pkg/client/cache"
|
||||||
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
|
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
|
||||||
@ -161,13 +160,11 @@ func NewFederatedInformer(
|
|||||||
|
|
||||||
federatedInformer.clusterInformer.store, federatedInformer.clusterInformer.controller = cache.NewInformer(
|
federatedInformer.clusterInformer.store, federatedInformer.clusterInformer.controller = cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (pkg_runtime.Object, error) {
|
||||||
versionedOptions := VersionizeV1ListOptions(options)
|
return federationClient.Federation().Clusters().List(options)
|
||||||
return federationClient.Federation().Clusters().List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := VersionizeV1ListOptions(options)
|
return federationClient.Federation().Clusters().Watch(options)
|
||||||
return federationClient.Federation().Clusters().Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&federation_api.Cluster{},
|
&federation_api.Cluster{},
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
federation_api "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
federation_api "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||||
fakefederationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5/fake"
|
fakefederationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5/fake"
|
||||||
api "k8s.io/kubernetes/pkg/api"
|
|
||||||
api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/cache"
|
"k8s.io/kubernetes/pkg/client/cache"
|
||||||
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
|
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
|
||||||
@ -81,13 +80,11 @@ func TestFederatedInformer(t *testing.T) {
|
|||||||
targetInformerFactory := func(cluster *federation_api.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
targetInformerFactory := func(cluster *federation_api.Cluster, clientset kubeclientset.Interface) (cache.Store, cache.ControllerInterface) {
|
||||||
return cache.NewInformer(
|
return cache.NewInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options api_v1.ListOptions) (runtime.Object, error) {
|
||||||
versionedOptions := VersionizeV1ListOptions(options)
|
return clientset.Core().Services(api_v1.NamespaceAll).List(options)
|
||||||
return clientset.Core().Services(api_v1.NamespaceAll).List(versionedOptions)
|
|
||||||
},
|
},
|
||||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
|
||||||
versionedOptions := VersionizeV1ListOptions(options)
|
return clientset.Core().Services(api_v1.NamespaceAll).Watch(options)
|
||||||
return clientset.Core().Services(api_v1.NamespaceAll).Watch(versionedOptions)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&api_v1.Service{},
|
&api_v1.Service{},
|
||||||
|
Loading…
Reference in New Issue
Block a user