Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Allow kiam-agent to not remove rules on the host #253

Merged
merged 1 commit into from
Jun 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cmd/kiam/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ type agentCommand struct {
clientOptions
*http.ServerOptions

iptables bool
hostIP string
hostInterface string
iptables bool
iptablesRemove bool
hostIP string
hostInterface string
}

func (cmd *agentCommand) Bind(parser parser) {
Expand All @@ -49,6 +50,7 @@ func (cmd *agentCommand) Bind(parser parser) {
parser.Flag("whitelist-route-regexp", "Proxy routes matching this regular expression").Default("^$").RegexpVar(&cmd.WhitelistRouteRegexp)

parser.Flag("iptables", "Add IPTables rules").Default("false").BoolVar(&cmd.iptables)
parser.Flag("iptables-remove", "Remove iptables rules at shutdown").Default("true").BoolVar(&cmd.iptablesRemove)
parser.Flag("host", "Host IP address.").Envar("HOST_IP").Required().StringVar(&cmd.hostIP)
parser.Flag("host-interface", "Network interface for pods to configure IPTables.").Default("docker0").StringVar(&cmd.hostInterface)
}
Expand All @@ -63,7 +65,9 @@ func (opts *agentCommand) Run() {
if err != nil {
log.Fatal("error configuring iptables:", err.Error())
}
defer rules.Remove()
if opts.iptablesRemove {
defer rules.Remove()
}
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down