Git Product home page Git Product logo

k8s-device-plugin's Introduction

This is a gerneral kubernetes device plugin. You can realize your device plugin with it very simple.

Features

  • applicable for kuberrnetes 1.10.x
  • publish devices to kubernetes
  • helps to mount device to container
  • restart after kubelet restart, re-build socket
  • custom your behaviour before container start

Requires

  • kubernetes: v1.10.x
  • go: v1.9+

Quick Start

Download

git clone https://github.com/ikaven1024/k8s-device-plugin.git $GOPATH/src/deviceplugin

Create a main.go

package main

import (
	"deviceplugin"
	pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1beta1"
)

func main() {
	update := make(chan []*pluginapi.Device)
	go yourDeviceManager(update)

	conf := deviceplugin.Config{
		ResourceName: "example.com/your-device",
		SocketName:   "your-device.sock",
		Update:       update,
	}
	deviceplugin.Run(conf, nil)
}

Implement your device manager

yourDeviceManager is an implement of your device manager. It accept an go chan, and send all devices to it when devices is changed (added, deleted, or health change). It shall send all of the devices at beginning of manager running.

Config

  • ResourceName (Requied): The name of resource register in kubernetes. The name shall be like yourdomin/name, and your domain shall not be kubernetes.io, whick is reserved.
  • SocketName(Requied): The socket file name. Then /var/lib/kubelet/device-plugins/<your-socket-name>will be created.
  • PreStartFunc(Optional): It is called before each container start if set.
  • AllocateFunc(Optional): Handling acclocation request.

Use of your extended resources

See extended resources for details.

Example

k8s-device-plugin's People

Contributors

ikaven1024 avatar

Stargazers

 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.