added kubernetes example
This commit is contained in:
		
							parent
							
								
									c0fb284f5e
								
							
						
					
					
						commit
						657f8e5266
					
				
							
								
								
									
										14
									
								
								kubernetes/README.md
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										14
									
								
								kubernetes/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					# WireGuard cluster example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This example will create 5 kubernetes nodes using k3s: a master and 4 workers.
 | 
				
			||||||
 | 
					All VMs have public IPs, which can be used to publish ports.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					To create the VMs, run:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					./create_vms.sh
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					And to deploy:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					./deploy.sh
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
							
								
								
									
										36
									
								
								kubernetes/create_vms.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										36
									
								
								kubernetes/create_vms.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					mkdir -p tmp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					detee-cli vm deploy --hostname k3s-master --vcpus 4 \
 | 
				
			||||||
 | 
					  --memory 4000 --disk 20 --location Random --public-ip |
 | 
				
			||||||
 | 
					  tail -1 > tmp/master_ssh_command &&
 | 
				
			||||||
 | 
					  echo "k3s-master successfully created" &
 | 
				
			||||||
 | 
					sleep 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					detee-cli vm deploy --hostname k3s-node-1 --vcpus 4 \
 | 
				
			||||||
 | 
					  --memory 4000 --disk 20 --location Random --public-ip |
 | 
				
			||||||
 | 
					  tail -1 > tmp/node1_ssh_command &&
 | 
				
			||||||
 | 
					  echo "k3s-node-1 successfully created" &
 | 
				
			||||||
 | 
					sleep 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					detee-cli vm deploy --hostname k3s-node-2 --vcpus 4 \
 | 
				
			||||||
 | 
					  --memory 4000 --disk 20 --location Random --public-ip |
 | 
				
			||||||
 | 
					  tail -1 > tmp/node2_ssh_command &&
 | 
				
			||||||
 | 
					  echo "k3s-node-2 successfully created" &
 | 
				
			||||||
 | 
					sleep 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					detee-cli vm deploy --hostname k3s-node-3 --vcpus 4 \
 | 
				
			||||||
 | 
					  --memory 4000 --disk 20 --location Random --public-ip |
 | 
				
			||||||
 | 
					  tail -1 > tmp/node3_ssh_command &&
 | 
				
			||||||
 | 
					  echo "k3s-node-3 successfully created" &
 | 
				
			||||||
 | 
					sleep 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					detee-cli vm deploy --hostname k3s-node-4 --vcpus 4 \
 | 
				
			||||||
 | 
					  --memory 4000 --disk 20 --location Random --public-ip |
 | 
				
			||||||
 | 
					  tail -1 > tmp/node4_ssh_command &&
 | 
				
			||||||
 | 
					  echo "k3s-node-4 successfully created" &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wait
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										40
									
								
								kubernetes/deploy.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										40
									
								
								kubernetes/deploy.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					ssh_master=$(cat tmp/master_ssh_command)
 | 
				
			||||||
 | 
					ssh_node1=$(cat tmp/node1_ssh_command)
 | 
				
			||||||
 | 
					ssh_node2=$(cat tmp/node2_ssh_command)
 | 
				
			||||||
 | 
					ssh_node3=$(cat tmp/node3_ssh_command)
 | 
				
			||||||
 | 
					ssh_node4=$(cat tmp/node4_ssh_command)
 | 
				
			||||||
 | 
					sleep 5
 | 
				
			||||||
 | 
					echo Master SSH command: $ssh_master | grep ssh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$ssh_master curl -o /root/get_k3s.sh https://get.k3s.io 
 | 
				
			||||||
 | 
					$ssh_master chmod +x /root/get_k3s.sh
 | 
				
			||||||
 | 
					$ssh_node1 curl -o /root/get_k3s.sh https://get.k3s.io 
 | 
				
			||||||
 | 
					$ssh_node1 chmod +x /root/get_k3s.sh
 | 
				
			||||||
 | 
					$ssh_node2 curl -o /root/get_k3s.sh https://get.k3s.io 
 | 
				
			||||||
 | 
					$ssh_node2 chmod +x /root/get_k3s.sh
 | 
				
			||||||
 | 
					$ssh_node3 curl -o /root/get_k3s.sh https://get.k3s.io 
 | 
				
			||||||
 | 
					$ssh_node3 chmod +x /root/get_k3s.sh
 | 
				
			||||||
 | 
					$ssh_node4 curl -o /root/get_k3s.sh https://get.k3s.io 
 | 
				
			||||||
 | 
					$ssh_node4 chmod +x /root/get_k3s.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$ssh_master /root/get_k3s.sh server --cluster-init
 | 
				
			||||||
 | 
					master_ip=$(echo $ssh_master | cut -d '@' -f2)
 | 
				
			||||||
 | 
					sleep 10
 | 
				
			||||||
 | 
					token=$($ssh_master cat /var/lib/rancher/k3s/server/node-token)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					worker_cmd="K3S_URL='https://${master_ip}:6443' K3S_TOKEN='${token}' /root/get_k3s.sh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$ssh_node1 $worker_cmd &
 | 
				
			||||||
 | 
					$ssh_node2 $worker_cmd &
 | 
				
			||||||
 | 
					$ssh_node3 $worker_cmd &
 | 
				
			||||||
 | 
					$ssh_node4 $worker_cmd &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sleep 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo
 | 
				
			||||||
 | 
					echo KUBERNETES INSTALLED! PLEASE FIND BELOW THE ACTIVE NODES AND PODS:
 | 
				
			||||||
 | 
					$ssh_master kubectl get nodes,pods -A
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo You can SSH into the nodes to run kubectl commands:
 | 
				
			||||||
 | 
					cat tmp/*_command
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user