mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
Initial Commit.
This commit is contained in:
commit
15a4d0ef2e
4 changed files with 95 additions and 0 deletions
1
Dockerfile
Normal file
1
Dockerfile
Normal file
|
@ -0,0 +1 @@
|
|||
FROM golang:onbuild
|
2
README.md
Normal file
2
README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# dbi-iafeature-discovery
|
||||
Research Prototype for IA feature discovery in a Kubernetes cluster. Details on this prototype can be found here: https://goo.gl/e5xe5Q.
|
51
featurelabeling-daemonset.json
Normal file
51
featurelabeling-daemonset.json
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"apiVersion": "extensions/v1beta1",
|
||||
"kind": "DaemonSet",
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"app": "dbi-nodelabel"
|
||||
},
|
||||
"name": "dbi-nodelabel"
|
||||
},
|
||||
"spec": {
|
||||
"template": {
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"app": "dbi-nodelabel"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"env": [
|
||||
{
|
||||
"name": "POD_NAME",
|
||||
"valueFrom": {
|
||||
"fieldRef": {
|
||||
"fieldPath": "metadata.name"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "POD_NAMESPACE",
|
||||
"valueFrom": {
|
||||
"fieldRef": {
|
||||
"fieldPath": "metadata.namespace"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"image": "intelsdi/nodelabels",
|
||||
"name": "nodelabeler",
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "1000m",
|
||||
"memory": "1000Mi"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
41
main.go
Normal file
41
main.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/klauspost/cpuid"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//Setting-up K8S client
|
||||
cli, err := client.NewInCluster()
|
||||
if err != nil {
|
||||
log.Fatalf("Can't Get K8s Client:%v", err)
|
||||
}
|
||||
|
||||
features := cpuid.CPU.Features.Strings()
|
||||
|
||||
podName := os.Getenv("POD_NAME")
|
||||
podns := os.Getenv("POD_NAMESPACE")
|
||||
|
||||
pod, err := cli.Pods(podns).Get(podName)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't Get Pod:%v", err)
|
||||
}
|
||||
|
||||
node, err := cli.Nodes().Get(pod.Spec.NodeName)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't Get Node:%v", err)
|
||||
}
|
||||
|
||||
for _, feature := range features {
|
||||
node.Labels["node.alpha.intel.com/"+feature] = "true"
|
||||
}
|
||||
|
||||
_, err = cli.Nodes().Update(node)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't Update Node:%v", err)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue