1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-14 20:56:42 +00:00

Convert templates and examples from json to yaml (#108)

Convert resource templates from json to yaml

Yaml is easier and less error prone to modify by hand. It also allows
comments which can be especially useful in the templates.
This commit is contained in:
Markus Lehtonen 2018-09-27 14:54:45 +03:00 committed by GitHub
parent f8bea163de
commit 41f9a14a24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 124 additions and 205 deletions

View file

@ -60,7 +60,7 @@ node-feature-discovery.
host mounted inside the NFD container. Thus, you need to provide Docker with the
correct `--volume` options in order for them to work correctly when run
stand-alone directly with `docker run`. See the
[template spec](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery-daemonset.json.template)
[template spec](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery-daemonset.yaml.template)
for up-to-date information about the required volume mounts.
## Feature discovery
@ -197,7 +197,7 @@ example spec that can be used as a template, or, as is when just trying out the
service:
```
kubectl create -f rbac.yaml
kubectl create -f node-feature-discovery-daemonset.json.template
kubectl create -f node-feature-discovery-daemonset.yaml.template
```
When the job runs, it contacts the Kubernetes API server to add labels
@ -206,7 +206,7 @@ to the node to advertise hardware features.
If you have RBAC authorization enabled (as is the default e.g. with clusters initialized with kubeadm) you need to configure the appropriate ClusterRoles, ClusterRoleBindings and a ServiceAccount in order for NFD to create node labels. The provided templates will configure these for you.
When run as a daemonset, nodes are re-labeled at an interval specified using
the `--sleep-interval` option. In the [template](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery-daemonset.json.template#L38) the default interval is set to 60s
the `--sleep-interval` option. In the [template](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery-daemonset.yaml.template#L26) the default interval is set to 60s
which is also the default when no `--sleep-interval` is specified.
Feature discovery can alternatively be configured as a one-shot job. There is
@ -256,7 +256,7 @@ docker push <quay-domain-name>/<registry-user>/<image-name>:<version>
To use your published image from the step above instead of the
`quay.io/kubernetes_incubator/node-feature-discovery` image, edit line 40 in the file
[node-feature-discovery-job.json.template](node-feature-discovery-job.json.template)
[node-feature-discovery-job.yaml.template](node-feature-discovery-job.yaml.template)
to the new location (`<quay-domain-name>/<registry-user>/<image-name>[:<version>]`).
## Targeting Nodes with Specific Features
@ -264,28 +264,19 @@ to the new location (`<quay-domain-name>/<registry-user>/<image-name>[:<version>
Nodes with specific features can be targeted using the `nodeSelector` field. The
following example shows how to target nodes with Intel TurboBoost enabled.
```json
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"labels": {
"env": "test"
},
"name": "golang-test"
},
"spec": {
"containers": [
{
"image": "golang",
"name": "go1",
}
],
"nodeSelector": {
"node.alpha.kubernetes-incubator.io/nfd-pstate-turbo": "true"
}
}
}
```yaml
apiVersion: v1
kind: Pod
metadata:
labels:
env: test
name: golang-test
spec:
containers:
- image: golang
name: go1
nodeSelector:
node.alpha.kubernetes-incubator.io/nfd-pstate-turbo: 'true'
```
For more details on targeting nodes, see [node selection][node-sel].

View file

@ -10,7 +10,7 @@ We wanted to demonstrate how to target nodes with turbo boost using node feature
Our experiment involved running the same application ten times with and without node feature discovery. We use the Ferret benchmark from the PARSEC benchmark suite [[2]][parsec] as our application. The benchmark implements an image similarity search. It is expected to benefit from turbo boost as it is CPU intensive [[3][ref-3], [4][ref-4]].
Without node feature discovery, two-thirds of the application instances will run on nodes without turbo boost and as a result be less-performant. By using feature discovery, we are able to target the node with turbo boost and gain performance. A pod template to express affinity to nodes with turbo boost can be found [here](helper-scripts/demo-pod-with-discovery.json.parsec.template).
Without node feature discovery, two-thirds of the application instances will run on nodes without turbo boost and as a result be less-performant. By using feature discovery, we are able to target the node with turbo boost and gain performance. A pod template to express affinity to nodes with turbo boost can be found [here](helper-scripts/demo-pod-with-discovery.yaml.parsec.template).
The figure below shows box plots that illustrates the variability in normalized execution time of running ten application instances with and without node feature discovery. The execution time of the runs are normalized to the best-performing run and the change in the normalized execution time is shown (0 represents the best performing run). With node feature discovery, under this experimental setup, we can see significant improvement in performance. Moreover, we also reduce the performance variability between different application instances.

View file

@ -1,25 +0,0 @@
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "demo-parsec-NUM"
},
"spec": {
"containers": [
{
"image": "quay.io/kubernetes_incubator/node-feature-discovery-APP",
"name": "demo-container-parsec-NUM",
"ports": [
{
"containerPort": 3351,
"hostPort": 10001
}
]
}
],
"nodeSelector": {
"node.alpha.kubernetes-incubator.io/nfd-pstate-turbo": "true"
},
"restartPolicy": "Never"
}
}

