add sealos ipvs --clean

Signed-off-by: oldthreefeng <louisehong4168@gmail.com>
This commit is contained in:
oldthreefeng
2020-12-23 22:56:48 +08:00
parent 113605b27a
commit 9a36d8ccf4
2 changed files with 12 additions and 0 deletions
+8
View File
@@ -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")
+4
View File
@@ -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