diff --git a/federation/cluster/federation-down.sh b/federation/cluster/federation-down.sh index 4787d778662..f3f71b2ae26 100755 --- a/federation/cluster/federation-down.sh +++ b/federation/cluster/federation-down.sh @@ -20,8 +20,9 @@ set -o pipefail KUBE_ROOT=$(readlink -m $(dirname "${BASH_SOURCE}")/../../) -# For $FEDERATION_NAME, $FEDERATION_KUBE_CONTEXT, $HOST_CLUSTER_CONTEXT, -# $KUBEDNS_CONFIGMAP_NAME and $KUBEDNS_CONFIGMAP_NAMESPACE. +# For $FEDERATION_NAME, $FEDERATION_NAMESPACE, $FEDERATION_KUBE_CONTEXT, +# $HOST_CLUSTER_CONTEXT, $KUBEDNS_CONFIGMAP_NAME and +# $KUBEDNS_CONFIGMAP_NAMESPACE. source "${KUBE_ROOT}/federation/cluster/common.sh" # federation_clusters returns a list of all the clusters in @@ -49,6 +50,7 @@ function unjoin_clusters() { "${KUBE_ROOT}/federation/develop/kubefed.sh" unjoin \ "${context}" \ + --federation-system-namespace=${FEDERATION_NAMESPACE} \ --context="${FEDERATION_KUBE_CONTEXT}" \ --host-cluster-context="${HOST_CLUSTER_CONTEXT}" done diff --git a/federation/cluster/federation-up.sh b/federation/cluster/federation-up.sh index 52783f20123..56158aacd9e 100755 --- a/federation/cluster/federation-up.sh +++ b/federation/cluster/federation-up.sh @@ -29,9 +29,9 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. # For `kube::log::status` function since it already sources # "${KUBE_ROOT}/cluster/lib/logging.sh" and DEFAULT_KUBECONFIG source "${KUBE_ROOT}/cluster/common.sh" -# For $FEDERATION_NAME, $FEDERATION_KUBE_CONTEXT, $HOST_CLUSTER_CONTEXT, -# $KUBEDNS_CONFIGMAP_NAME, $KUBEDNS_CONFIGMAP_NAMESPACE and -# $KUBEDNS_FEDERATION_FLAG. +# For $FEDERATION_NAME, $FEDERATION_NAMESPACE, $FEDERATION_KUBE_CONTEXT, +# $HOST_CLUSTER_CONTEXT, $KUBEDNS_CONFIGMAP_NAME, +# $KUBEDNS_CONFIGMAP_NAMESPACE and $KUBEDNS_FEDERATION_FLAG. source "${KUBE_ROOT}/federation/cluster/common.sh" DNS_ZONE_NAME="${FEDERATION_DNS_ZONE_NAME:-}" @@ -86,6 +86,7 @@ function init() { timeout --signal=INT --kill-after=1m 20m \ "${KUBE_ROOT}/federation/develop/kubefed.sh" init \ "${FEDERATION_NAME}" \ + --federation-system-namespace=${FEDERATION_NAMESPACE} \ --host-cluster-context="${HOST_CLUSTER_CONTEXT}" \ --dns-zone-name="${DNS_ZONE_NAME}" \ --dns-provider="${DNS_PROVIDER}" \ @@ -105,6 +106,7 @@ function join_clusters() { "${KUBE_ROOT}/federation/develop/kubefed.sh" join \ "${context}" \ + --federation-system-namespace=${FEDERATION_NAMESPACE} \ --host-cluster-context="${HOST_CLUSTER_CONTEXT}" \ --context="${FEDERATION_NAME}" \ --secret-name="${context//_/-}" # Replace "_" by "-" diff --git a/test/e2e/BUILD b/test/e2e/BUILD index aefd34797a3..ea9c8a71de8 100644 --- a/test/e2e/BUILD +++ b/test/e2e/BUILD @@ -102,7 +102,6 @@ go_library( ], tags = ["automanaged"], deps = [ - "//federation/apis/federation/v1beta1:go_default_library", "//pkg/api:go_default_library", "//pkg/api/annotations:go_default_library", "//pkg/api/v1:go_default_library", diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index cc8dfbaf6d1..7a833a33f9b 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -34,7 +34,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" runtimeutils "k8s.io/apimachinery/pkg/util/runtime" utilyaml "k8s.io/apimachinery/pkg/util/yaml" - federationapi "k8s.io/kubernetes/federation/apis/federation/v1beta1" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" @@ -116,7 +115,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { metav1.NamespaceSystem, metav1.NamespaceDefault, metav1.NamespacePublic, - federationapi.FederationNamespaceSystem, + framework.FederationSystemNamespace(), }) if err != nil { framework.Failf("Error deleting orphaned namespaces: %v", err) diff --git a/test/e2e/framework/BUILD b/test/e2e/framework/BUILD index 4b8c83a1d80..831dff0ac2f 100644 --- a/test/e2e/framework/BUILD +++ b/test/e2e/framework/BUILD @@ -13,6 +13,7 @@ go_library( "authorizer_util.go", "cleanup.go", "exec_util.go", + "federation_util.go", "firewall_util.go", "framework.go", "get-kubemark-resource-usage.go", @@ -36,6 +37,7 @@ go_library( ], tags = ["automanaged"], deps = [ + "//federation/apis/federation/v1beta1:go_default_library", "//pkg/api:go_default_library", "//pkg/api/v1:go_default_library", "//pkg/api/v1/service:go_default_library", diff --git a/test/e2e/framework/federation_util.go b/test/e2e/framework/federation_util.go new file mode 100644 index 00000000000..552473fab8f --- /dev/null +++ b/test/e2e/framework/federation_util.go @@ -0,0 +1,33 @@ +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package framework + +import ( + "os" + + federationapi "k8s.io/kubernetes/federation/apis/federation/v1beta1" +) + +// FederationSystemNamespace returns the namespace in which +// the federation system components are hosted. +func FederationSystemNamespace() string { + federationNS := os.Getenv("FEDERATION_NAMESPACE") + if federationNS != "" { + return federationNS + } + return federationapi.FederationNamespaceSystem +} diff --git a/test/e2e_federation/framework/util.go b/test/e2e_federation/framework/util.go index 7cc79aea451..2daea426499 100644 --- a/test/e2e_federation/framework/util.go +++ b/test/e2e_federation/framework/util.go @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/util/wait" restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" - federationapi "k8s.io/kubernetes/federation/apis/federation/v1beta1" "k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/validation" @@ -40,10 +39,7 @@ import ( // Detects whether the federation namespace exists in the underlying cluster func SkipUnlessFederated(c clientset.Interface) { - federationNS := os.Getenv("FEDERATION_NAMESPACE") - if federationNS == "" { - federationNS = federationapi.FederationNamespaceSystem - } + federationNS := framework.FederationSystemNamespace() _, err := c.Core().Namespaces().Get(federationNS, metav1.GetOptions{}) if err != nil {