K8S-HOSTDEV-PLUGIN

command module
v0.0.0-...-53c3602 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2018 License: Apache-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

hostdev device plugin for Kubernetes

Introduction

k8s-hostdev-plugin is a device plugin for Kubernetes to configure devices under host /dev into PODs through device cgroup.

The hostdev binary should be runing on each node and talk with kubelet vai unix sockets under '/var/lib/kubelet/device-plugins/'. This could be achieved by a daemonset which will be explained later.

Build

# make help
# make bin
# make img
# make push

Install on Kubernetes

1. edit the 'containers.[*].args' part of hostdev-plugin-ds.yaml:
      containers:
      - name: hostdev
        args: ["--devs", "/dev/mem:r,/dev/fuse:rwm"]

The above args means 2 devices to be supported:

  • /dev/mem with permission "r"
  • /dev/fuse with permission "rwm"
2. Install the daemonset
# kubectl create -f hostdev-plugin-ds.yaml

check the pods status:

# kubectl -n kube-system get pods
NAME                          READY     STATUS    RESTARTS   AGE
hostdev-device-plugin-2wfhn   1/1       Running   0          25m
hostdev-device-plugin-bzd7w   1/1       Running   0          25m
3. check the device full name to be used in business POD spec
# kubectl get node/$NODE_NAME -o jsonpath='{.status.allocatable}'
map[pods:29 cpu:940m hostdev.k8s.io/dev_mem:1 hostdev.k8s.io/dev_fuse:1 memory:618688Ki]

Notes the full names:

  • hostdev.k8s.io/dev_mem for /dev/mem
  • hostdev.k8s.io/dev_fuse for /dev/fuse

Configure POD spec

apiVersion: v1
kind: Pod
metadata:
  name: ng
spec:
  containers:
    - name: ng
      image: nginx:alpine
      securityContext:
        capabilities:
          add: ["SYS_RAWIO"]
      resources:
        limits:
          hostdev.k8s.io/dev_mem: 1

PODs with such resourece definition will get asigned a /dev/mem device.

TODO

  • dynamic config by ConfigMap

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL