mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-04 14:31:03 +02:00
47 lines
888 B
Go
47 lines
888 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"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()
|
|
|
|
pflag.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)
|
|
}
|
|
}
|