This respository explains how we can connect multiple kubernetes clusters using the submariner tool https://submariner.io/
[This repository has been tested on VM's that were created in AWS cloud]
Create a management VM from where we can run all the commands, please make sure this VM has following tools installed
- ansible
- kubectl
https://kubernetes.io/docs/tasks/tools/
- subctl
curl -Ls https://get.submariner.io | bash
export PATH=$PATH:~/.local/bin
echo export PATH=\$PATH:~/.local/bin >> ~/.profile
The playbook directory has the ansible script to create kubernetes cluster
The inventory.yaml should be edited as per your VM host IPs and security credentials [pem file - removed from the repo]
This kubernetes cluster makes use of flannel CNI plugin hence the Pod_subnet range should always be 10.244.x.x/16 and ensure this range does not overlap with any other cluster
The test folder contains the deployment and service configuration for the pods that are installed in these cluster and are used to test the communication
nginx-demo.yaml -> This creates a nginx pod in one of the cluster with cluster IP configuration
netshoot.yaml -> This is make shift pod deployed on another cluster to test the ping/curl to the nginx pod which is another cluster
Following is the list of kubernetes clusters that we can create
- Cluster A - 2 VM [one master and one worker]
- Cluster B - 2 VM [one master and one worker] also acts as sumbariner broker
Clone the repository in the management VM Create a total of 4 VM's for 2 clusters and record their IPs, Make sure the worker node of each worker has a public IP and can be accessed from outside; also make sure the Security group setting allows all kind of inbound/outbound traffic to all these 4 VM's
Modify the inventory.yaml with the host IP address recorded above for VM's and security credentials[pem file] and execute in following order for each cluster
- Update kube dependencies
ansible-playbook -i inventory.yaml kube-dependencies.yaml
- Create master node
ansible-playbook -i inventory.yaml master.yaml
- Create worker nodes
ansible-playbook -i inventory.yaml workers.yaml
Install subctl on both the cluster master node, above all commands are executed on respective clusters master node
We are making cluster B as broker
subctl deploy-broker --kubeconfig .kube/config
subctl join --kubeconfig .kube/config broker-info.subm --clusterid clusterb
Note: broker-info.subm is the file auto generated from above command of deploy broker
Note: copy the broker-info.subm from cluster B to cluster A
subctl join --kubeconfig .kube/config broker-info.subm --clusterid clustera
subctl diagnose all
kubectl get clusters --all-namespaces
kubectl describe cluster --all-namespaces
kubectl get endpoint --all-namespaces
Note: copy the test/nginx-demo.yaml on the cluster B master node
kubectl apply -f nginx-demo.yaml
kubectl get svc -l app=nginx-demo
Note: Note down the cluster IP of nginx service
Note: copy the test/netshoot.yaml on the cluster A master node
kubectl apply -f netshoot.yaml
kubectl get pods -l app=netshoot
Note: Record the name of the pod
kubectl exec [netshoot pod name] -- curl [ClusterIP of Nginx-demo]