Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

leemingeer/webhook-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

webhook simple

简介

webhook server关键流程是通过http.Server()对象的Handler串接。当webhook server收到kube-apiserver动态准入控制器发过来的admission review request, 其中的path路由匹配到注册到mux的自定义handler对象, 调用其ServeHttp()来实现。

http包内置了http.Server的Handler实现: NewServeMux(简称mux), 可将多路自定义handler对象(实现ServeHttp方法)注册到mux的api路由中.

mux对外暴露HandleHandleFunc两种方式,

  • Handle方式
    • 将handler注册到mux, 有ServeHttp方法的对象才可以称为handler。
  • HandleFunc方式
    • 将普通函数注册到mux, 一个普通函数当作http的handler的原因是底层适配器将普通函数封装成了handler

本项目使用的是mux.HandleFunc注册方式, Handle注册方式参考:参考:k8s-webhook-example

使用步骤

#!/usr/bin/env bash
实例化webhook模版文件
# make webhook
制作webhook service镜像
# make image
部署webhook
make deploy

测试

create nginx deployment

About

simple webhook helps understanding how webhook works

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /