From 374f22b8883f26a78f140d685403b22468efc7e8 Mon Sep 17 00:00:00 2001 From: Chris Friesen Date: Tue, 16 Apr 2019 16:00:59 -0400 Subject: [PATCH] Add helm chart for node feature discovery This packages up the upstream "node feature discovery" project[1] into a helm chart and includes it in the ISO. The expectation is that it's there if end-users want to use it, but it will not be installed by default. Rather than make a new RPM, the helm chart has been added to the existing stx-platform-helm package. Unlike the other charts in that package, for now it will be included in the load (to make it available right away). Once the helm charts from that application are properly installed on system installation then we can consider removing the node feature discovery helm chart from the filesystem as it will be available from the local helm repo. There are two primary files describing Kubernetes resources. They both originally came from version 0.3.0 of the upstream project but one of them needed to be renamed to work with "helm package" which restricts the allowable filename suffixes. The two upstream files have been modified to support helm overrides. This also required adding a template for the namespace, if a custom one is specified. [1] https://github.com/kubernetes-sigs/node-feature-discovery/ Change-Id: I6e7c8a629994ad4da3834cbefccb94cd01259cc5 Story: 2005193 Task: 29954 Signed-off-by: Chris Friesen --- .../node-feature-discovery/Chart.yaml | 15 ++++ .../node-feature-discovery/README.rst | 17 +++++ .../templates/namespace.yaml | 14 ++++ .../node-feature-discovery-daemonset.json.tpl | 73 +++++++++++++++++++ .../templates/rbac.yaml | 41 +++++++++++ .../node-feature-discovery/values.yaml | 27 +++++++ .../stx-platform-helm/centos/build_srpm.data | 3 +- .../centos/stx-platform-helm.spec | 4 + 8 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 kubernetes/helm-charts/node-feature-discovery/Chart.yaml create mode 100644 kubernetes/helm-charts/node-feature-discovery/README.rst create mode 100644 kubernetes/helm-charts/node-feature-discovery/templates/namespace.yaml create mode 100644 kubernetes/helm-charts/node-feature-discovery/templates/node-feature-discovery-daemonset.json.tpl create mode 100644 kubernetes/helm-charts/node-feature-discovery/templates/rbac.yaml create mode 100644 kubernetes/helm-charts/node-feature-discovery/values.yaml diff --git a/kubernetes/helm-charts/node-feature-discovery/Chart.yaml b/kubernetes/helm-charts/node-feature-discovery/Chart.yaml new file mode 100644 index 0000000000..eceb438090 --- /dev/null +++ b/kubernetes/helm-charts/node-feature-discovery/Chart.yaml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +apiVersion: v1 +description: Node Feature Discovery +home: https://github.com/kubernetes-sigs/node-feature-discovery +maintainers: +- name: node-feature-discovery Authors +name: node-feature-discovery +sources: +- https://github.com/kubernetes-sigs/node-feature-discovery +version: 0.3.0 diff --git a/kubernetes/helm-charts/node-feature-discovery/README.rst b/kubernetes/helm-charts/node-feature-discovery/README.rst new file mode 100644 index 0000000000..c20b2ba0c9 --- /dev/null +++ b/kubernetes/helm-charts/node-feature-discovery/README.rst @@ -0,0 +1,17 @@ +kubernetes-sigs/node-feature-discovery +====================================== + +This chart runs v0.3.0 of the node-feature-discovery as implemented +at https://github.com/kubernetes-sigs/node-feature-discovery + +This software enables node feature discovery for Kubernetes. It detects +hardware features available on each node in a Kubernetes cluster, and +advertises those features using node labels. + +This chart uses a DaemonSet to spawn a pod on each node in the cluster +to do the actual work. + +The two files under the templates directory are taken directly from +v0.3.0 at the link above. The Docker image specified is the one +published by the upstream team. + diff --git a/kubernetes/helm-charts/node-feature-discovery/templates/namespace.yaml b/kubernetes/helm-charts/node-feature-discovery/templates/namespace.yaml new file mode 100644 index 0000000000..cb8c6ae4d5 --- /dev/null +++ b/kubernetes/helm-charts/node-feature-discovery/templates/namespace.yaml @@ -0,0 +1,14 @@ +{{/* +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +*/}} + +{{ if ne .Values.namespace "default" }} +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace }} +{{ end }} diff --git a/kubernetes/helm-charts/node-feature-discovery/templates/node-feature-discovery-daemonset.json.tpl b/kubernetes/helm-charts/node-feature-discovery/templates/node-feature-discovery-daemonset.json.tpl new file mode 100644 index 0000000000..45b43a53c1 --- /dev/null +++ b/kubernetes/helm-charts/node-feature-discovery/templates/node-feature-discovery-daemonset.json.tpl @@ -0,0 +1,73 @@ +{{/* +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +*/}} + +{ + "apiVersion": "apps/v1", + "kind": "DaemonSet", + "metadata": { + "labels": { + "app": {{ .Values.app_label }} + }, + "namespace": {{ .Values.namespace }}, + "name": {{ .Release.Name }} + }, + "spec": { + "selector": { + "matchLabels": { + "app": {{ .Values.app_label }} + } + }, + "template": { + "metadata": { + "labels": { + "app": {{ .Values.app_label }} + } + }, + "spec": { +{{ if and .Values.node_selector_key .Values.node_selector_value }} + "nodeSelector": { + {{ .Values.node_selector_key }}: {{ .Values.node_selector_value }} + }, +{{ end }} + "hostNetwork": true, + "serviceAccount": {{ .Release.Name }}, + "containers": [ + { + "env": [ + { + "name": "NODE_NAME", + "valueFrom": { + "fieldRef": { + "fieldPath": "spec.nodeName" + } + } + } + ], + "image": "quay.io/kubernetes_incubator/node-feature-discovery:v0.3.0", + "name": {{ .Release.Name }}, + "args": ["--sleep-interval={{ .Values.scan_interval }}s"], + "volumeMounts": [ + { + "name": "host-sys", + "mountPath": "/host-sys" + } + ] + } + ], + "volumes": [ + { + "name": "host-sys", + "hostPath": { + "path": "/sys" + } + } + ] + } + } + } +} diff --git a/kubernetes/helm-charts/node-feature-discovery/templates/rbac.yaml b/kubernetes/helm-charts/node-feature-discovery/templates/rbac.yaml new file mode 100644 index 0000000000..1f0c0e20e8 --- /dev/null +++ b/kubernetes/helm-charts/node-feature-discovery/templates/rbac.yaml @@ -0,0 +1,41 @@ +{{/* +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +*/}} + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Release.Name }} +rules: +- apiGroups: + - "" + resources: + - pods + - nodes + verbs: + - get + - patch + - update +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ .Release.Name }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Release.Name }} +subjects: +- kind: ServiceAccount + name: {{ .Release.Name }} + namespace: {{ .Values.namespace }} diff --git a/kubernetes/helm-charts/node-feature-discovery/values.yaml b/kubernetes/helm-charts/node-feature-discovery/values.yaml new file mode 100644 index 0000000000..4cd4ae8515 --- /dev/null +++ b/kubernetes/helm-charts/node-feature-discovery/values.yaml @@ -0,0 +1,27 @@ +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Default values for node-feature-discovery. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name: value + +# namespace to use for chart resources. Must be specified. +namespace: default + +# label for the daemonset to find its pods +app_label: node-feature-discovery + +# docker image to use for the pods +image: quay.io/kubernetes_incubator/node-feature-discovery:v0.3.0 + +# interval (in secs) to scan the node features +scan_interval: 60 + +# key/value pair to match against node labels to select which nodes +# should run the node feature discovery. Defaults to all nodes. +node_selector_key: +node_selector_value: diff --git a/kubernetes/platform/stx-platform/stx-platform-helm/centos/build_srpm.data b/kubernetes/platform/stx-platform/stx-platform-helm/centos/build_srpm.data index 02d1c5f115..5138d04860 100644 --- a/kubernetes/platform/stx-platform/stx-platform-helm/centos/build_srpm.data +++ b/kubernetes/platform/stx-platform/stx-platform-helm/centos/build_srpm.data @@ -1,7 +1,8 @@ SRC_DIR="stx-platform-helm" COPY_LIST_TO_TAR="\ +$PKG_BASE/../../../helm-charts/node-feature-discovery \ $PKG_BASE/../../../helm-charts/rbd-provisioner \ $PKG_BASE/../../../helm-charts/ceph-pools-audit" -TIS_PATCH_VER=1 +TIS_PATCH_VER=2 diff --git a/kubernetes/platform/stx-platform/stx-platform-helm/centos/stx-platform-helm.spec b/kubernetes/platform/stx-platform/stx-platform-helm/centos/stx-platform-helm.spec index 58fd967d33..7e1b8b9068 100644 --- a/kubernetes/platform/stx-platform/stx-platform-helm/centos/stx-platform-helm.spec +++ b/kubernetes/platform/stx-platform/stx-platform-helm/centos/stx-platform-helm.spec @@ -62,6 +62,7 @@ helm repo add local http://localhost:8879/charts # Make the charts. These produce a tgz file make rbd-provisioner make ceph-pools-audit +make node-feature-discovery # Terminate helm server (the last backgrounded task) kill %1 @@ -93,7 +94,10 @@ rm -fr %{app_staging} %install install -d -m 755 %{buildroot}/%{app_folder} install -p -D -m 755 %{_builddir}/%{app_tarball} %{buildroot}/%{app_folder} +install -d -m 755 ${RPM_BUILD_ROOT}/opt/extracharts +install -p -D -m 755 node-feature-discovery-*.tgz ${RPM_BUILD_ROOT}/opt/extracharts %files %defattr(-,root,root,-) %{app_folder}/* +/opt/extracharts/*