Skip to content

Commit

Permalink
feat: subcommand flush
Browse files Browse the repository at this point in the history
Signed-off-by: kwanhur <[email protected]>
  • Loading branch information
kwanhur committed Mar 20, 2022
1 parent 97080c4 commit f82c99a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- ipvsctl sub-command `daemon`, `local-address`, `connection`
- ipvsctl sub-command `daemon`, `flush`, `local-address`, `connection`
- support import from stdin, compatible with ipvsadm dump format

## [v1.0.0] - 2022-03-19
Expand Down
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A modern Linux Virtual Server controller.

## Description

`ipvsctl` is similar to `ipvsadm`, `ipvsctl` support multiple modern operations, include sub-commands `service`, `server`, `timeout`, `zero`, `daemon`.
`ipvsctl` is similar to `ipvsadm`, `ipvsctl` support multiple modern operations, include sub-commands `service`, `server`, `timeout`, `daemon`, `zero`, `flush`.

## Commands

Expand All @@ -54,6 +54,7 @@ AUTHOR:

COMMANDS:
zero, z Zero ipvs all the virtual service stats(byte packet and rate counters)
flush, f, clear Flush out the virtual server table
service, s, svc, vs Operates virtual service[vip:vport protocol] (TCP UDP STCP)/(IPv4 IPv6)
server, ser, svr, d, dst, dest, destination, rs, realserver Operates real server[rip:rport] (IPv4/IPv6)
timeout, t, to, out Operates timeout (tcp tcpfin udp)
Expand Down Expand Up @@ -88,7 +89,7 @@ COMMANDS:
update, u, up Update ipvs virtual service
del, d, delete Del ipvs virtual service
zero, z Zero ipvs virtual server stats(byte packet and rate counters)
flush, f, clear Flush ipvs, all the rules will be clear
flush, f, clear Flush out the virtual server table
help, h Shows a list of commands or help for one command

OPTIONS:
Expand Down Expand Up @@ -469,6 +470,23 @@ OPTIONS:
--help, -h show help (default: false)
```

### Flush

It's used to clear out the virtual server table.

```shell
./ipvsctl flush -h
NAME:
ipvsctl flush - Flush out the virtual server table

USAGE:
ipvsctl flush [command options] [arguments...]

OPTIONS:
--yes, --force, -f, -y Are you agree to do it?[yes/no] (default: false)
--help, -h show help (default: false)
```

### Daemon

The connection synchronization daemon is implemented inside the Linux kernel. The master daemon running at the primary load balancer multicasts changes of
Expand Down Expand Up @@ -532,7 +550,7 @@ OPTIONS:
--help, -h show help (default: false)
```

#### Del Daemon
#### Delete Daemon

Stop the connection synchronization daemon.

Expand Down
10 changes: 9 additions & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ func (o *Operator) BasicCommands() []*cli.Command {
Action: o.Zero(),
Flags: flags,
},
{
Name: "flush",
Aliases: []string{"f", "clear"},
Usage: "Flush out the virtual server table",
Action: o.FlushService(),
Flags: flags,
},
}
}

Expand Down Expand Up @@ -186,8 +193,9 @@ func (o *Operator) ServiceCommands() []*cli.Command {
{
Name: "flush",
Aliases: []string{"f", "clear"},
Usage: "Flush ipvs, all the rules will be clear",
Usage: "Flush out the virtual server table",
Action: o.FlushService(),
Flags: flags,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (o *Operator) ZeroService() cli.ActionFunc {
}
}

// FlushService clear out all of the Linux virtual table
// FlushService clear out all the Linux virtual table
func (o *Operator) FlushService() cli.ActionFunc {
return func(c *cli.Context) error {
o.ctx = c
Expand Down

0 comments on commit f82c99a

Please sign in to comment.