Skip to content

Commit

Permalink
Merge pull request bpfman#1047 from Billy99/billy99-k8s-fentry-fexit
Browse files Browse the repository at this point in the history
bpfman-operator: Add K8s support for fentry and fexit
  • Loading branch information
mergify[bot] authored Mar 26, 2024
2 parents 9aad37c + cc811b8 commit 163586d
Show file tree
Hide file tree
Showing 50 changed files with 4,176 additions and 133 deletions.
2 changes: 1 addition & 1 deletion bpfman-api/src/bpfman.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub struct FexitAttachInfo {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AttachInfo {
#[prost(oneof = "attach_info::Info", tags = "2, 3, 4, 5, 6")]
#[prost(oneof = "attach_info::Info", tags = "2, 3, 4, 5, 6, 7, 8")]
pub info: ::core::option::Option<attach_info::Info>,
}
/// Nested message and enum types in `AttachInfo`.
Expand Down
16 changes: 16 additions & 0 deletions bpfman-operator/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,20 @@ resources:
kind: UprobeProgram
path: github.com/bpfman/bpfman/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: bpfman.io
kind: FentryProgram
path: github.com/bpfman/bpfman/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: bpfman.io
kind: FexitProgram
path: github.com/bpfman/bpfman/api/v1alpha1
version: v1alpha1
version: "3"
71 changes: 71 additions & 0 deletions bpfman-operator/apis/v1alpha1/fentryProgram_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2024.
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.
*/

// All fields are required unless explicitly marked optional
// +kubebuilder:validation:Required
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:nonNamespaced
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster

// FentryProgram is the Schema for the FentryPrograms API
// +kubebuilder:printcolumn:name="BpfFunctionName",type=string,JSONPath=`.spec.bpffunctionname`
// +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeselector`
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`,priority=1
type FentryProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FentryProgramSpec `json:"spec"`
// +optional
Status FentryProgramStatus `json:"status,omitempty"`
}

// FentryProgramSpec defines the desired state of FentryProgram
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`
type FentryProgramSpec struct {
BpfProgramCommon `json:",inline"`

// Function to attach the fentry to.
FunctionName string `json:"func_name"`
}

// FentryProgramStatus defines the observed state of FentryProgram
type FentryProgramStatus struct {
// Conditions houses the global cluster state for the FentryProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

// +kubebuilder:object:root=true
// FentryProgramList contains a list of FentryPrograms
type FentryProgramList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FentryProgram `json:"items"`
}
71 changes: 71 additions & 0 deletions bpfman-operator/apis/v1alpha1/fexitProgram_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2024.
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.
*/

// All fields are required unless explicitly marked optional
// +kubebuilder:validation:Required
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:nonNamespaced
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster

// FexitProgram is the Schema for the FexitPrograms API
// +kubebuilder:printcolumn:name="BpfFunctionName",type=string,JSONPath=`.spec.bpffunctionname`
// +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeselector`
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`,priority=1
type FexitProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FexitProgramSpec `json:"spec"`
// +optional
Status FexitProgramStatus `json:"status,omitempty"`
}

// FexitProgramSpec defines the desired state of FexitProgram
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`
type FexitProgramSpec struct {
BpfProgramCommon `json:",inline"`

// Function to attach the fexit to.
FunctionName string `json:"func_name"`
}

// FexitProgramStatus defines the observed state of FexitProgram
type FexitProgramStatus struct {
// Conditions houses the global cluster state for the FexitProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

// +kubebuilder:object:root=true
// FexitProgramList contains a list of FexitPrograms
type FexitProgramList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FexitProgram `json:"items"`
}
194 changes: 194 additions & 0 deletions bpfman-operator/apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions bpfman-operator/apis/v1alpha1/zz_generated.register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 163586d

Please sign in to comment.