Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 31 additions & 47 deletions apis/v1alpha1/bpf_application_state_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1types "k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// +union
Expand Down Expand Up @@ -52,7 +50,7 @@ type BpfApplicationProgramState struct {
// +unionDiscriminator
// +required
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
Type EBPFProgType `json:"type"`
Type EBPFProgType `json:"type,omitempty"`

// xdp contains the attachment data for an XDP program when type is set to XDP.
// +unionMember
Expand Down Expand Up @@ -83,15 +81,32 @@ type BpfApplicationProgramState struct {
}

type BpfApplicationStateStatus struct {
// UpdateCount tracks the number of times the BpfApplicationState object has
// conditions contains the summary state of the BpfApplication for the given
// Kubernetes node. If one or more programs failed to load or attach to the
// designated attachment point, the condition will report the error. If more
// than one error has occurred, condition will contain the first error
// encountered.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
// +optional
// +kubebuilder:validation:MaxItems=1023
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
// updateCount tracks the number of times the BpfApplicationState object has
// been updated. The bpfman agent initializes it to 1 when it creates the
// object, and then increments it before each subsequent update. It serves
// as a lightweight sequence number to verify that the API server is serving
// the most recent version of the object before beginning a new Reconcile
// operation.
UpdateCount int64 `json:"updateCount"`
// node is the name of the Kubernets node for this BpfApplicationState.
Node string `json:"node"`
// +kubebuilder:validation:Minimum=1
// +optional
UpdateCount int64 `json:"updateCount,omitempty"`
// node is the name of the Kubernetes node for this BpfApplicationState.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Node string `json:"node,omitempty"`
// appLoadStatus reflects the status of loading the eBPF application on the
// given node.
//
Expand All @@ -113,21 +128,15 @@ type BpfApplicationStateStatus struct {
//
// UnloadError is returned if one or more programs encountered an error when
// being unloaded.
AppLoadStatus AppLoadStatus `json:"appLoadStatus"`
// +optional
AppLoadStatus AppLoadStatus `json:"appLoadStatus,omitempty"`
// programs is a list of eBPF programs contained in the parent BpfApplication
// instance. Each entry in the list contains the derived program attributes as
// well as the attach status for each program on the given Kubernetes node.
// +kubebuilder:validation:MaxItems=1023
// +listType=atomic
// +optional
Programs []BpfApplicationProgramState `json:"programs,omitempty"`
// conditions contains the summary state of the BpfApplication for the given
// Kubernetes node. If one or more programs failed to load or attach to the
// designated attachment point, the condition will report the error. If more
// than one error has occurred, condition will contain the first error
// encountered.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

// +genclient
Expand All @@ -143,13 +152,16 @@ type BpfApplicationStateStatus struct {
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type BpfApplicationState struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// metadata is the object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

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

Expand All @@ -160,31 +172,3 @@ type BpfApplicationStateList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []BpfApplicationState `json:"items"`
}

func (an BpfApplicationState) GetName() string {
return an.Name
}

func (an BpfApplicationState) GetUID() metav1types.UID {
return an.UID
}

func (an BpfApplicationState) GetAnnotations() map[string]string {
return an.Annotations
}

func (an BpfApplicationState) GetLabels() map[string]string {
return an.Labels
}

func (an BpfApplicationState) GetConditions() []metav1.Condition {
return an.Status.Conditions
}

func (an BpfApplicationState) GetClientObject() client.Object {
return &an
}

func (anl BpfApplicationStateList) GetItems() []BpfApplicationState {
return anl.Items
}
22 changes: 15 additions & 7 deletions apis/v1alpha1/bpf_application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ type BpfApplicationProgram struct {
// name is a required field and is the name of the function that is the entry
// point for the eBPF program. name must not be an empty string, must not
// exceed 64 characters in length, must start with alpha characters and must
// only contain alphanumeric characters.
// only contain alphanumeric characters and underscores.
// +required
// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9_]+."
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=64
Name string `json:"name"`
Name string `json:"name,omitempty"`

// type is a required field used to specify the type of the eBPF program.
//
Expand Down Expand Up @@ -73,7 +73,7 @@ type BpfApplicationProgram struct {
// +unionDiscriminator
// +required
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
Type EBPFProgType `json:"type"`
Type EBPFProgType `json:"type,omitempty"`

// xdp is an optional field, but required when the type field is set to XDP.
// xdp defines the desired state of the application's XDP programs. XDP program
Expand Down Expand Up @@ -163,7 +163,9 @@ type BpfApplicationSpec struct {
// programs in the list to be reloaded, which could be temporarily service
// effecting. For this reason, modifying the list is currently not allowed.
// +required
// +kubebuilder:validation:MinItems:=1
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=1023
// +listType=atomic
Programs []BpfApplicationProgram `json:"programs,omitempty"`
}

Expand All @@ -185,11 +187,17 @@ type BpfApplicationSpec struct {
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type BpfApplication struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// metadata is the object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BpfApplicationSpec `json:"spec,omitempty"`
Status BpfAppStatus `json:"status,omitempty"`
// spec defines the desired state of the BpfApplication.
// +required
Spec BpfApplicationSpec `json:"spec,omitzero"`
// status reflects the observed state of the BpfApplication.
// +optional
Status BpfAppStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
76 changes: 30 additions & 46 deletions apis/v1alpha1/cluster_bpf_application_state_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1types "k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// +union
Expand Down Expand Up @@ -73,7 +71,7 @@ type ClBpfApplicationProgramState struct {
// +unionDiscriminator
// +required
// +kubebuilder:validation:Enum:="FEntry";"FExit";"KProbe";"KRetProbe";"TC";"TCX";"TracePoint";"UProbe";"URetProbe";"XDP"
Type EBPFProgType `json:"type"`
Type EBPFProgType `json:"type,omitempty"`

// xdp contains the attachment data for an XDP program when type is set to XDP.
// +unionMember
Expand Down Expand Up @@ -134,15 +132,32 @@ type ClBpfApplicationProgramState struct {
}

type ClBpfApplicationStateStatus struct {
// UpdateCount tracks the number of times the BpfApplicationState object has
// conditions contains the summary state of the ClusterBpfApplication for the
// given Kubernetes node. If one or more programs failed to load or attach to
// the designated attachment point, the condition will report the error. If
// more than one error has occurred, condition will contain the first error
// encountered.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
// +optional
// +kubebuilder:validation:MaxItems=1023
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
// updateCount tracks the number of times the BpfApplicationState object has
// been updated. The bpfman agent initializes it to 1 when it creates the
// object, and then increments it before each subsequent update. It serves
// as a lightweight sequence number to verify that the API server is serving
// the most recent version of the object before beginning a new Reconcile
// operation.
UpdateCount int64 `json:"updateCount"`
// +kubebuilder:validation:Minimum=1
// +optional
UpdateCount int64 `json:"updateCount,omitempty"`
// node is the name of the Kubernetes node for this ClusterBpfApplicationState.
Node string `json:"node"`
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Node string `json:"node,omitempty"`
// appLoadStatus reflects the status of loading the eBPF application on the
// given node.
//
Expand All @@ -162,22 +177,16 @@ type ClBpfApplicationStateStatus struct {
//
// UnloadError is returned if one or more programs encountered an error when
// being unloaded.
AppLoadStatus AppLoadStatus `json:"appLoadStatus"`
// +optional
AppLoadStatus AppLoadStatus `json:"appLoadStatus,omitempty"`
// programs is a list of eBPF programs contained in the parent
// ClusterBpfApplication instance. Each entry in the list contains the derived
// program attributes as well as the attach status for each program on the
// given Kubernetes node.
// +kubebuilder:validation:MaxItems=1023
// +listType=atomic
// +optional
Programs []ClBpfApplicationProgramState `json:"programs,omitempty"`
// conditions contains the summary state of the ClusterBpfApplication for the
// given Kubernetes node. If one or more programs failed to load or attach to
// the designated attachment point, the condition will report the error. If
// more than one error has occurred, condition will contain the first error
// encountered.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

// +genclient
Expand All @@ -194,13 +203,16 @@ type ClBpfApplicationStateStatus struct {
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type ClusterBpfApplicationState struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// metadata is the object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// status reflects the status of a ClusterBpfApplication instance for the given
// node. appLoadStatus and conditions provide an overall status for the given
// node, while each item in the programs list provides a per eBPF program
// status for the given node.
// +optional
Status ClBpfApplicationStateStatus `json:"status,omitempty"`
}

Expand All @@ -211,31 +223,3 @@ type ClusterBpfApplicationStateList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterBpfApplicationState `json:"items"`
}

func (an ClusterBpfApplicationState) GetName() string {
return an.Name
}

func (an ClusterBpfApplicationState) GetUID() metav1types.UID {
return an.UID
}

func (an ClusterBpfApplicationState) GetAnnotations() map[string]string {
return an.Annotations
}

func (an ClusterBpfApplicationState) GetLabels() map[string]string {
return an.Labels
}

func (an ClusterBpfApplicationState) GetConditions() []metav1.Condition {
return an.Status.Conditions
}

func (an ClusterBpfApplicationState) GetClientObject() client.Object {
return &an
}

func (anl ClusterBpfApplicationStateList) GetItems() []ClusterBpfApplicationState {
return anl.Items
}
22 changes: 15 additions & 7 deletions apis/v1alpha1/cluster_bpf_application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ type ClBpfApplicationProgram struct {
// name is a required field and is the name of the function that is the entry
// point for the eBPF program. name must not be an empty string, must not
// exceed 64 characters in length, must start with alpha characters and must
// only contain alphanumeric characters.
// only contain alphanumeric characters and underscores.
// +required
// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9_]+."
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=64
Name string `json:"name"`
Name string `json:"name,omitempty"`

// type is a required field used to specify the type of the eBPF program.
//
Expand Down Expand Up @@ -143,7 +143,7 @@ type ClBpfApplicationProgram struct {
// +unionDiscriminator
// +required
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"FEntry";"FExit";"KProbe";"KRetProbe";"UProbe";"URetProbe";"TracePoint"
Type EBPFProgType `json:"type"`
Type EBPFProgType `json:"type,omitempty"`

// xdp is an optional field, but required when the type field is set to XDP.
// xdp defines the desired state of the application's XDP programs. XDP program
Expand Down Expand Up @@ -293,7 +293,9 @@ type ClBpfApplicationSpec struct {
// effecting. For this reason, modifying the list is currently not allowed.
// +required
// +kubebuilder:validation:MinItems:=1
Programs []ClBpfApplicationProgram `json:"programs"`
// +kubebuilder:validation:MaxItems=1023
// +listType=atomic
Programs []ClBpfApplicationProgram `json:"programs,omitempty"`
}

// +genclient
Expand All @@ -316,11 +318,17 @@ type ClBpfApplicationSpec struct {
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type ClusterBpfApplication struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// metadata is the standard object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClBpfApplicationSpec `json:"spec,omitempty"`
Status BpfAppStatus `json:"status,omitempty"`
// spec defines the desired state of the BpfApplication.
// +required
Spec ClBpfApplicationSpec `json:"spec,omitzero"`
// status reflects the observed state of the BpfApplication.
// +optional
Status BpfAppStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
Loading
Loading