All Projects → slok → k8s-webhook-example

slok / k8s-webhook-example

Licence: Apache-2.0 license
Kubernetes production-ready admission webhook example

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Makefile
30231 projects
Smarty
1635 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to k8s-webhook-example

Nestjs Braintree
A module for braintree reoccurring payments and transactions 💳
Stars: ✭ 62 (-3.12%)
Mutual labels:  webhooks
Faasd
A lightweight & portable faas engine
Stars: ✭ 1,330 (+1978.13%)
Mutual labels:  webhooks
Node Webhooks
↪️ Node.js module to create and trigger your own webHooks.
Stars: ✭ 157 (+145.31%)
Mutual labels:  webhooks
Mattersend
Library and CLI utility to send messages to mattermost's incoming webhooks
Stars: ✭ 68 (+6.25%)
Mutual labels:  webhooks
Webhooks Notifications
Use Plex webhooks to display desktop notifications and control playback with media keys
Stars: ✭ 86 (+34.38%)
Mutual labels:  webhooks
Git Webhook Ci
A Git (github/gitee) webhook callback server to do stuff e.g. fetch new code (poor man CI)
Stars: ✭ 118 (+84.38%)
Mutual labels:  webhooks
Vk2discord
🔧 Автоматическая публикация записей из группы или профиля VK.COM в канал Discord
Stars: ✭ 45 (-29.69%)
Mutual labels:  webhooks
Frappe
Low code web framework for real world applications, in Python and Javascript
Stars: ✭ 3,349 (+5132.81%)
Mutual labels:  webhooks
Achievibit
Github Gamification - Achievements system as a GitHub WebHook.
Stars: ✭ 93 (+45.31%)
Mutual labels:  webhooks
Backport
A simple CLI tool that automates the process of backporting commits on a GitHub repo
Stars: ✭ 154 (+140.63%)
Mutual labels:  webhooks
Frostybot Js
Frostybot-JS is a cryptocurrency trading API endpoint, designed to execute webhook or REST requests as orders on a variety of well-known exchanges. While primarily designed to automate your Tradingview strategies, Frostybot can also be integrated with any other software using webhooks or REST. Bitmex, FTX, Deribit and Binance are supported.
Stars: ✭ 72 (+12.5%)
Mutual labels:  webhooks
Webhook Discord
A simple Javascript file for nicely formatting Discord webhooks
Stars: ✭ 81 (+26.56%)
Mutual labels:  webhooks
Unpackerr
Extracts downloads for Radarr, Sonarr, Lidarr - Deletes extracted files after import
Stars: ✭ 122 (+90.63%)
Mutual labels:  webhooks
Auto Reply
➿ Handle GitHub webhooks and manage issues on your repositories. Currently runs @jekyllbot.
Stars: ✭ 62 (-3.12%)
Mutual labels:  webhooks
Goplaxt
Scrobble Plex plays to Trakt with ease!
Stars: ✭ 183 (+185.94%)
Mutual labels:  webhooks
Shield
The core shield package.
Stars: ✭ 60 (-6.25%)
Mutual labels:  webhooks
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (+75%)
Mutual labels:  webhooks
Twitch
Interact with Twitch's API, chat, PubSub and subscribe to WebHooks.
Stars: ✭ 237 (+270.31%)
Mutual labels:  webhooks
Tradingview Webhooks Bot
a bot that can execute trades based on tradingview webhook alerts!
Stars: ✭ 184 (+187.5%)
Mutual labels:  webhooks
Webhooks Home Automation
Use Plex webhooks to control lighting in your home
Stars: ✭ 137 (+114.06%)
Mutual labels:  webhooks

k8s-webhook-example

A production ready Kubernetes admission webhook example using Kubewebhook.

The example tries showing these:

  • How to set up a production ready Kubernetes admission webhook.
    • Clean and decouple structure.
    • Metrics.
    • Gracefull shutdown.
    • Testing webhooks.
  • Serve multiple webhooks on the same application.
  • Mutating and validating webhooks with different use cases (check Webhooks section).

Structure

The application is mainly structured in 3 parts:

  • main: This is where everything is created, wired, configured and set up, cmd/k8s-webhook-example.
  • http: This is the package that configures the HTTP server, wires the routes and the webhook handlers. internal/http/webhook.
  • Application services: These services have the domain logic of the validators and mutators:

Apart from the webhook refering stuff we have other parts like:

And finally there is an example of how we could deploy our webhooks on a production server:

Webhooks

all-mark-webhook.slok.dev

  • Webhook type: Mutating.
  • Resources affected: deployments, daemonsets, cronjobs, jobs, statefulsets, pods

This webhooks shows how to add a label to all the specified types in a generic way.

We use dynamic webhooks without the requirement to know what type of objects we are dealing with. This is becase all the types implement metav1.Object interface that accesses to the metadata of the object. In this case our domain logic doesn't need to know what type is.

ingress-validation-webhook.slok.dev

  • Webhook type: Validating.
  • Resources affected: Ingresses.

This webhook has a chain of validation on ingress objects, it is composed of 2 validations:

  • Check an ingress has a single host/rule.
  • Check an ingress host matches specific regexes.

This webhook shows two things:

First, shows how to create a chain of validations for a single webhook handler.

Second, it shows how to deal with specific types of resources in different group/versions, for this it uses a dynamic webhook (like all-mark-webhook.slok.dev) but this instead, typecasts to the specific types, in this case, the webhook validates all available ingresses, specifically extensions/v1beta1 and networking.k8s.io/v1beta1.

service-monitor-safer.slok.dev

  • Webhook type: Mutating.
  • Resources affected: ServiceMonitors (monitoring.coreos.com/v1) CRD.

This webhook show two things.

  • Working with CRDs, in this case mutating them.
  • Working with Static webhooks (specific type).

This webhook takes Prometheus monitoring.coreos.com/v1/servicemonitors CRs and sets safe scraping intervals, it checks the interval and in case is missing or is less that the minimum configured it will mutate the CR to set the minimum scrape interval.

This will show us how to deal with CRDs in webhooks, and also how we can make static webhooks to only work safely in a specific resource type.

The static webhooks are specially important on resources that are not known, these are:

  • CRDs.
  • Core resources that are on the cluster but not on the webhook libraries, because of Kubernetes different versions (new types and deprecations from version to version).

If we use dynamic webhook on unknown types by our webhook app, we will deal with runtime.Unstructured, this is not bad and is safe, it would add complexity to mutate/validate these objects, although for mutating/validating metadata fields (e.g labels), is easy and simple.

That said, most webhooks can/should use dynamic type webhooks because are common resources, like ingress-validation-webhook.slok.dev, all-mark-webhook.slok.dev, that use dynamic webhooks correctly.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].