Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"flag"
"fmt"
"k8s.io/client-go/kubernetes"
"os"
"path/filepath"
"runtime"
log "github.com/golang/glog"
k8s "github.com/mayadata-io/litmus-manager/pkg/kubernetes"
"github.com/mayadata-io/litmus-manager/pkg/litmus"
"github.com/mayadata-io/litmus-manager/router"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/tools/clientcmd"
)
// Constant to define the port number
const (
Port = ":3000"
)
func printVersion() {
log.Info(fmt.Sprintf("Go Version: %s", runtime.Version()))
log.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
}
func main() {
// send logs to stderr so we can use 'kubectl logs'
_ = flag.Set("logtostderr", "true")
_ = flag.Set("v", "3")
var kubeconfig string
kubeconfig = filepath.Join(os.Getenv("HOME"), ".kube","config")
// use the current context in kubeconfig
restConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
panic(err.Error())
}
k8s.RestConfig = restConfig
// create the clientset
clientSet, err := kubernetes.NewForConfig(restConfig)
if err != nil {
panic(err.Error())
}
flag.Parse()
// Version Info
printVersion()
// Creating new routes
route := router.New()
// Create rest config
//restConfig, err := k8s.NewRestConfig()
//if err != nil {
// log.Fatalf("Failed to create rest config: %v", err)
// return
//}
//k8s.RestConfig = restConfig
// Create k8s clientset
//clientSet, err := k8s.NewClientSet(k8s.RestConfig)
//if err != nil {
// log.Fatalf("Failed to create kubernetes client: %v", err)
// return
//}
k8s.ClientSet = clientSet
chaosClientSet, err := litmus.NewClientSet(restConfig)
if err != nil {
log.Fatalf("Failed to create chaos client: %v", err)
return
}
litmus.ClientSet = chaosClientSet
log.Fatal(route.Run(Port))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.