-
Notifications
You must be signed in to change notification settings - Fork 5
/
onload_types.go
214 lines (172 loc) · 7.38 KB
/
onload_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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: (c) Copyright 2023 Advanced Micro Devices, Inc.
package v1alpha1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// NOTE: Update sample properties in:
// - config/samples/onload/base/onload_v1alpha1_onload.yaml
// - config/samples/onload/overlays/in-cluster-build-ocp/patch-onload.yaml
// Currently unimplemented
type SFCSpec struct {
}
// BuildArg represents a build argument used when building a container image.
type BuildArg struct {
Name string `json:"name"`
Value string `json:"value"`
}
// Build is a subset of the build options presented by the Kernel Module
// Management operator.
type OnloadKernelBuild struct {
// +optional
// BuildArgs is an array of build variables that are provided to the image building backend.
BuildArgs []BuildArg `json:"buildArgs"`
// ConfigMap that holds Dockerfile contents
DockerfileConfigMap *v1.LocalObjectReference `json:"dockerfileConfigMap"`
}
type OnloadKernelMapping struct {
// Regexp is a regular expression that is used to match against the kernel
// versions of the nodes in the cluster. Use also in place of literal strings.
Regexp string `json:"regexp"`
// KernelModuleImage is the image that contains the out-of-tree kernel
// modules used by Onload. Absent image tags may be built by KMM.
KernelModuleImage string `json:"kernelModuleImage"`
// +optional
// SFC optionally specifies that the controller will manage the SFC
// kernel module. Incompatible with boot-time loading approaches.
SFC *SFCSpec `json:"sfc,omitempty"`
// +optional
// Build specifies the parameters that are to be passed to the Kernel Module
// Management operator when building the images that contain the module.
// The build process creates a new image which will be written to the
// location specified by the `KernelModuleImage` parameter.
// If empty, no builds will take place.
Build *OnloadKernelBuild `json:"build,omitempty"`
}
// OnloadSpec defines the desired state of Onload
type OnloadSpec struct {
// KernelMappings is a list of pairs of kernel versions and container
// images. This allows for flexibility when there are heterogenous kernel
// versions on the nodes in the cluster.
KernelMappings []OnloadKernelMapping `json:"kernelMappings"`
// UserImage is the image that contains the built userland objects, used
// within the Onload Device Plugin DaemonSet.
UserImage string `json:"userImage"`
// Version string to associate with this Onload CR.
Version string `json:"version"`
// +optional
// ImagePullPolicy is the policy used when pulling images.
// More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
// +optional
// ControlPlane allows fine-tuning of the Onload control plane server.
ControlPlane *ControlPlaneSpec `json:"controlPlane,omitempty"`
}
type ControlPlaneSpec struct {
// +optional
// Parameters is an optional list of parameters passed to the Onload
// control plane server when launched by the Onload kernel module.
// +kubebuilder:default:={"-K"}
Parameters []string `json:"parameters"`
}
// Currently unimplemented
// +kubebuilder:validation:XValidation:message="SetPreload and MountOnload mutually exclusive",rule="!(self.setPreload && self.mountOnload)"
type DevicePluginSpec struct {
// +optional
// ImagePullPolicy is the policy used when pulling images.
// More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
// +optional
// MaxPodsPerNode is the number of Kubernetes devices that the Onload
// Device Plugin should register with the kubelet. Notionally this is
// equivalent to the number of pods that can request an Onload resource on
// each node.
// +kubebuilder:default:=100
MaxPodsPerNode *int `json:"maxPodsPerNode,omitempty"`
// +optional
// Preload determines whether the Onload Device Plugin will set LD_PRELOAD
// for pods using Onload.
// Mutually exclusive with MountOnload
// +kubebuilder:default:=true
SetPreload *bool `json:"setPreload,omitempty"`
// +optional
// MountOnload is used by the Onload Device Plugin to decide whether to
// mount the `onload` script as a file in the container's filesystem.
// `onload` is mounted at `<baseMountPath>/<binMountpath>`
// Mutually exclusive with Preload
// +kubebuilder:default:=false
MountOnload *bool `json:"mountOnload,omitempty"`
// +optional
// HostOnloadPath is the base location of Onload files on the host
// filesystem.
// +kubebuilder:default=/opt/onload/
HostOnloadPath *string `json:"hostOnloadPath,omitempty"`
// +optional
// BaseMountPath is a prefix to be applied to all Onload file mounts in the
// container's filesystem.
// +kubebuilder:default=/opt/onload
BaseMountPath *string `json:"baseMountPath,omitempty"`
// +optional
// BinMountPath is the location to mount Onload binaries in the container's
// filesystem.
// +kubebuilder:default=/usr/bin
BinMountPath *string `json:"binMountPath,omitempty"`
// +optional
// LibMountPath is the location to mount Onload libraries in the container's
// filesystem.
// +kubebuilder:default=/usr/lib64
LibMountPath *string `json:"libMounthPath,omitempty"`
}
// Spec is the top-level specification for Onload and related products that are
// controlled by the Onload Operator
type Spec struct {
// Onload is the specification of the version of Onload to be used by this
// CR
Onload OnloadSpec `json:"onload"`
// DevicePlugin is further specification for the Onload Device Plugin which
// uses the device plugin framework to provide an `amd.com/onload` resource.
// Image location is not configured here; see Onload Operator deployment.
DevicePlugin DevicePluginSpec `json:"devicePlugin"`
// Selector defines the set of nodes that this Onload CR will run on.
Selector map[string]string `json:"selector"`
// ServiceAccountName is the name of the service account that the objects
// created by the Onload Operator will use.
ServiceAccountName string `json:"serviceAccountName"`
}
// OnloadStatus defines the observed state of Onload
type OnloadStatus struct {
}
type DevicePluginStatus struct {
}
// Status contains the statuses for Onload and related products that are
// controlled by the Onload Operator
type Status struct {
// Conditions store the status conditions of Onload
// +operator-sdk:csv:customresourcedefinitions:type=status
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
// Status of Onload components
Onload OnloadStatus `json:"onload"`
// Status of Onload Device Plugin
DevicePlugin DevicePluginStatus `json:"devicePlugin"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// Onload is the Schema for the onloads API
type Onload struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec Spec `json:"spec,omitempty"`
Status Status `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// OnloadList contains a list of Onload
type OnloadList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Onload `json:"items"`
}
func init() {
SchemeBuilder.Register(&Onload{}, &OnloadList{})
}