Ejemplo n.º 1
0
func main() {
	cl, err := client.NewInCluster()
	if err != nil {
		log.Printf("Error creating Kubernetes client (%s)", err)
		os.Exit(1)
	}

	router := mux.NewRouter()

	deployHandler := handlers.NewDeploy(cl)
	method, path := deployHandler.PathInfo()
	router.Handle(path, deployHandler).Methods(method.String())

	host := os.Getenv(hostEnvVar)
	if host == "" {
		host = defaultHost
	}
	port, err := strconv.Atoi(os.Getenv(portEnvVar))
	if err != nil {
		port = defaultPort
	}
	hostStr := fmt.Sprintf("%s:%d", host, port)
	log.Printf("Serving on %s", hostStr)
	if err := http.ListenAndServe(hostStr, router); err != nil {
		log.Printf("Error serving (%s)", err)
		os.Exit(1)
	}
}
Ejemplo n.º 2
0
// ClientInCluster is a convenience function for calling NewInCluster inside the github.com/jchauncey/kubeclient/client/unversioned package
func ClientInCluster() (kubeclient.Interface, error) {
	return kubeclient.NewInCluster()
}