mirror of
https://github.com/labring/sealos.git
synced 2026-09-24 15:46:19 +08:00
add sealos ipvs --clean
Signed-off-by: oldthreefeng <louisehong4168@gmail.com>
This commit is contained in:
@@ -26,15 +26,23 @@ var ipvsCmd = &cobra.Command{
|
||||
Use: "ipvs",
|
||||
Short: "sealos create or care local ipvs lb",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if clean {
|
||||
// do clean things
|
||||
|
||||
return
|
||||
}
|
||||
install.Ipvs.VsAndRsCare()
|
||||
},
|
||||
}
|
||||
|
||||
var clean bool
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(ipvsCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
ipvsCmd.Flags().BoolVar(&install.Ipvs.RunOnce, "run-once", false, "is run once mode")
|
||||
ipvsCmd.Flags().BoolVarP(&clean, "clean","c", false, " clean Vip ipvs rule before join node, if Vip has no ipvs rule do nothing.")
|
||||
ipvsCmd.Flags().StringVar(&install.Ipvs.VirtualServer, "vs", "", "virturl server like 10.54.0.2:6443")
|
||||
ipvsCmd.Flags().StringSliceVar(&install.Ipvs.RealServer, "rs", []string{}, "virturl server like 192.168.0.2:6443")
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ func (s *SealosInstaller) JoinNodes() {
|
||||
for _, master := range s.Masters {
|
||||
masters += fmt.Sprintf(" --rs %s:6443", IpFormat(master))
|
||||
}
|
||||
ipvsCleanCmd := "sealos ipvs --clean"
|
||||
ipvsCmd := fmt.Sprintf("sealos ipvs --vs %s:6443 %s --health-path /healthz --health-schem https --run-once", VIP, masters)
|
||||
|
||||
for _, node := range s.Nodes {
|
||||
@@ -157,6 +158,9 @@ func (s *SealosInstaller) JoinNodes() {
|
||||
SSHConfig.CmdToString(node, addRouteCmd, "")
|
||||
}
|
||||
|
||||
// clean Vip ipvs rule before join node, if Vip has no ipvs rule do nothing.
|
||||
_ = SSHConfig.CmdAsync(node, ipvsCleanCmd)
|
||||
|
||||
_ = SSHConfig.CmdAsync(node, ipvsCmd) // create ipvs rules before we join node
|
||||
cmd := s.Command(Version, JoinNode)
|
||||
//create lvscare static pod
|
||||
|
||||
Reference in New Issue
Block a user