Skip to content

Latest commit

 

History

History

sample-fed-v2-demo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Sample Federation-v2 Demo

Prereqs

The following Demo must be run within the federation-v2 repository/Gopath.

Newer versions of minikube and certain drivers (kvm2) do not run with the "-p --profile" flag. Minikube v.25.2 has been used with kvm and virtualbox to successfully run this demo.

Create clusters

minikube start -p us-west
minikube start -p us-east
kubectl config use-context us-west
kubectl config set-context us-west --namespace=test-namespace
kubectl config set-context us-east --namespace=test-namespace

Create Federation Namespace

kubectl create ns federation

Deploy Cluster Registry

crinit aggregated init mycr --host-cluster-context=us-west
kubectl config delete-context mycr
kubectl config delete-cluster mycr

Deploy Federation

apiserver-boot run in-cluster --name federation --namespace federation --image <registry/username/imagename:tag>

Verify Clusters in Config

kubectl config get-clusters

Join Clusters to Federation

go build -o bin/kubefnord cmd/kubefnord/kubefnord.go
./bin/kubefnord join us-west --host-cluster-context us-west --add-to-registry --v=2
./bin/kubefnord join us-east --host-cluster-context us-west --add-to-registry --v=2

Check Status of Joined Clusters

kubectl -n federation describe federatedclusters

Create all the resources

git clone https://github.com/font/k8s-example-apps.git
cd k8s-example-apps/sample-fed-v2-demo/configs
kubectl create -f .

Check Status

for i in us-west us-east; do echo; echo ------------ ${i} ------------; echo; kubectl --context ${i} get ns test-namespace; echo; echo; done
for i in us-west us-east; do echo; echo ------------ ${i} ------------; echo; kubectl --context ${i} get configmaps; echo; echo; done
for i in us-west us-east; do echo; echo ------------ ${i} ------------; echo; kubectl --context ${i} get secrets; echo; echo; done
for i in us-west us-east; do echo; echo ------------ ${i} ------------; echo; kubectl --context ${i} get rs; echo; echo; done

Update FederatedNamespacePlacement

Remove us-east via a patch command or manually:

kubectl -n test-namespace patch federatednamespaceplacement test-namespace -p \
    '{"spec":{"clusternames": ["us-west"]}}'
kubectl -n test-namespace edit federatednamespaceplacement test-namespace

Then verify replicasets:

for i in us-west us-east; do echo; echo ------------ ${i} ------------; echo; kubectl --context ${i} -n test-namespace get rs; echo; echo; done

Update FederatedNamespacePlacement to add back us-east again via a patch command or manually:

kubectl -n test-namespace patch federatednamespaceplacement test-namespace -p \
    '{"spec":{"clusternames": ["us-west", "us-east"]}}'
kubectl -n test-namespace edit federatednamespaceplacement test-namespace

Then verify replicasets:

for i in us-west us-east; do echo; echo ------------ ${i} ------------; echo; kubectl --context ${i} -n test-namespace get rs; echo; echo; done

Conclusion

So you can see that Federation-v2 handles workloads by joining clusters into the workload, allowing you to specify the resource types that you want to propagate, override certain parameters that you want to differentiate in your clusters, and specify the placement rules for where you want that resource type to be propagated.

Cleanup

Delete clusters

minikube delete -p us-east
minikube delete -p us-west