Giter Club home page Giter Club logo

k8s-webhook's Introduction

k8s-webhook

A small k8s-webhook, designed to mount a specific configuration in the Pod. Currently supported:

  • Labels
  • Affinity
  • NodeSelector
  • Tolerations

For a review, visit this page: https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/

Step 1: Pre-install

Install on a working machine with Windows Golang, Docker Desktop, make.

https://golang.org/

https://www.docker.com/products/docker-desktop

http://gnuwin32.sourceforge.net/packages/make.htm

Step 2: Build

Run: make docker

Step 3: Deploy

Save the docker image to tar file, distribute to nodes and upload:

docker save -o webhook.tar k8s-webhook:v1

docker load -i webhook.tar

Create a deploy directory and place the following files on the node:

gen-certificates.sh
ca-bundle.sh
deployment.yaml
service.yaml
mutationwebhook.yaml
config.yaml

Make * .sh files executable:

chmod +x

Next, we need to generate certificates that will be used for work. To do this, run the gen-certifictes.sh script.

The mutatingwebhook.yaml file contains a CA_BUNDLE stub, instead of which we need to put the caBundle of k8s cluster. To do this, we will perform transformations using the ca-bundle.sh script:

cat mutatingwebhook.yaml | ./ca-bundle.sh > mutatingwebhook-ca.yaml

Check the new file that caBundle has been added successfully. We are almost ready to deploy webhook, let's look at the deployment files.

Pay attention to volumeMounts and volumes. Here we are mount our secrets and two ConfigsMap's, which describe the logic of which pods and how we will change.

Let's take a closer look at part of the config. As I pointed out in the beginning, this is just an example of how we can manage the webhook based on configuration. In aacc-webhook-coreconfig, we create a mapconfigs.yaml file (hardcoded name), in which we describe which pods need to be changed, the parameters are as follows:

labelKey - the label that the webhook will look for in labels

value - the key value that the webhook will look for. If key and value are the same, a decision is made that the pod will be patched.

file - filename from ConfigMap k8s-webhook-configs containing content to be added.

types - list of configuration types, the webhook can add several types at once if they are supported in the code and content has been created for them. At the moment, the demo version supports Affinity, nodeSelector, toleration.

k8s-webhook's People

Contributors

trixiether avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.