generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 29
/
nodefeaturediscovery_types.go
147 lines (121 loc) · 4.81 KB
/
nodefeaturediscovery_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
Copyright 2021. The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
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 {
// +optional
Operand OperandSpec `json:"operand"`
// Deploy the NFD-Topology-Updater
// NFD-Topology-Updater is a daemon responsible for examining allocated
// resources on a worker node to account for resources available to be
// allocated to new pod on a per-zone basis
// https://kubernetes-sigs.github.io/node-feature-discovery/v0.10/get-started/introduction.html#nfd-topology-updater
// +optional
TopologyUpdater bool `json:"topologyUpdater"`
// Instance name. Used to separate annotation namespaces for
// multiple parallel deployments.
// +optional
Instance string `json:"instance"`
// ExtraLabelNs defines the list of of allowed extra label namespaces
// By default, only allow labels in the default `feature.node.kubernetes.io` label namespace
// +nullable
// +kubebuilder:validation:Optional
ExtraLabelNs []string `json:"extraLabelNs,omitempty"`
// ResourceLabels defines the list of features
// to be advertised as extended resources instead of labels.
// +nullable
// +kubebuilder:validation:Optional
ResourceLabels []string `json:"resourceLabels,omitempty"`
// LabelWhiteList defines a regular expression
// for filtering feature labels based on their name.
// Each label must match against the given reqular expression in order to be published.
// +nullable
// +kubebuilder:validation:Optional
LabelWhiteList string `json:"labelWhiteList,omitempty"`
// WorkerConfig describes configuration options for the NFD
// worker.
// +optional
WorkerConfig ConfigMap `json:"workerConfig"`
}
// OperandSpec describes configuration options for the operand
type OperandSpec struct {
// Image defines the image to pull for the
// NFD operand
// [defaults to k8s.gcr.io/nfd/node-feature-discovery]
// +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+
Image string `json:"image,omitempty"`
// ImagePullPolicy defines Image pull policy for the
// NFD operand image [defaults to Always]
// +kubebuilder:validation:Optional
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
// ServicePort specifies the TCP port that nfd-master
// listens for incoming requests.
// +kubebuilder:validation:Optional
ServicePort int `json:"servicePort"`
}
// ConfigMap describes configuration options for the NFD worker
type ConfigMap struct {
// BinaryData holds the NFD configuration file
ConfigData string `json:"configData"`
}
// NodeFeatureDiscoveryStatus defines the observed state of NodeFeatureDiscovery
// +k8s:openapi-gen=true
type NodeFeatureDiscoveryStatus struct {
// Conditions represents the latest available observations of current state.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=nodefeaturediscoveries,scope=Namespaced
// NodeFeatureDiscovery is the Schema for the nodefeaturediscoveries API
type NodeFeatureDiscovery struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NodeFeatureDiscoverySpec `json:"spec,omitempty"`
Status NodeFeatureDiscoveryStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// +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.Image
}
// ImagePolicy returns a valid corev1.PullPolicy from the string in the CR
func (o *OperandSpec) ImagePolicy(pullPolicy string) corev1.PullPolicy {
switch corev1.PullPolicy(pullPolicy) {
case corev1.PullAlways:
return corev1.PullAlways
case corev1.PullNever:
return corev1.PullNever
}
return corev1.PullIfNotPresent
}
// Data returns a valid ConfigMap name
func (c *ConfigMap) Data() string {
return c.ConfigData
}