View file

@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: demo-parsec-NUM
spec:
containers:
- image: quay.io/kubernetes_incubator/node-feature-discovery-APP
name: demo-container-parsec-NUM
ports:
- containerPort: 3351
hostPort: 10001
nodeSelector:
node.alpha.kubernetes-incubator.io/nfd-pstate-turbo: 'true'
restartPolicy: Never

View file

@ -1,22 +0,0 @@
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "demo-APP-NUM"
},
"spec": {
"containers": [
{
"image": "quay.io/kubernetes_incubator/node-feature-discovery-IMG",
"name": "demo-container-APP-NUM",
"ports": [
{
"containerPort": 3351,
"hostPort": 10001
}
]
}
],
"restartPolicy": "Never"
}
}

View file

@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: demo-APP-NUM
spec:
containers:
- image: quay.io/kubernetes_incubator/node-feature-discovery-IMG
name: demo-container-APP-NUM
ports:
- containerPort: 3351
hostPort: 10001
restartPolicy: Never

View file

@ -49,8 +49,8 @@ for i in {1..10}
do
if [ "$app" == "parsec" ]
then
sed -e "s/NUM/$i-with-discovery/" -e "s/APP/demo-1/" demo-pod-with-discovery.json.parsec.template > demo-pod-with-discovery.json
kubectl create -f demo-pod-with-discovery.json
sed -e "s/NUM/$i-with-discovery/" -e "s/APP/demo-1/" demo-pod-with-discovery.yaml.parsec.template > demo-pod-with-discovery.yaml
kubectl create -f demo-pod-with-discovery.yaml
else
sed -e "s/NUM/$i-with-discovery/" -e "s/APP/demo-2/" demo-pod-with-discovery.yaml.cloverleaf.template > demo-pod-with-discovery.yaml
kubectl create -f demo-pod-with-discovery.yaml
@ -59,4 +59,4 @@ do
done
echo "Ten pods with node feature discovery enabled started."
rm -f demo-pod-with-discovery.json demo-pod-with-discovery.yaml
rm -f demo-pod-with-discovery.yaml

View file

@ -49,13 +49,13 @@ for i in {1..10}
do
if [ "$app" == "parsec" ]
then
sed -e "s/NUM/$i-wo-discovery/" -e "s/IMG/demo-1/" -e "s/APP/$app/" demo-pod-without-discovery.json.template > demo-pod-without-discovery.json
sed -e "s/NUM/$i-wo-discovery/" -e "s/IMG/demo-1/" -e "s/APP/$app/" demo-pod-without-discovery.yaml.template > demo-pod-without-discovery.yaml
else
sed -e "s/NUM/$i-wo-discovery/" -e "s/IMG/demo-2/" -e "s/APP/$app/" demo-pod-without-discovery.json.template > demo-pod-without-discovery.json
sed -e "s/NUM/$i-wo-discovery/" -e "s/IMG/demo-2/" -e "s/APP/$app/" demo-pod-without-discovery.yaml.template > demo-pod-without-discovery.yaml
fi
kubectl create -f demo-pod-without-discovery.json
kubectl create -f demo-pod-without-discovery.yaml
echo "WithoutDiscovery" >> labels-without-discovery-$app.log
done
echo "Ten pods without node feature discovery started."
rm -f demo-pod-without-discovery.json
rm -f demo-pod-without-discovery.yaml

View file

