Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

All commands are executed on federation master node.

  1. 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

#switch context to federation cluster
root@kubefed-1:~# kubectl config use-context enterprise
Switched to context "enterprise".
  
#describe federated clusters
root@kubefed-1:~# kubectl describe clusters
Name:         fedclusterone
Namespace:
Labels:       <none>
Annotations:  federation.kubernetes.io/cluster-role-name=federation-controller-manager:federation-fedclusterone-kubernetes-admin-host
              federation.kubernetes.io/servive-account-name=fedclusterone-kubernetes-admin-host
API Version:  federation/v1beta1
Kind:         Cluster
Metadata:
  Creation Timestamp:  2018-01-29T23:36:29Z
  Resource Version:    3850
  Self Link:           /apis/federation/v1beta1/clusters/fedclusterone
  UID:                 3acf1506-054d-11e8-8aa9-aaa2b22c081f
Spec:
  Secret Ref:
    Name:  fedclusterone-28jrt
  Server Address By Client CID Rs:
    Client CIDR:     0.0.0.0/0
    Server Address:  https://10.147.113.132:6443
Status:
  Conditions:
    Last Probe Time:       2018-01-30T19:40:14Z
    Last Transition Time:  2018-01-29T23:36:48Z
    Message:               /healthz responded with ok
    Reason:                ClusterReady
    Status:                True
    Type:                  Ready
Events:                    <none>
 
Name:         fedclustertwo
Namespace:
Labels:       <none>
Annotations:  federation.kubernetes.io/cluster-role-name=federation-controller-manager:federation-fedclustertwo-kubernetes-admin-host
              federation.kubernetes.io/servive-account-name=fedclustertwo-kubernetes-admin-host
API Version:  federation/v1beta1
Kind:         Cluster
Metadata:
  Creation Timestamp:  2018-01-29T23:42:46Z
  Resource Version:    3851
  Self Link:           /apis/federation/v1beta1/clusters/fedclustertwo
  UID:                 1bb4017e-054e-11e8-8aa9-aaa2b22c081f
Spec:
  Secret Ref:
    Name:  fedclustertwo-h979k
  Server Address By Client CID Rs:
    Client CIDR:     0.0.0.0/0
    Server Address:  https://10.147.112.160:6443
Status:
  Conditions:
    Last Probe Time:       2018-01-30T19:40:14Z
    Last Transition Time:  2018-01-29T23:42:48Z
    Message:               /healthz responded with ok
    Reason:                ClusterReady
    Status:                True
    Type:                  Ready
Events:                    <none>
root@kubefed-1:~#

 

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:~#
  

  • No labels