mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-04 22:41:03 +02:00
* package utils unit tests * add tests to travis CI * make push needs IMG_TAG in docker push command
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
_ "net/http/pprof"
|
|
|
|
"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)
|
|
}
|
|
|
|
if config.EnablePprof {
|
|
go func() {
|
|
fmt.Fprintf(os.Stdout, http.ListenAndServe("0.0.0.0:6060", nil).Error())
|
|
}()
|
|
}
|
|
|
|
err = kubeRouter.Run()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Failed to run kube-router: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|