@ -6,5 +6,5 @@ NumNodes=$(kubectl get nodes | grep -i ' ready ' | wc -l)
# We request a specific hostPort in the job spec to limit the number of pods
# that run on a node to one. As a result, one pod runs on each node in parallel
# We set the NODE_NAME environemnt variable to get the Kubernetes node object.
sed -e "s/COMPLETION_COUNT/$NumNodes/" -e "s/PARALLELISM_COUNT/$NumNodes/" node-feature-discovery-job.json.template > node-feature-discovery-job.json
kubectl create -f node-feature-discovery-job.json
sed -e "s/COMPLETION_COUNT/$NumNodes/" -e "s/PARALLELISM_COUNT/$NumNodes/" node-feature-discovery-job.yaml.template > node-feature-discovery-job.yaml
kubectl create -f node-feature-discovery-job.yaml

View file

@ -1,59 +0,0 @@
{
"apiVersion": "apps/v1",
"kind": "DaemonSet",
"metadata": {
"labels": {
"app": "node-feature-discovery"
},
"name": "node-feature-discovery"
},
"spec": {
"selector": {
"matchLabels": {
"app": "node-feature-discovery"
}
},
"template": {
"metadata": {
"labels": {
"app": "node-feature-discovery"
}
},
"spec": {
"hostNetwork": true,
"serviceAccount": "node-feature-discovery",
"containers": [
{
"env": [
{
"name": "NODE_NAME",
"valueFrom": {
"fieldRef": {
"fieldPath": "spec.nodeName"
}
}
}
],
"image": "quay.io/kubernetes_incubator/node-feature-discovery:v0.3.0",
"name": "node-feature-discovery",
"args": ["--sleep-interval=60s"],
"volumeMounts": [
{
"name": "host-sys",
"mountPath": "/host-sys"
}
]
}
],
"volumes": [
{
"name": "host-sys",
"hostPath": {
"path": "/sys"
}
}
]
}
}
}
}

View file

@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: node-feature-discovery
name: node-feature-discovery
spec:
selector:
matchLabels:
app: node-feature-discovery
template:
metadata:
labels:
app: node-feature-discovery
spec:
hostNetwork: true
serviceAccount: node-feature-discovery
containers:
- env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: quay.io/kubernetes_incubator/node-feature-discovery:v0.3.0
name: node-feature-discovery
args:
- "--sleep-interval=60s"
volumeMounts:
- name: host-sys
mountPath: "/host-sys"
volumes:
- name: host-sys
hostPath:
path: "/sys"

View file

@ -1,63 +0,0 @@
{
"apiVersion": "batch/v1",
"kind": "Job",
"metadata": {
"labels": {
"app": "node-feature-discovery"
},
"name": "node-feature-discovery"
},
"spec": {
"completions": COMPLETION_COUNT,
"parallelism": PARALLELISM_COUNT,
"template": {
"metadata": {
"labels": {
"app": "node-feature-discovery"
}
},
"spec": {
"hostNetwork": true,
"serviceAccount": "node-feature-discovery",
"containers": [
{
"env": [
{
"name": "NODE_NAME",
"valueFrom": {
"fieldRef": {
"fieldPath": "spec.nodeName"
}
}
}
],
"image": "quay.io/kubernetes_incubator/node-feature-discovery:v0.3.0",
"name": "node-feature-discovery",
"args": ["--oneshot"],
"ports": [
{
"containerPort": 7156,
"hostPort": 7156
}
],
"volumeMounts": [
{
"name": "host-sys",
"mountPath": "/host-sys"
}
]
}
],
"restartPolicy": "Never",
"volumes": [
{
"name": "host-sys",
"hostPath": {
"path": "/sys"
}
}
]
}
}
}
}

View file

@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: Job
metadata:
labels:
app: node-feature-discovery
name: node-feature-discovery
spec:
completions: COMPLETION_COUNT
parallelism: PARALLELISM_COUNT
template:
metadata:
labels:
app: node-feature-discovery
spec:
hostNetwork: true
serviceAccount: node-feature-discovery
containers:
- env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: quay.io/kubernetes_incubator/node-feature-discovery:v0.3.0
name: node-feature-discovery
args:
- "--oneshot"
ports:
- containerPort: 7156
hostPort: 7156
volumeMounts:
- name: host-sys
mountPath: "/host-sys"
restartPolicy: Never
volumes:
- name: host-sys
hostPath:
path: "/sys"