...
- Change the current context to the newly created "federated cluster".
root @kubefed - 1 :~# kubectl config use-context enterprise
Switched to context "enterprise" .
root @kubefed - 1 :~#
|
2. Check clusters
Federated cluster should show "No resources found" before any clusters are joined.
root @kubefed - 1 :~# kubectl config use-context enterprise
Switched to context "enterprise" .
root @kubefed - 1 :~# kubectl get clusters
No resources found.
root @kubefed - 1 :~#
|
3. Join the first cluster(site-1) and verify it.
#join cluster
root @kubefed - 1 :~# kubefed join fedclusterone --host-cluster-context=kubernetes-admin-host --cluster-context=kubernetes-admin-s3
cluster "fedclusterone" created
#list clusters
root @kubefed - 1 :~# kubectl get clusters
NAME AGE
fedclusterone 30s
root @kubefed - 1 :~#
# switch context to joining cluster
root @kubefed - 1 :~# kubectl config use-context kubernetes-admin-s3
Switched to context "kubernetes-admin-s3" .
#view service account for joining cluster
root @kubefed - 1 :~# kubectl get serviceaccounts --all-namespaces | grep federation-system
NAMESPACE NAME SECRETS AGE
federation-system default 1 47s
federation-system fedclusterone-kubernetes-admin-host 1 47s
root @kubefed - 1 :~#
|
4. Join the second cluster(site-2) and verify it.
# change the context
root @kubefed - 1 :~# kubectl config use-context enterprise
Switched to context "enterprise" .
root @kubefed - 1 :~#
#join cluster
root @kubefed - 1 :~# kubefed join fedclustertwo --host-cluster-context=kubernetes-admin-host --cluster-context=kubernetes-admin-s5
cluster "fedclustertwo" created
#list clusters
root @kubefed - 1 :~# kubectl get clusters
NAME AGE
fedclusterone 6m
fedclustertwo 17s
root @kubefed - 1 :~#
# switch context to joining cluster
root @kubefed - 1 :~# kubectl config use-context kubernetes-admin-s5
Switched to context "kubernetes-admin-s5" .
#view service account for joining cluster
root @kubefed - 1 :~# kubectl get serviceaccounts --all-namespaces | grep federation-system
NAMESPACE NAME SECRETS AGE
federation-system default 1 5m
federation-system fedclustertwo-kubernetes-admin-host 1 5m
root @kubefed - 1 :~#
# change the context
root @kubefed - 1 :~# kubectl config use-context enterprise
Switched to context "enterprise" .
root @kubefed - 1 :~#
|
5. Set up default namespace for federation context:
root @kubefed - 1 :~# kubectl --context=enterprise create ns default
namespace "default" created
root @kubefed - 1 :~#
# verify it
ubuntu @kubefed - 4 :~$ kubectl --context=enterprise get namespace
NAME STATUS AGE
default Active 21s
ubuntu @kubefed - 4 :~$
|
Verifying federated site's cluster information
1. Describe clusters to view information
Removing a cluster from federation
A joined cluster can be removed from federation (if needed) using below command.
# switch context to federation context name
root @kubefed - 1 :~# kubectl config use-context enterprise
Switched to context "enterprise" .
#unjoin cluster fedclusterone
root @kubefed - 1 :~# kubefed unjoin fedclusterone --host-cluster-context=kubernetes-admin-host
Successfully removed cluster "fedclusterone" from federation
root @kubefed - 1 :~#
#view clusters after removing fedclusterone
root @kubefed - 1 :~# kubectl get clusters
NAME AGE
fedclustertwo 10d
root @kubefed - 1 :~#
|