Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b9b252fb
Commit
b9b252fb
authored
Feb 03, 2017
by
shashidharatd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Cluster Registration to federation-up.sh
parent
3ce49346
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
36 additions
and
78 deletions
+36
-78
federation-up.sh
federation/cluster/federation-up.sh
+21
-21
federated-daemonset.go
test/e2e_federation/federated-daemonset.go
+1
-3
federated-deployment.go
test/e2e_federation/federated-deployment.go
+2
-9
federated-ingress.go
test/e2e_federation/federated-ingress.go
+1
-3
federated-namespace.go
test/e2e_federation/federated-namespace.go
+1
-11
federated-replicaset.go
test/e2e_federation/federated-replicaset.go
+2
-9
federated-secret.go
test/e2e_federation/federated-secret.go
+1
-4
federated-service.go
test/e2e_federation/federated-service.go
+1
-6
federation-util.go
test/e2e_federation/federation-util.go
+6
-9
framework.go
test/e2e_federation/framework/framework.go
+0
-3
No files found.
federation/cluster/federation-up.sh
View file @
b9b252fb
...
@@ -55,34 +55,34 @@ function init() {
...
@@ -55,34 +55,34 @@ function init() {
--image
=
"
${
kube_registry
}
/hyperkube-amd64:
${
kube_version
}
"
--image
=
"
${
kube_registry
}
/hyperkube-amd64:
${
kube_version
}
"
}
}
# create_cluster_secrets creates the secrets containing the kubeconfigs
# join_cluster_to_federation joins the clusters in the local kubeconfig to federation. The clusters
# of the participating clusters in the host cluster. The kubeconfigs itself
# and their kubeconfig entries in the local kubeconfig are created while deploying clusters, i.e. when kube-up is run.
# are created while deploying clusters, i.e. when kube-up is run.
function
join_cluster_to_federation
()
{
function
create_cluster_secrets
()
{
for
cluster
in
$(
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
config get-clusters |sed
-n
'1!p'
)
;
do
local
-r
kubeconfig_dir
=
"
$(
dirname
${
DEFAULT_KUBECONFIG
})
"
# Skip federation context
local
-r
base_dir
=
"
${
kubeconfig_dir
}
/federation/kubernetes-apiserver"
if
[[
"
${
cluster
}
"
==
"
${
FEDERATION_NAME
}
"
]]
;
then
continue
fi
# Skip contexts not beginning with "federation"
if
[[
"
${
cluster
}
"
!=
federation
*
]]
;
then
continue
fi
# Create secrets with all the kubernetes-apiserver's kubeconfigs.
kube::log::status
"Joining cluster with name '
${
cluster
}
' to federation with name '
${
FEDERATION_NAME
}
'"
for
dir
in
$(
ls
"
${
base_dir
}
"
)
;
do
# We create a secret with the same name as the directory name (which is
"
${
KUBE_ROOT
}
/federation/develop/kubefed.sh"
join
\
# same as cluster name in kubeconfig).
"
${
cluster
}
"
\
# Massage the name so that it is valid (should not contain "_" and max 253
--host-cluster-context
=
"
${
HOST_CLUSTER_CONTEXT
}
"
\
# chars)
--context
=
"
${
FEDERATION_NAME
}
"
\
name
=
$(
echo
"
${
dir
}
"
|
sed
-e
"s/_/-/g"
)
# Replace "_" by "-"
--secret-name
=
"
${
cluster
//_/-
}
"
# Replace "_" by "-"
name
=
${
name
:0:252
}
kube::log::status
"Creating secret with name:
${
name
}
in namespace
${
FEDERATION_NAMESPACE
}
"
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
create secret generic
${
name
}
--from-file
=
"
${
base_dir
}
/
${
dir
}
/kubeconfig"
--namespace
=
"
${
FEDERATION_NAMESPACE
}
"
done
done
}
}
USE_KUBEFED
=
"
${
USE_KUBEFED
:-}
"
USE_KUBEFED
=
"
${
USE_KUBEFED
:-}
"
if
[[
"
${
USE_KUBEFED
}
"
==
"true"
]]
;
then
if
[[
"
${
USE_KUBEFED
}
"
==
"true"
]]
;
then
init
init
# TODO(madhusudancs): Call to create_cluster_secrets and the function
# itself must be removed after implementing cluster join with kubefed
join_cluster_to_federation
# here. This call is now required for the cluster joins in the
# BeforeEach blocks of each e2e test to work.
create_cluster_secrets
else
else
# Read the version back from the versions file if no version is given.
# Read the version back from the versions file if no version is given.
readonly
kube_version
=
"
$(
cat
${
KUBE_ROOT
}
/_output/federation/versions | python
-c
'\
readonly
kube_version
=
"
$(
cat
${
KUBE_ROOT
}
/_output/federation/versions | python
-c
'\
...
...
test/e2e_federation/federated-daemonset.go
View file @
b9b252fb
...
@@ -51,8 +51,7 @@ var _ = framework.KubeDescribe("Federation daemonsets [Feature:Federation]", fun
...
@@ -51,8 +51,7 @@ var _ = framework.KubeDescribe("Federation daemonsets [Feature:Federation]", fun
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
clusters
=
map
[
string
]
*
cluster
{}
clusters
,
_
=
getRegisteredClusters
(
UserAgentName
,
f
)
registerClusters
(
clusters
,
UserAgentName
,
""
,
f
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
...
@@ -60,7 +59,6 @@ var _ = framework.KubeDescribe("Federation daemonsets [Feature:Federation]", fun
...
@@ -60,7 +59,6 @@ var _ = framework.KubeDescribe("Federation daemonsets [Feature:Federation]", fun
// Delete all daemonsets.
// Delete all daemonsets.
nsName
:=
f
.
FederationNamespace
.
Name
nsName
:=
f
.
FederationNamespace
.
Name
deleteAllDaemonSetsOrFail
(
f
.
FederationClientset
,
nsName
)
deleteAllDaemonSetsOrFail
(
f
.
FederationClientset
,
nsName
)
unregisterClusters
(
clusters
,
f
)
})
})
It
(
"should be created and deleted successfully"
,
func
()
{
It
(
"should be created and deleted successfully"
,
func
()
{
...
...
test/e2e_federation/federated-deployment.go
View file @
b9b252fb
...
@@ -18,7 +18,6 @@ package e2e_federation
...
@@ -18,7 +18,6 @@ package e2e_federation
import
(
import
(
"fmt"
"fmt"
"os"
"strings"
"strings"
"time"
"time"
...
@@ -71,22 +70,16 @@ var _ = framework.KubeDescribe("Federation deployments [Feature:Federation]", fu
...
@@ -71,22 +70,16 @@ var _ = framework.KubeDescribe("Federation deployments [Feature:Federation]", fu
// e2e cases for federated deployment controller
// e2e cases for federated deployment controller
Describe
(
"Federated Deployment"
,
func
()
{
Describe
(
"Federated Deployment"
,
func
()
{
var
(
var
(
clusters
map
[
string
]
*
cluster
clusters
map
[
string
]
*
cluster
federationName
string
)
)
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
if
federationName
=
os
.
Getenv
(
"FEDERATION_NAME"
);
federationName
==
""
{
clusters
,
_
=
getRegisteredClusters
(
UserAgentName
,
f
)
federationName
=
DefaultFederationName
}
clusters
=
map
[
string
]
*
cluster
{}
registerClusters
(
clusters
,
UserAgentName
,
federationName
,
f
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
nsName
:=
f
.
FederationNamespace
.
Name
nsName
:=
f
.
FederationNamespace
.
Name
deleteAllDeploymentsOrFail
(
f
.
FederationClientset
,
nsName
)
deleteAllDeploymentsOrFail
(
f
.
FederationClientset
,
nsName
)
unregisterClusters
(
clusters
,
f
)
})
})
It
(
"should create and update matching deployments in underlying clusters"
,
func
()
{
It
(
"should create and update matching deployments in underlying clusters"
,
func
()
{
...
...
test/e2e_federation/federated-ingress.go
View file @
b9b252fb
...
@@ -94,8 +94,7 @@ var _ = framework.KubeDescribe("Federated ingresses [Feature:Federation]", func(
...
@@ -94,8 +94,7 @@ var _ = framework.KubeDescribe("Federated ingresses [Feature:Federation]", func(
federationName
=
DefaultFederationName
federationName
=
DefaultFederationName
}
}
jig
=
newFederationTestJig
(
f
.
FederationClientset
)
jig
=
newFederationTestJig
(
f
.
FederationClientset
)
clusters
=
map
[
string
]
*
cluster
{}
clusters
,
primaryClusterName
=
getRegisteredClusters
(
UserAgentName
,
f
)
primaryClusterName
=
registerClusters
(
clusters
,
UserAgentName
,
federationName
,
f
)
ns
=
f
.
FederationNamespace
.
Name
ns
=
f
.
FederationNamespace
.
Name
})
})
...
@@ -103,7 +102,6 @@ var _ = framework.KubeDescribe("Federated ingresses [Feature:Federation]", func(
...
@@ -103,7 +102,6 @@ var _ = framework.KubeDescribe("Federated ingresses [Feature:Federation]", func(
// Delete all ingresses.
// Delete all ingresses.
nsName
:=
f
.
FederationNamespace
.
Name
nsName
:=
f
.
FederationNamespace
.
Name
deleteAllIngressesOrFail
(
f
.
FederationClientset
,
nsName
)
deleteAllIngressesOrFail
(
f
.
FederationClientset
,
nsName
)
unregisterClusters
(
clusters
,
f
)
})
})
It
(
"should create and update matching ingresses in underlying clusters"
,
func
()
{
It
(
"should create and update matching ingresses in underlying clusters"
,
func
()
{
...
...
test/e2e_federation/federated-namespace.go
View file @
b9b252fb
...
@@ -18,7 +18,6 @@ package e2e_federation
...
@@ -18,7 +18,6 @@ package e2e_federation
import
(
import
(
"fmt"
"fmt"
"os"
"strings"
"strings"
"time"
"time"
...
@@ -44,19 +43,11 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
...
@@ -44,19 +43,11 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
f
:=
fedframework
.
NewDefaultFederatedFramework
(
"federation-namespace"
)
f
:=
fedframework
.
NewDefaultFederatedFramework
(
"federation-namespace"
)
Describe
(
"Namespace objects"
,
func
()
{
Describe
(
"Namespace objects"
,
func
()
{
var
federationName
string
var
clusters
map
[
string
]
*
cluster
// All clusters, keyed by cluster name
var
clusters
map
[
string
]
*
cluster
// All clusters, keyed by cluster name
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
clusters
,
_
=
getRegisteredClusters
(
UserAgentName
,
f
)
// TODO: Federation API server should be able to answer this.
if
federationName
=
os
.
Getenv
(
"FEDERATION_NAME"
);
federationName
==
""
{
federationName
=
DefaultFederationName
}
clusters
=
map
[
string
]
*
cluster
{}
registerClusters
(
clusters
,
UserAgentName
,
federationName
,
f
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
...
@@ -69,7 +60,6 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
...
@@ -69,7 +60,6 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
cluster
.
Core
()
.
Namespaces
()
.
List
,
cluster
.
Core
()
.
Namespaces
()
.
List
,
cluster
.
Core
()
.
Namespaces
()
.
Delete
)
cluster
.
Core
()
.
Namespaces
()
.
Delete
)
}
}
unregisterClusters
(
clusters
,
f
)
})
})
It
(
"should be created and deleted successfully"
,
func
()
{
It
(
"should be created and deleted successfully"
,
func
()
{
...
...
test/e2e_federation/federated-replicaset.go
View file @
b9b252fb
...
@@ -18,7 +18,6 @@ package e2e_federation
...
@@ -18,7 +18,6 @@ package e2e_federation
import
(
import
(
"fmt"
"fmt"
"os"
"strings"
"strings"
"time"
"time"
...
@@ -73,23 +72,17 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
...
@@ -73,23 +72,17 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
// e2e cases for federated replicaset controller
// e2e cases for federated replicaset controller
Describe
(
"Federated ReplicaSet"
,
func
()
{
Describe
(
"Federated ReplicaSet"
,
func
()
{
var
(
var
(
clusters
map
[
string
]
*
cluster
clusters
map
[
string
]
*
cluster
federationName
string
)
)
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
if
federationName
=
os
.
Getenv
(
"FEDERATION_NAME"
);
federationName
==
""
{
clusters
,
_
=
getRegisteredClusters
(
UserAgentName
,
f
)
federationName
=
DefaultFederationName
}
clusters
=
map
[
string
]
*
cluster
{}
registerClusters
(
clusters
,
UserAgentName
,
federationName
,
f
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
// Delete all replicasets.
// Delete all replicasets.
nsName
:=
f
.
FederationNamespace
.
Name
nsName
:=
f
.
FederationNamespace
.
Name
deleteAllReplicaSetsOrFail
(
f
.
FederationClientset
,
nsName
)
deleteAllReplicaSetsOrFail
(
f
.
FederationClientset
,
nsName
)
unregisterClusters
(
clusters
,
f
)
})
})
It
(
"should create and update matching replicasets in underling clusters"
,
func
()
{
It
(
"should create and update matching replicasets in underling clusters"
,
func
()
{
...
...
test/e2e_federation/federated-secret.go
View file @
b9b252fb
...
@@ -50,8 +50,7 @@ var _ = framework.KubeDescribe("Federation secrets [Feature:Federation]", func()
...
@@ -50,8 +50,7 @@ var _ = framework.KubeDescribe("Federation secrets [Feature:Federation]", func()
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
fedframework
.
SkipUnlessFederated
(
f
.
ClientSet
)
clusters
=
map
[
string
]
*
cluster
{}
clusters
,
_
=
getRegisteredClusters
(
UserAgentName
,
f
)
registerClusters
(
clusters
,
UserAgentName
,
""
,
f
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
...
@@ -59,8 +58,6 @@ var _ = framework.KubeDescribe("Federation secrets [Feature:Federation]", func()
...
@@ -59,8 +58,6 @@ var _ = framework.KubeDescribe("Federation secrets [Feature:Federation]", func()
// Delete all secrets.
// Delete all secrets.
nsName
:=
f
.
FederationNamespace
.
Name
nsName
:=
f
.
FederationNamespace
.
Name
deleteAllSecretsOrFail
(
f
.
FederationClientset
,
nsName
)
deleteAllSecretsOrFail
(
f
.
FederationClientset
,
nsName
)
unregisterClusters
(
clusters
,
f
)
})
})
It
(
"should be created and deleted successfully"
,
func
()
{
It
(
"should be created and deleted successfully"
,
func
()
{
...
...
test/e2e_federation/federated-service.go
View file @
b9b252fb
...
@@ -89,12 +89,7 @@ var _ = framework.KubeDescribe("Federated Services [Feature:Federation]", func()
...
@@ -89,12 +89,7 @@ var _ = framework.KubeDescribe("Federated Services [Feature:Federation]", func()
federationName
=
DefaultFederationName
federationName
=
DefaultFederationName
}
}
clusters
=
map
[
string
]
*
cluster
{}
clusters
,
primaryClusterName
=
getRegisteredClusters
(
UserAgentName
,
f
)
primaryClusterName
=
registerClusters
(
clusters
,
UserAgentName
,
federationName
,
f
)
})
AfterEach
(
func
()
{
unregisterClusters
(
clusters
,
f
)
})
})
Describe
(
"service creation"
,
func
()
{
Describe
(
"service creation"
,
func
()
{
...
...
test/e2e_federation/federation-util.go
View file @
b9b252fb
...
@@ -100,9 +100,9 @@ func clusterIsReadyOrFail(f *fedframework.Framework, context *fedframework.E2ECo
...
@@ -100,9 +100,9 @@ func clusterIsReadyOrFail(f *fedframework.Framework, context *fedframework.E2ECo
framework
.
Logf
(
"Cluster %s is Ready"
,
context
.
Name
)
framework
.
Logf
(
"Cluster %s is Ready"
,
context
.
Name
)
}
}
// waitForAll
ClustersReady wait
for all clusters defined in e2e context to be created
// waitForAll
RegisteredClusters waits
for all clusters defined in e2e context to be created
// return ClusterList until the listed cluster items equals clusterCount
// return ClusterList until the listed cluster items equals clusterCount
func
waitForAll
ClustersReady
(
f
*
fedframework
.
Framework
,
clusterCount
int
)
*
federationapi
.
ClusterList
{
func
waitForAll
RegisteredClusters
(
f
*
fedframework
.
Framework
,
clusterCount
int
)
*
federationapi
.
ClusterList
{
var
clusterList
*
federationapi
.
ClusterList
var
clusterList
*
federationapi
.
ClusterList
if
err
:=
wait
.
PollImmediate
(
framework
.
Poll
,
FederatedServiceTimeout
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
PollImmediate
(
framework
.
Poll
,
FederatedServiceTimeout
,
func
()
(
bool
,
error
)
{
var
err
error
var
err
error
...
@@ -187,15 +187,12 @@ func unregisterClusters(clusters map[string]*cluster, f *fedframework.Framework)
...
@@ -187,15 +187,12 @@ func unregisterClusters(clusters map[string]*cluster, f *fedframework.Framework)
}
}
// can not be moved to util, as By and Expect must be put in Ginkgo test unit
// can not be moved to util, as By and Expect must be put in Ginkgo test unit
func
registerClusters
(
clusters
map
[
string
]
*
cluster
,
userAgentName
,
federationName
string
,
f
*
fedframework
.
Framework
)
string
{
func
getRegisteredClusters
(
userAgentName
string
,
f
*
fedframework
.
Framework
)
(
map
[
string
]
*
cluster
,
string
)
{
clusters
:=
make
(
map
[
string
]
*
cluster
)
contexts
:=
f
.
GetUnderlyingFederatedContexts
()
contexts
:=
f
.
GetUnderlyingFederatedContexts
()
for
_
,
context
:=
range
contexts
{
createClusterObjectOrFail
(
f
,
&
context
)
}
By
(
"Obtaining a list of all the clusters"
)
By
(
"Obtaining a list of all the clusters"
)
clusterList
:=
waitForAll
ClustersReady
(
f
,
len
(
contexts
))
clusterList
:=
waitForAll
RegisteredClusters
(
f
,
len
(
contexts
))
framework
.
Logf
(
"Checking that %d clusters are Ready"
,
len
(
contexts
))
framework
.
Logf
(
"Checking that %d clusters are Ready"
,
len
(
contexts
))
for
_
,
context
:=
range
contexts
{
for
_
,
context
:=
range
contexts
{
...
@@ -211,7 +208,7 @@ func registerClusters(clusters map[string]*cluster, userAgentName, federationNam
...
@@ -211,7 +208,7 @@ func registerClusters(clusters map[string]*cluster, userAgentName, federationNam
clusters
[
c
.
Name
]
=
&
cluster
{
c
.
Name
,
createClientsetForCluster
(
c
,
i
,
userAgentName
),
false
,
nil
}
clusters
[
c
.
Name
]
=
&
cluster
{
c
.
Name
,
createClientsetForCluster
(
c
,
i
,
userAgentName
),
false
,
nil
}
}
}
createNamespaceInClusters
(
clusters
,
f
)
createNamespaceInClusters
(
clusters
,
f
)
return
primaryClusterName
return
clusters
,
primaryClusterName
}
}
/*
/*
...
...
test/e2e_federation/framework/framework.go
View file @
b9b252fb
...
@@ -140,9 +140,6 @@ func (f *Framework) FederationAfterEach() {
...
@@ -140,9 +140,6 @@ func (f *Framework) FederationAfterEach() {
framework
.
Logf
(
"Warning: framework is marked federated, but has no federation 1.5 clientset"
)
framework
.
Logf
(
"Warning: framework is marked federated, but has no federation 1.5 clientset"
)
return
return
}
}
if
err
:=
f
.
FederationClientset
.
Federation
()
.
Clusters
()
.
DeleteCollection
(
nil
,
metav1
.
ListOptions
{});
err
!=
nil
{
framework
.
Logf
(
"Error: failed to delete Clusters: %+v"
,
err
)
}
}()
}()
// Print events if the test failed.
// Print events if the test failed.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment