@@ -28,52 +28,142 @@ import (
28
28
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'UProbe' ? has(self.uprobe) : !has(self.uprobe)",message="uprobe configuration is required when type is uprobe, and forbidden otherwise"
29
29
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'URetProbe' ? has(self.uretprobe) : !has(self.uretprobe)",message="uretprobe configuration is required when type is uretprobe, and forbidden otherwise"
30
30
type BpfApplicationProgram struct {
31
- // name is the name of the function that is the entry point for the BPF
32
- // program
31
+ // name is a required field and is the name of the function that is the entry
32
+ // point for the eBPF program. name must not be an empty string, must not
33
+ // exceed 64 characters in length, must start with alpha characters and must
34
+ // only contain alphanumeric characters.
35
+ // +required
33
36
// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9_]+."
34
37
// +kubebuilder:validation:MinLength=1
35
38
// +kubebuilder:validation:MaxLength=64
36
39
Name string `json:"name"`
37
40
38
- // type specifies the bpf program type
41
+ // type is a required field used to specify the type of the eBPF program. The
42
+ // type dictates which eBPF hook point to use. This is where the eBPF program
43
+ // is executed.
44
+ //
45
+ // Allowed values are:
46
+ // TC, TCX, UProbe, URetProbe, XDP
47
+ //
48
+ // When set to TC, the eBPF program can attach to network devices (interfaces).
49
+ // The program can be attached on either packet ingress or egress, so the
50
+ // program will be called on every incoming or outgoing packet seen by the
51
+ // network device. When using the TC program type, the tc field is required.
52
+ // See tc for more details on TC programs.
53
+ //
54
+ // When set to TCX, the eBPF program can attach to network devices
55
+ // (interfaces). The program can be attached on either packet ingress or
56
+ // egress, so the program will be called on every incoming or outgoing packet
57
+ // seen by the network device. When using the TCX program type, the tcx field
58
+ // is required. See tcx for more details on TCX programs.
59
+ //
60
+ // When set to UProbe, the program can attach in user-space. The UProbe is
61
+ // attached to a binary, library or function name, and optionally an offset in
62
+ // the code. When using the UProbe program type, the uprobe field is required.
63
+ // See uprobe for more details on UProbe programs.
64
+ //
65
+ // When set to URetProbe, the program can attach in user-space.
66
+ // The URetProbe is attached to the return of a binary, library or function
67
+ // name, and optionally an offset in the code. When using the URetProbe
68
+ // program type, the uretprobe field is required. See uretprobe for more
69
+ // details on URetProbe programs.
70
+ //
71
+ // When set to XDP, the eBPF program can attach to network devices (interfaces)
72
+ // and will be called on every incoming packet received by the network device.
73
+ // When using the XDP program type, the xdp field is required. See xdp for more
74
+ // details on XDP programs.
39
75
// +unionDiscriminator
40
76
// +required
41
77
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
42
78
Type EBPFProgType `json:"type"`
43
79
44
- // xdp defines the desired state of the application's XdpPrograms.
80
+ // xdp is an optional field, but required when the type field is set to XDP.
81
+ // xdp defines the desired state of the application's XDP programs. XDP program
82
+ // can be attached to network devices (interfaces) and will be called on every
83
+ // incoming packet received by the network device. The XDP hook point is just
84
+ // after the packet has been received off the wire, but before the Linux kernel
85
+ // has allocated an sk_buff, which is used to pass the packet through the
86
+ // kernel networking stack.
45
87
// +unionMember
46
88
// +optional
47
89
XDP * XdpProgramInfo `json:"xdp,omitempty"`
48
90
49
- // tc defines the desired state of the application's TcPrograms.
91
+ // tc is an optional field, but required when the type field is set to TC. tc
92
+ // defines the desired state of the application's TC programs. TC programs are
93
+ // attached to network devices (interfaces). The program can be attached on
94
+ // either packet ingress or egress, so the program will be called on every
95
+ // incoming or outgoing packet seen by the network device. The TC hook point is
96
+ // in Linux's Traffic Control (tc) subsystem, which is after the Linux kernel
97
+ // has allocated an sk_buff. TCX is newer implementation of TC with enhanced
98
+ // performance and better support for running multiple programs on a given
99
+ // network device. This makes TC useful for packet classification actions.
50
100
// +unionMember
51
101
// +optional
52
102
TC * TcProgramInfo `json:"tc,omitempty"`
53
103
54
- // tcx defines the desired state of the application's TcxPrograms.
104
+ // tcx is an optional field, but required when the type field is set to TCX.
105
+ // tcx defines the desired state of the application's TCX programs. TCX
106
+ // programs are attached to network devices (interfaces). The program can be
107
+ // attached on either packet ingress or egress, so the program will be called
108
+ // on every incoming or outgoing packet seen by the network device. The TCX
109
+ // hook point is in Linux's Traffic Control (tc) subsystem, which is after the
110
+ // Linux kernel has allocated an sk_buff. This makes TCX useful for packet
111
+ // classification actions. TCX is a newer implementation of TC with enhanced
112
+ // performance and better support for running multiple programs on a given
113
+ // network device.
55
114
// +unionMember
56
115
// +optional
57
116
TCX * TcxProgramInfo `json:"tcx,omitempty"`
58
117
59
- // uprobe defines the desired state of the application's UprobePrograms.
118
+ // uprobe is an optional field, but required when the type field is set to
119
+ // UProbe. uprobe defines the desired state of the application's UProbe
120
+ // programs. UProbe programs are user-space probes. A target must be provided,
121
+ // which is the library name or absolute path to a binary or library where the
122
+ // probe is attached. Optionally, a function name can also be provided to
123
+ // provide finer granularity on where the probe is attached. They can be
124
+ // attached at any point in the binary, library or function using the optional
125
+ // offset field. However, caution must be taken when using the offset, ensuring
126
+ // the offset is still in the desired bytecode.
60
127
// +unionMember
61
128
// +optional
62
129
UProbe * UprobeProgramInfo `json:"uprobe,omitempty"`
63
130
64
- // uretprobe defines the desired state of the application's UretprobePrograms.
131
+ // uretprobe is an optional field, but required when the type field is set to
132
+ // URetProbe. uretprobe defines the desired state of the application's
133
+ // URetProbe programs. URetProbe programs are user-space probes. A target must
134
+ // be provided, which is the library name or absolute path to a binary or
135
+ // library where the probe is attached. Optionally, a function name can also be
136
+ // provided to provide finer granularity on where the probe is attached. They
137
+ // are attached to the return point of the binary, library or function, but can
138
+ // be set anywhere using the optional offset field. However, caution must be
139
+ // taken when using the offset, ensuring the offset is still in the desired
140
+ // bytecode.
65
141
// +unionMember
66
142
// +optional
67
143
URetProbe * UprobeProgramInfo `json:"uretprobe,omitempty"`
68
144
}
69
145
70
- // BpfApplicationSpec defines the desired state of BpfApplication
146
+ // spec defines the desired state of the BpfApplication. The BpfApplication
147
+ // describes the set of one or more namespace scoped eBPF programs that should
148
+ // be loaded for a given application and attributes for how they should be
149
+ // loaded. eBPF programs that are grouped together under the same
150
+ // BpfApplication instance can share maps and global data between the eBPF
151
+ // programs loaded on the same Kubernetes Node.
71
152
type BpfApplicationSpec struct {
72
153
BpfAppCommon `json:",inline"`
73
154
74
- // programs is the list of bpf programs in the BpfApplication that should be
75
- // loaded. The application can selectively choose which program(s) to run
76
- // from this list based on the optional attach points provided.
155
+ // programs is a required field and is the list of eBPF programs in a BPF
156
+ // Application CRD that should be loaded in kernel memory. At least one entry
157
+ // is required. eBPF programs in this list will be loaded on the system based
158
+ // the nodeSelector. Even if an eBPF program is loaded in kernel memory, it
159
+ // cannot be triggered until an attachment point is provided. The different
160
+ // program types have different ways of attaching. The attachment points can be
161
+ // added at creation time or modified (added or removed) at a later time to
162
+ // activate or deactivate the eBPF program as desired.
163
+ // CAUTION: When programs are added or removed from the list, that requires all
164
+ // programs in the list to be reloaded, which could be temporarily service
165
+ // effecting. For this reason, modifying the list is currently not allowed.
166
+ // +required
77
167
// +kubebuilder:validation:MinItems:=1
78
168
Programs []BpfApplicationProgram `json:"programs,omitempty"`
79
169
}
@@ -83,7 +173,15 @@ type BpfApplicationSpec struct {
83
173
// +kubebuilder:subresource:status
84
174
// +kubebuilder:resource:scope=Namespaced
85
175
86
- // BpfApplication is the Schema for the bpfapplications API
176
+ // BpfApplication is the schema for the namespace scoped BPF Applications API.
177
+ // Using this API allows applications to load one or more eBPF programs on a
178
+ // Kubernetes cluster using bpfman to load the programs.
179
+ //
180
+ // The bpfApplication.status field reports the overall status of the
181
+ // BpfApplication CRD. A given BpfApplication CRD can result in loading and
182
+ // attaching multiple eBPF programs on multiple nodes, so this status is just a
183
+ // summary. More granular per-node status details can be found in the
184
+ // corresponding BpfApplicationState CRD that bpfman creates for each node.
87
185
// +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeselector`
88
186
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
89
187
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
0 commit comments