mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 23:22:37 +00:00
154 lines
5.5 KiB
Diff
154 lines
5.5 KiB
Diff
From 1158d4cb3a3cd43f1d0a72bd35c6dea9b1de345e Mon Sep 17 00:00:00 2001
|
|
From: Manuel de Brito Fontes <aledbf@gmail.com>
|
|
Date: Wed, 21 Sep 2016 14:16:52 -0300
|
|
Subject: [PATCH] Fix k8s build
|
|
|
|
---
|
|
contrib/kubernetes/testscripts/00_run_k8s.sh | 2 +-
|
|
contrib/kubernetes/testscripts/10_setup_kubectl.sh | 2 +-
|
|
middleware/kubernetes/controller.go | 38 ++++++++--------------
|
|
middleware/kubernetes/kubernetes.go | 9 +++--
|
|
4 files changed, 20 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/contrib/kubernetes/testscripts/00_run_k8s.sh b/contrib/kubernetes/testscripts/00_run_k8s.sh
|
|
index ef98a8e..7ff6811 100755
|
|
--- a/contrib/kubernetes/testscripts/00_run_k8s.sh
|
|
+++ b/contrib/kubernetes/testscripts/00_run_k8s.sh
|
|
@@ -5,7 +5,7 @@ set -e
|
|
# Based on instructions at: http://kubernetes.io/docs/getting-started-guides/docker/
|
|
|
|
#K8S_VERSION=$(curl -sS https://storage.googleapis.com/kubernetes-release/release/latest.txt)
|
|
-K8S_VERSION="v1.2.4"
|
|
+K8S_VERSION="v1.3.7"
|
|
|
|
ARCH="amd64"
|
|
|
|
diff --git a/contrib/kubernetes/testscripts/10_setup_kubectl.sh b/contrib/kubernetes/testscripts/10_setup_kubectl.sh
|
|
index 1778671..a7cfc1e 100755
|
|
--- a/contrib/kubernetes/testscripts/10_setup_kubectl.sh
|
|
+++ b/contrib/kubernetes/testscripts/10_setup_kubectl.sh
|
|
@@ -10,7 +10,7 @@ cd ${BASEDIR}
|
|
echo "Setting up kubectl..."
|
|
|
|
if [ ! -e kubectl ]; then
|
|
- curl -O http://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/linux/amd64/kubectl
|
|
+ curl -O http://storage.googleapis.com/kubernetes-release/release/v1.3.7/bin/linux/amd64/kubectl
|
|
chmod u+x kubectl
|
|
fi
|
|
|
|
diff --git a/middleware/kubernetes/controller.go b/middleware/kubernetes/controller.go
|
|
index 126d415..c7f9e9e 100644
|
|
--- a/middleware/kubernetes/controller.go
|
|
+++ b/middleware/kubernetes/controller.go
|
|
@@ -55,12 +55,15 @@ func newdnsController(kubeClient *client.Client, resyncPeriod time.Duration, lse
|
|
},
|
|
&api.Endpoints{}, resyncPeriod, cache.ResourceEventHandlerFuncs{})
|
|
|
|
- dns.svcLister.Store, dns.svcController = cache.NewInformer(
|
|
+ dns.svcLister.Indexer, dns.svcController = cache.NewIndexerInformer(
|
|
&cache.ListWatch{
|
|
ListFunc: serviceListFunc(dns.client, namespace, dns.selector),
|
|
WatchFunc: serviceWatchFunc(dns.client, namespace, dns.selector),
|
|
},
|
|
- &api.Service{}, resyncPeriod, cache.ResourceEventHandlerFuncs{})
|
|
+ &api.Service{},
|
|
+ resyncPeriod,
|
|
+ cache.ResourceEventHandlerFuncs{},
|
|
+ cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
|
|
|
|
dns.nsLister.Store, dns.nsController = cache.NewInformer(
|
|
&cache.ListWatch{
|
|
@@ -163,47 +166,34 @@ func (dns *dnsController) GetNamespaceList() *api.NamespaceList {
|
|
return &nsList
|
|
}
|
|
|
|
-func (dns *dnsController) GetServiceList() *api.ServiceList {
|
|
- svcList, err := dns.svcLister.List()
|
|
+func (dns *dnsController) GetServiceList() []*api.Service {
|
|
+ svcs, err := dns.svcLister.List(labels.Everything())
|
|
if err != nil {
|
|
- return &api.ServiceList{}
|
|
+ return []*api.Service{}
|
|
}
|
|
-
|
|
- return &svcList
|
|
+ return svcs
|
|
}
|
|
|
|
// GetServicesByNamespace returns a map of
|
|
// namespacename :: [ kubernetesService ]
|
|
func (dns *dnsController) GetServicesByNamespace() map[string][]api.Service {
|
|
k8sServiceList := dns.GetServiceList()
|
|
- if k8sServiceList == nil {
|
|
- return nil
|
|
- }
|
|
-
|
|
- items := make(map[string][]api.Service, len(k8sServiceList.Items))
|
|
- for _, i := range k8sServiceList.Items {
|
|
+ items := make(map[string][]api.Service, len(k8sServiceList))
|
|
+ for _, i := range k8sServiceList {
|
|
namespace := i.Namespace
|
|
- items[namespace] = append(items[namespace], i)
|
|
+ items[namespace] = append(items[namespace], *i)
|
|
}
|
|
-
|
|
return items
|
|
}
|
|
|
|
// GetServiceInNamespace returns the Service that matches
|
|
// servicename in the namespace
|
|
func (dns *dnsController) GetServiceInNamespace(namespace string, servicename string) *api.Service {
|
|
- svcKey := fmt.Sprintf("%v/%v", namespace, servicename)
|
|
- svcObj, svcExists, err := dns.svcLister.Store.GetByKey(svcKey)
|
|
-
|
|
+ svcObj, err := dns.svcLister.Services(namespace).Get(servicename)
|
|
if err != nil {
|
|
// TODO(...): should return err here
|
|
return nil
|
|
}
|
|
|
|
- if !svcExists {
|
|
- // TODO(...): should return err here
|
|
- return nil
|
|
- }
|
|
-
|
|
- return svcObj.(*api.Service)
|
|
+ return svcObj
|
|
}
|
|
diff --git a/middleware/kubernetes/kubernetes.go b/middleware/kubernetes/kubernetes.go
|
|
index 0bd1dc7..eddc58b 100644
|
|
--- a/middleware/kubernetes/kubernetes.go
|
|
+++ b/middleware/kubernetes/kubernetes.go
|
|
@@ -183,14 +183,14 @@ func (k *Kubernetes) Get(namespace string, nsWildcard bool, servicename string,
|
|
|
|
var resultItems []api.Service
|
|
|
|
- for _, item := range serviceList.Items {
|
|
+ for _, item := range serviceList {
|
|
if symbolMatches(namespace, item.Namespace, nsWildcard) && symbolMatches(servicename, item.Name, serviceWildcard) {
|
|
// If namespace has a wildcard, filter results against Corefile namespace list.
|
|
// (Namespaces without a wildcard were filtered before the call to this function.)
|
|
if nsWildcard && (len(k.Namespaces) > 0) && (!util.StringInSlice(item.Namespace, k.Namespaces)) {
|
|
continue
|
|
}
|
|
- resultItems = append(resultItems, item)
|
|
+ resultItems = append(resultItems, *item)
|
|
}
|
|
}
|
|
|
|
@@ -216,12 +216,11 @@ func isKubernetesNameError(err error) bool {
|
|
}
|
|
|
|
func (k *Kubernetes) getServiceRecordForIP(ip, name string) []msg.Service {
|
|
- svcList, err := k.APIConn.svcLister.List()
|
|
+ svcList, err := k.APIConn.svcLister.List(labels.Everything())
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
-
|
|
- for _, service := range svcList.Items {
|
|
+ for _, service := range svcList {
|
|
if service.Spec.ClusterIP == ip {
|
|
return []msg.Service{msg.Service{Host: ip}}
|
|
}
|