hook
kubernetes admission webhook framework
install
go get github.com/chenhuazhong/hook
demo
package main
import (
"github.com/chenhuazhong/hook/hook"
"github.com/chenhuazhong/hook/service"
"github.com/chenhuazhong/hook/utils"
"k8s.io/apimachinery/pkg/runtime"
"net/http"
)
func main(){
h := service.Default()
h.Validating("/validate", hook.ValidateFun{
ValidateCreate: func(obj runtime.Object) hook.RST {
return hook.RST{
Code: 200,
Result: true,
Message: "ok",
}
},
})
h.Route("/health", func(w *utils.Reponse, r *http.Request) {
w.WriteReponse([]byte("ok"), 200)
})
h.Run("0.0.0.0:8088", "server-cert.pem", "server-key.pem")
}