移除 haproxy
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build Docker Image / Explore-Gitea-Actions (push) Successful in 10s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build Docker Image / Explore-Gitea-Actions (push) Successful in 10s
				
			This commit is contained in:
		
							parent
							
								
									1f25ee25d6
								
							
						
					
					
						commit
						5ee6680288
					
				
							
								
								
									
										50
									
								
								init-k8s.sh
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								init-k8s.sh
									
									
									
									
									
								
							| @ -128,7 +128,7 @@ if ! echo "$masters" | grep -qw "$current_ip"; then | |||||||
|   exit 0 |   exit 0 | ||||||
| fi | fi | ||||||
| # 安装 keepalived haproxy | # 安装 keepalived haproxy | ||||||
| apt install -y keepalived haproxy | apt install -y keepalived | ||||||
| # 检查是否为 Master-01 | # 检查是否为 Master-01 | ||||||
| first_master=$(echo $masters | cut -d',' -f1) | first_master=$(echo $masters | cut -d',' -f1) | ||||||
| if [ "$current_ip" == "$first_master" ]; then | if [ "$current_ip" == "$first_master" ]; then | ||||||
| @ -156,54 +156,6 @@ sudo systemctl restart keepalived | |||||||
| systemctl status keepalived & | systemctl status keepalived & | ||||||
| echo "初始化 master VIP $current_ip 成功" | echo "初始化 master VIP $current_ip 成功" | ||||||
| 
 | 
 | ||||||
| # 初始化 haproxy |  | ||||||
| IFS=',' read -r -a master_ips <<< "$masters" |  | ||||||
| backend_config="" |  | ||||||
| for ((i=0; i<${#master_ips[@]}; i++)); do |  | ||||||
|     backend_config+="    server master-$((i+1)) ${master_ips[$i]}:6444 check"$'\n' |  | ||||||
| done |  | ||||||
| mkdir -p /usr/local/haproxy |  | ||||||
| cat <<EOF | sudo tee /etc/haproxy/haproxy.cfg |  | ||||||
| global |  | ||||||
|     log 127.0.0.1 local0 notice |  | ||||||
|     maxconn 10000 |  | ||||||
|     chroot /usr/local/haproxy |  | ||||||
|     user haproxy |  | ||||||
|     group haproxy |  | ||||||
|     daemon |  | ||||||
|     # ssl 优化 |  | ||||||
|     tune.ssl.default-dh-param 2048 |  | ||||||
|     tune.bufsize 32768 |  | ||||||
| 
 |  | ||||||
| # 默认配置 |  | ||||||
| defaults |  | ||||||
|     log global |  | ||||||
|     option  httplog |  | ||||||
|     option  dontlognull |  | ||||||
|         timeout connect 5000 |  | ||||||
|         timeout client 50000 |  | ||||||
|         timeout server 50000 |  | ||||||
| 
 |  | ||||||
| frontend k8s-api |  | ||||||
|     bind *:6443 |  | ||||||
|     mode tcp |  | ||||||
|     option tcplog |  | ||||||
|     default_backend k8s-api-backend |  | ||||||
| 
 |  | ||||||
| backend k8s-api-backend |  | ||||||
|     mode tcp |  | ||||||
|     option tcp-check |  | ||||||
|     balance roundrobin |  | ||||||
|     default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100 |  | ||||||
| $backend_config |  | ||||||
| EOF |  | ||||||
| groupadd -r haproxy || echo "用户组已存在" |  | ||||||
| useradd -r -g haproxy -s /sbin/nologin haproxy || echo "用户已存在" |  | ||||||
| sudo systemctl restart keepalived && sudo systemctl restart haproxy |  | ||||||
| systemctl status haproxy & |  | ||||||
| echo "初始化 master haproxy $current_ip 成功" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| if [ "$current_ip" != "$first_master" ]; then | if [ "$current_ip" != "$first_master" ]; then | ||||||
|   echo "初始化 master $current_ip 成功" |   echo "初始化 master $current_ip 成功" | ||||||
|   exit 0 |   exit 0 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user