generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This Patch expands the nodeFeatureDiscovery CRD to enable users to define the Operand image provenance regirsty/image:version as well as the imaePullPolicy, that by default has been set to "Always" Also now the nodeFeatureDiscovery CRD holds the binaryData for the NFD-Worker configuration file, allowing users to define the desired nfd-worker.conf by editing the CR. To achieve this we move the api from v1alpha1 to v1 and extend the CRD and the controller to watch for the updated resources. extra: go mod tidy removed 2 non needed deps from go.mod Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
- Loading branch information
1 parent
ad82d0f
commit 6ef0a3b
Showing
16 changed files
with
444 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
apiVersion: nfd.kubernetes.io/v1alpha1 | ||
apiVersion: nfd.kubernetes.io/v1 | ||
kind: NodeFeatureDiscovery | ||
metadata: | ||
name: nfd-master-server | ||
namespace: REPLACE_NAMESPACE | ||
spec: | ||
namespace: node-feature-discovery-operator | ||
image: k8s.gcr.io/nfd/node-feature-discovery:v0.6.0 | ||
operand: | ||
namespace: node-feature-discovery-operator | ||
image: node-feature-discovery | ||
repository: k8s.gcr.io/nfd | ||
version: v0.6.0 | ||
imagePullPolicy: Always | ||
nfd-worker: | ||
config: | | ||
#sources: | ||
# pci: | ||
# deviceClassWhitelist: | ||
# - "0200" | ||
# - "03" | ||
# - "12" | ||
# deviceLabelFields: | ||
# - "class" | ||
# - "vendor" | ||
# - "device" | ||
# - "subsystem_vendor" | ||
# - "subsystem_device" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package v1 contains API Schema definitions for the nfd v1 API group | ||
// +k8s:deepcopy-gen=package,register | ||
// +groupName=nfd.kubernetes.io | ||
package v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package v1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// NodeFeatureDiscoverySpec defines the desired state of NodeFeatureDiscovery | ||
// +k8s:openapi-gen=true | ||
type NodeFeatureDiscoverySpec struct { | ||
Operand OperandSpec `json:"operand"` | ||
Config ConfigSpec `json:"nfd-worker"` | ||
} | ||
|
||
// OperandSpec describes configuration options for the operand | ||
type OperandSpec struct { | ||
// +kubebuilder:validation:Pattern=[a-zA-Z0-9\.\-\/]+ | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// +kubebuilder:validation:Pattern=[a-zA-Z0-9\.\-\/]+ | ||
Repository string `json:"repository,omitempty"` | ||
|
||
// +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ | ||
Image string `json:"image,omitempty"` | ||
|
||
// +kubebuilder:validation:Pattern=[a-zA-Z0-9\.-]+ | ||
Version string `json:"version,omitempty"` | ||
|
||
// Image pull policy | ||
// +kubebuilder:validation:Optional | ||
ImagePullPolicy string `json:"imagePullPolicy,omitempty"` | ||
} | ||
|
||
// ConfigSpec describes configuration options for the NFD worker | ||
type ConfigSpec struct { | ||
// BinaryData holds the NFD configuration file | ||
BinaryData string `json:"config"` | ||
} | ||
|
||
// NodeFeatureDiscoveryStatus defines the observed state of NodeFeatureDiscovery | ||
// +k8s:openapi-gen=true | ||
type NodeFeatureDiscoveryStatus struct{} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// NodeFeatureDiscovery is the Schema for the nodefeaturediscoveries API | ||
// +k8s:openapi-gen=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:path=nodefeaturediscoveries,scope=Namespaced | ||
type NodeFeatureDiscovery struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NodeFeatureDiscoverySpec `json:"spec,omitempty"` | ||
Status NodeFeatureDiscoveryStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// NodeFeatureDiscoveryList contains a list of NodeFeatureDiscovery | ||
type NodeFeatureDiscoveryList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NodeFeatureDiscovery `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NodeFeatureDiscovery{}, &NodeFeatureDiscoveryList{}) | ||
} | ||
|
||
// ImagePath returns a compiled full valid image string | ||
func (o *OperandSpec) ImagePath() string { | ||
return o.Repository + "/" + o.Image + ":" + o.Version | ||
} | ||
|
||
// ImagePolicy returns a valid corev1.PullPolicy from the string in the CR | ||
func (o *OperandSpec) ImagePolicy(pullPolicy string) corev1.PullPolicy { | ||
var imagePullPolicy corev1.PullPolicy | ||
switch pullPolicy { | ||
case "Always": | ||
imagePullPolicy = corev1.PullAlways | ||
case "Never": | ||
imagePullPolicy = corev1.PullNever | ||
case "IfNotPresent": | ||
imagePullPolicy = corev1.PullIfNotPresent | ||
default: | ||
imagePullPolicy = corev1.PullIfNotPresent | ||
} | ||
return imagePullPolicy | ||
} | ||
|
||
// Data returns a valid ConfigMap name | ||
func (c *ConfigSpec) Data() string { | ||
return c.BinaryData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pis/nfd/v1alpha1/zz_generated.deepcopy.go → pkg/apis/nfd/v1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.