Git Product home page Git Product logo

multus-admission-controller's Introduction

Network attachment definition admission controller

An admission controller to check resources as defined by the Network Plumbing Working Group de-facto CRD specification upon their creation.

This admission controller is aware of some of the aspects of what's required when you create NetworkAttachmentDefinition custom resources, and can report back to the user that those resources are well formatted, to improve their experience.

Getting started

Clone this repository and execute ./hack/webhook-deployment.sh to deploy:

$ ./hack/webhook-deployment.sh

Example of the admission controller in action

If you're to create a NetworkAttachmentDefinition which has something that's out of whack -- in this example malformatted JSON -- you'll get some feedback that something is wrong.

$ cat <<EOF | kubectl create -f -
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: bad-conf
spec:
  config: '{
      "cniVersion": "0.3.0"malFormattedJSON
      }
    }'
EOF
Error from server: error when creating "STDIN": admission webhook "net-attach-def-admission-controller-validating-config.k8s.cni.cncf.io" denied the request: invalid config: error parsing configuration: invalid character 'm' after object key:value pair

If you create a valid NetworkAttachmentDefinition, you'll find that the custom resource is created successfully.

$ cat <<EOF | kubectl create -f -
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: macvlan-conf
spec:
  config: '{
      "cniVersion": "0.3.0",
      "type": "macvlan",
      "master": "eth0",
      "mode": "bridge",
      "ipam": {
        "type": "host-local",
        "subnet": "192.168.1.0/24",
        "rangeStart": "192.168.1.200",
        "rangeEnd": "192.168.1.216",
        "routes": [
          { "dst": "0.0.0.0/0" }
        ],
        "gateway": "192.168.1.1"
      }
    }'
EOF
networkattachmentdefinition.k8s.cni.cncf.io/macvlan-conf created

Collecting metrics with Prometheus

Network attachment definition admission controller comes with following metrics.

  1. No. of instances with k8s.v1.cni.cncf.io/networks annotations
  2. Is cluster enabled with instances annotated with k8s.v1.cni.cncf.io/networks.

To install Prometheus and enable scraping the endpoints , execute ./hack/prometheus-deployment.sh

Metrics details

Building the admission controller

To build the admission controller, ensure it exists in your go path (we recommend you clone it to $GOPATH/src/github.com/k8snetworkplumbingwg/net-attach-def-admission-controller).

While in that directory, simple run:

make

For full installation and troubleshooting steps please see Installation guide.

For developer information, refer to the developer guide.

multus-admission-controller's People

Contributors

aneeshkp avatar deads2k avatar dougbtv avatar openshift-bot avatar openshift-merge-robot avatar przemeklal avatar rkamudhan avatar s1061123 avatar sosiouxme avatar trozet avatar zshi-redhat 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.