Skip to content

Commit 3f285c0

Browse files
committed
api review: update field descriptions
As part of the API review, a comment was made to improve the description of all fields. This commit makes a pass at the ClusterBpfApplication, BpfApplication, ClusterBpfApplicationState and BpfApplicationState CRD fields. Signed-off-by: Billy McFall <[email protected]>
1 parent d749d10 commit 3f285c0

27 files changed

+4337
-1635
lines changed

apis/v1alpha1/bpf_application_state_types.go

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"sigs.k8s.io/controller-runtime/pkg/client"
2323
)
2424

25-
// BpfApplicationProgramState defines the desired state of BpfApplication
2625
// +union
2726
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'XDP' ? has(self.xdp) : !has(self.xdp)",message="xdp configuration is required when type is xdp, and forbidden otherwise"
2827
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'TC' ? has(self.tc) : !has(self.tc)",message="tc configuration is required when type is tc, and forbidden otherwise"
@@ -32,54 +31,96 @@ import (
3231
type BpfApplicationProgramState struct {
3332
BpfProgramStateCommon `json:",inline"`
3433

35-
// type specifies the bpf program type
34+
// type specifies the provisioned eBPF program type for this program entry.
35+
// Type will be one of:
36+
// TC, TCX, UProbe, URetProbe, XDP
37+
//
38+
// When set to TC, the tc object will be populated with the eBPF program data
39+
// associated with a TC program.
40+
//
41+
// When set to TCX, the tcx object will be populated with the eBPF program
42+
// data associated with a TCX program.
43+
//
44+
// When set to UProbe, the uprobe object will be populated with the eBPF
45+
// program data associated with a UProbe program.
46+
//
47+
// When set to URetProbe, the uretprobe object will be populated with the eBPF
48+
// program data associated with a URetProbe program.
49+
//
50+
// When set to XDP, the xdp object will be populated with the eBPF program data
51+
// associated with a URetProbe program.
3652
// +unionDiscriminator
3753
// +required
3854
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
3955
Type EBPFProgType `json:"type"`
4056

41-
// xdp defines the desired state of the application's XdpPrograms.
57+
// xdp contains the attachment data for an XDP program when type is set to XDP.
4258
// +unionMember
4359
// +optional
4460
XDP *XdpProgramInfoState `json:"xdp,omitempty"`
4561

46-
// tc defines the desired state of the application's TcPrograms.
62+
// tc contains the attachment data for a TC program when type is set to TC.
4763
// +unionMember
4864
// +optional
4965
TC *TcProgramInfoState `json:"tc,omitempty"`
5066

51-
// tcx defines the desired state of the application's TcxPrograms.
67+
// tcx contains the attachment data for a TCX program when type is set to TCX.
5268
// +unionMember
5369
// +optional
5470
TCX *TcxProgramInfoState `json:"tcx,omitempty"`
5571

56-
// uprobe defines the desired state of the application's UprobePrograms.
72+
// uprobe contains the attachment data for a UProbe program when type is set to
73+
// UProbe.
5774
// +unionMember
5875
// +optional
5976
UProbe *UprobeProgramInfoState `json:"uprobe,omitempty"`
6077

61-
// uretprobe defines the desired state of the application's UretprobePrograms.
78+
// uretprobe contains the attachment data for a URetProbe program when type is
79+
// set to URetProbe.
6280
// +unionMember
6381
// +optional
6482
URetProbe *UprobeProgramInfoState `json:"uretprobe,omitempty"`
6583
}
6684

67-
// BpfApplicationStateStatus reflects the status of the BpfApplication on the given node
6885
type BpfApplicationStateStatus struct {
69-
// updateCount is the number of times the BpfApplicationState has been updated. Set to 1
70-
// when the object is created, then it is incremented prior to each update.
71-
// This allows us to verify that the API server has the updated object prior
72-
// to starting a new Reconcile operation.
86+
// updateCount is the number of times the BpfApplicationState has been updated.
87+
// Set to 1 when the object is created, then it is incremented prior to each
88+
// update. This is used to verify that the API server has the updated object
89+
// prior to starting a new Reconcile operation.
7390
UpdateCount int64 `json:"updateCount"`
74-
// node is the name of the node for this BpfApplicationStateSpec.
91+
// node is the name of the Kubernets node for this BpfApplicationState.
7592
Node string `json:"node"`
76-
// appLoadStatus reflects the status of loading the bpf application on the
77-
// given node.
93+
// appLoadStatus reflects the status of loading the eBPF application on the
94+
// given node. Whether or not the eBPF program is attached to an attachment
95+
// point is tracked by the linkStatus field, which is under of each link of
96+
// each program.
97+
//
98+
// NotLoaded is a temporary state that is assigned when a
99+
// ClusterBpfApplicationState is created and the initial reconcile is being
100+
// processed.
101+
//
102+
// LoadSuccess is returned if all the programs have been loaded with no errors.
103+
//
104+
// LoadError is returned if one or more programs encountered an error and were
105+
// not loaded.
106+
//
107+
// NotSelected is returned if this application did not select to run on this
108+
// Kubernetes node.
109+
//
110+
// UnloadSuccess is returned when all the programs were successfully unloaded.
111+
//
112+
// UnloadError is returned if one or more programs encountered an error when
113+
// being unloaded.
78114
AppLoadStatus AppLoadStatus `json:"appLoadStatus"`
79-
// programs is a list of bpf programs contained in the parent application.
115+
// programs is a list of eBPF programs contained in the parent BpfApplication
116+
// instance. Each entry in the list contains the derived program attributes as
117+
// well as the attach status for each program on the given Kubernetes node.
80118
Programs []BpfApplicationProgramState `json:"programs,omitempty"`
81-
// Conditions contains the overall status of the BpfApplicationState object
82-
// on the given node.
119+
// conditions contains the summary state of the BpfApplication for the given
120+
// Kubernetes node. If one or more programs failed to load or attach to the
121+
// designated attachment point, the condition will report the error. If more
122+
// than one error has occurred, condition will contain the first error
123+
// encountered.
83124
// +patchMergeKey=type
84125
// +patchStrategy=merge
85126
// +listType=map
@@ -92,14 +133,21 @@ type BpfApplicationStateStatus struct {
92133
// +kubebuilder:subresource:status
93134
// +kubebuilder:resource:scope=Namespaced
94135

95-
// BpfApplicationState contains the per-node state of a BpfApplication.
136+
// BpfApplicationState contains the state of a BpfApplication instance for a
137+
// given Kubernetes node. When a user creates a BpfApplication instance, bpfman
138+
// creates a BpfApplicationState instance for each node in a Kubernetes
139+
// cluster.
96140
// +kubebuilder:printcolumn:name="Node",type=string,JSONPath=".status.node"
97141
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
98142
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
99143
type BpfApplicationState struct {
100144
metav1.TypeMeta `json:",inline"`
101145
metav1.ObjectMeta `json:"metadata,omitempty"`
102146

147+
// status reflects the status of a BpfApplication instance for the given node.
148+
// appLoadStatus and conditions provide an overall status for the given node,
149+
// while each item in the programs list provides a per eBPF program status for
150+
// the given node.
103151
Status BpfApplicationStateStatus `json:"status,omitempty"`
104152
}
105153

apis/v1alpha1/bpf_application_types.go

Lines changed: 112 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,143 @@ import (
2828
// +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"
2929
// +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"
3030
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
3336
// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9_]+."
3437
// +kubebuilder:validation:MinLength=1
3538
// +kubebuilder:validation:MaxLength=64
3639
Name string `json:"name"`
3740

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 attachment point to use. This is where the eBPF
43+
// program 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.
3975
// +unionDiscriminator
4076
// +required
4177
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
4278
Type EBPFProgType `json:"type"`
4379

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 attachment point is
84+
// just after the packet has been received off the wire, but before the Linux
85+
// kernel has allocated an sk_buff, which is used to pass the packet through
86+
// the kernel networking stack.
4587
// +unionMember
4688
// +optional
4789
XDP *XdpProgramInfo `json:"xdp,omitempty"`
4890

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 attachment
96+
// point is in Linux's Traffic Control (tc) subsystem, which is after the
97+
// Linux kernel has allocated an sk_buff. TCX is newer implementation of TC
98+
// with enhanced performance and better support for running multiple programs
99+
// on a given network device. This makes TC useful for packet classification
100+
// actions.
50101
// +unionMember
51102
// +optional
52103
TC *TcProgramInfo `json:"tc,omitempty"`
53104

54-
// tcx defines the desired state of the application's TcxPrograms.
105+
// tcx is an optional field, but required when the type field is set to TCX.
106+
// tcx defines the desired state of the application's TCX programs. TCX
107+
// programs are attached to network devices (interfaces). The program can be
108+
// attached on either packet ingress or egress, so the program will be called
109+
// on every incoming or outgoing packet seen by the network device. The TCX
110+
// attachment point is in Linux's Traffic Control (tc) subsystem, which is
111+
// after the Linux kernel has allocated an sk_buff. This makes TCX useful for
112+
// packet classification actions. TCX is a newer implementation of TC with
113+
// enhanced performance and better support for running multiple programs on a
114+
// given network device.
55115
// +unionMember
56116
// +optional
57117
TCX *TcxProgramInfo `json:"tcx,omitempty"`
58118

59-
// uprobe defines the desired state of the application's UprobePrograms.
119+
// uprobe is an optional field, but required when the type field is set to
120+
// UProbe. uprobe defines the desired state of the application's UProbe
121+
// programs. UProbe programs are user-space probes. A target must be provided,
122+
// which is the library name or absolute path to a binary or library where the
123+
// probe is attached. Optionally, a function name can also be provided to
124+
// provide finer granularity on where the probe is attached. They can be
125+
// attached at any point in the binary, library or function using the optional
126+
// offset field. However, caution must be taken when using the offset, ensuring
127+
// the offset is still in the desired bytecode.
60128
// +unionMember
61129
// +optional
62130
UProbe *UprobeProgramInfo `json:"uprobe,omitempty"`
63131

64-
// uretprobe defines the desired state of the application's UretprobePrograms.
132+
// uretprobe is an optional field, but required when the type field is set to
133+
// URetProbe. uretprobe defines the desired state of the application's
134+
// URetProbe programs. URetProbe programs are user-space probes. A target must
135+
// be provided, which is the library name or absolute path to a binary or
136+
// library where the probe is attached. Optionally, a function name can also be
137+
// provided to provide finer granularity on where the probe is attached. They
138+
// are attached to the return point of the binary, library or function, but can
139+
// be set anywhere using the optional offset field. However, caution must be
140+
// taken when using the offset, ensuring the offset is still in the desired
141+
// bytecode.
65142
// +unionMember
66143
// +optional
67144
URetProbe *UprobeProgramInfo `json:"uretprobe,omitempty"`
68145
}
69146

70-
// BpfApplicationSpec defines the desired state of BpfApplication
147+
// spec defines the desired state of the BpfApplication. The BpfApplication
148+
// describes the set of one or more namespace scoped eBPF programs that should
149+
// be loaded for a given application and attributes for how they should be
150+
// loaded. eBPF programs that are grouped together under the same
151+
// BpfApplication instance can share maps and global data between the eBPF
152+
// programs loaded on the same Kubernetes Node.
71153
type BpfApplicationSpec struct {
72154
BpfAppCommon `json:",inline"`
73155

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.
156+
// programs is a required field and is the list of eBPF programs in a BPF
157+
// Application CRD that should be loaded in kernel memory. At least one entry
158+
// is required. eBPF programs in this list will be loaded on the system based
159+
// the nodeSelector. Even if an eBPF program is loaded in kernel memory, it
160+
// cannot be triggered until an attachment point is provided. The different
161+
// program types have different ways of attaching. The attachment points can be
162+
// added at creation time or modified (added or removed) at a later time to
163+
// activate or deactivate the eBPF program as desired.
164+
// CAUTION: When programs are added or removed from the list, that requires all
165+
// programs in the list to be reloaded, which could be temporarily service
166+
// effecting. For this reason, modifying the list is currently not allowed.
167+
// +required
77168
// +kubebuilder:validation:MinItems:=1
78169
Programs []BpfApplicationProgram `json:"programs,omitempty"`
79170
}
@@ -83,7 +174,15 @@ type BpfApplicationSpec struct {
83174
// +kubebuilder:subresource:status
84175
// +kubebuilder:resource:scope=Namespaced
85176

86-
// BpfApplication is the Schema for the bpfapplications API
177+
// BpfApplication is the schema for the namespace scoped BPF Applications API.
178+
// Using this API allows applications to load one or more eBPF programs on a
179+
// Kubernetes cluster using bpfman to load the programs.
180+
//
181+
// The bpfApplication.status field reports the overall status of the
182+
// BpfApplication CRD. A given BpfApplication CRD can result in loading and
183+
// attaching multiple eBPF programs on multiple nodes, so this status is just a
184+
// summary. More granular per-node status details can be found in the
185+
// corresponding BpfApplicationState CRD that bpfman creates for each node.
87186
// +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeselector`
88187
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
89188
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

0 commit comments

Comments
 (0)