Coder Social home page Coder Social logo

kube-admission-webhook-example's Introduction

Kubernetes Admission Webhook Example

Kubernetes administrators would like to control the level of overcommit and manage container density on nodes, masters can be configured to override the ratio between request and limit set on developer containers.

We can use admission controller to modify/validate pod resource.

Instructions

Step 1/3 enable admissionregistration.k8s.io/v1beta1=true & plugins

The api-server should add config below:

--runtime-config: batch/v2alpha1=true, admissionregistration.k8s.io/v1beta1=true

--enable-admission-plugins: NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota

Step 2/3 Deploy webhook

kubectl apply -f webhook.yaml

Here is an example yaml:

apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingWebhookConfiguration
metadata:
  name: taoge.example.webhook
webhooks:
- name: taoge.example.webhook
  rules:
  - apiGroups:
    - ""
    apiVersions:
    - v1
    operations:
    - CREATE
    resources:
    - pods
  clientConfig:
    url: https://10.8.0.172:8443
    caBundle: ""

Note that the caBundle is base64 encode of pem file.

Step 3/3 Run webhook server

go run main.go will start a really simple http server. It justs receive k8s requests and return ok response.

References

https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/

https://docs.okd.io/latest/architecture/additional_concepts/dynamic_admission_controllers.html

https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/

kube-admission-webhook-example's People

Contributors

yowenter avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.