forked from cloudnativelabs/kube-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkube-router.go
52 lines (40 loc) · 1022 Bytes
/
kube-router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"os"
"flag"
"github.com/cloudnativelabs/kube-router/app"
"github.com/cloudnativelabs/kube-router/app/options"
"github.com/spf13/pflag"
)
func main() {
config := options.NewKubeRouterConfig()
config.AddFlags(pflag.CommandLine)
pflag.Parse()
// Workaround for this issue:
// https://github.com/kubernetes/kubernetes/issues/17162
flag.CommandLine.Parse([]string{})
flag.Set("logtostderr", "true")
if config.HelpRequested {
pflag.Usage()
os.Exit(0)
}
if os.Geteuid() != 0 {
fmt.Fprintf(os.Stderr, "kube-router needs to be run with privileges to execute iptables, ipset and configure ipvs\n")
os.Exit(1)
}
if config.CleanupConfig {
app.CleanupConfigAndExit()
os.Exit(0)
}
kubeRouter, err := app.NewKubeRouterDefault(config)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to parse kube-router config: %v\n", err)
os.Exit(1)
}
err = kubeRouter.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to run kube-router: %v\n", err)
os.Exit(1)
}
}