Skip to content

Commit

Permalink
tetragon: remove tetragon CR code
Browse files Browse the repository at this point in the history
In the previous patch, we used ListUnstructured for tetragon CRs. This
means that there is no need for the tetragon clientset anymore. Remove
it.

Signed-off-by: Kornilios Kourtis <[email protected]>
  • Loading branch information
kkourt authored and michi-covalent committed Mar 11, 2024
1 parent 1632e1b commit 7027d3e
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 865 deletions.
22 changes: 0 additions & 22 deletions k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
"github.com/cilium/cilium/pkg/versioncheck"

tetragonv1alpha1 "github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1"
tetragonClientset "github.com/cilium/tetragon/pkg/k8s/client/clientset/versioned"

"github.com/cilium/cilium-cli/defaults"
)
Expand All @@ -57,7 +56,6 @@ type Client struct {
ExtensionClientset apiextensionsclientset.Interface // k8s api extension needed to retrieve CRDs
DynamicClientset dynamic.Interface
CiliumClientset ciliumClientset.Interface
TetragonClientset tetragonClientset.Interface
Config *rest.Config
RawConfig clientcmdapi.Config
RESTClientGetter genericclioptions.RESTClientGetter
Expand Down Expand Up @@ -92,11 +90,6 @@ func NewClient(contextName, kubeconfig, ciliumNamespace string) (*Client, error)
return nil, err
}

tetragonClientset, err := tetragonClientset.NewForConfig(config)
if err != nil {
return nil, err
}

clientset, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -127,7 +120,6 @@ func NewClient(contextName, kubeconfig, ciliumNamespace string) (*Client, error)

return &Client{
CiliumClientset: ciliumClientset,
TetragonClientset: tetragonClientset,
Clientset: clientset,
ExtensionClientset: extensionClientset,
Config: config,
Expand Down Expand Up @@ -956,17 +948,3 @@ func (c *Client) CreateEphemeralContainer(ctx context.Context, pod *corev1.Pod,
ctx, pod.Name, types.StrategicMergePatchType, patch, metav1.PatchOptions{}, "ephemeralcontainers",
)
}

// Tetragon Specific commands

func (c *Client) ListTetragonTracingPolicies(ctx context.Context, opts metav1.ListOptions) (*tetragonv1alpha1.TracingPolicyList, error) {
return c.TetragonClientset.CiliumV1alpha1().TracingPolicies().List(ctx, opts)
}

func (c *Client) ListTetragonTracingPoliciesNamespaced(ctx context.Context, namespace string, opts metav1.ListOptions) (*tetragonv1alpha1.TracingPolicyNamespacedList, error) {
return c.TetragonClientset.CiliumV1alpha1().TracingPoliciesNamespaced(namespace).List(ctx, opts)
}

func (c *Client) ListTetragonPodInfo(ctx context.Context, namespace string, opts metav1.ListOptions) (*tetragonv1alpha1.PodInfoList, error) {
return c.TetragonClientset.CiliumV1alpha1().PodInfo(namespace).List(ctx, opts)
}
4 changes: 0 additions & 4 deletions sysdump/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/blang/semver/v4"
ciliumv2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
ciliumv2alpha1 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2alpha1"
tetragonv1alpha1 "github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
Expand Down Expand Up @@ -59,9 +58,6 @@ type KubernetesClient interface {
ListCiliumNodes(ctx context.Context) (*ciliumv2.CiliumNodeList, error)
ListCiliumNodeConfigs(ctx context.Context, namespace string, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumNodeConfigList, error)
ListCiliumPodIPPools(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumPodIPPoolList, error)
ListTetragonPodInfo(ctx context.Context, namespace string, opts metav1.ListOptions) (*tetragonv1alpha1.PodInfoList, error)
ListTetragonTracingPolicies(ctx context.Context, opts metav1.ListOptions) (*tetragonv1alpha1.TracingPolicyList, error)
ListTetragonTracingPoliciesNamespaced(ctx context.Context, namespace string, opts metav1.ListOptions) (*tetragonv1alpha1.TracingPolicyNamespacedList, error)
ListDaemonSet(ctx context.Context, namespace string, o metav1.ListOptions) (*appsv1.DaemonSetList, error)
ListEvents(ctx context.Context, o metav1.ListOptions) (*corev1.EventList, error)
ListEndpoints(ctx context.Context, o metav1.ListOptions) (*corev1.EndpointsList, error)
Expand Down
54 changes: 0 additions & 54 deletions sysdump/sysdump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/cilium/cilium/api/v1/models"
ciliumv2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
ciliumv2alpha1 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2alpha1"
tetragonv1alpha1 "github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1"
"github.com/stretchr/testify/assert"
"gopkg.in/check.v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -198,15 +197,6 @@ func TestKVStoreTask(t *testing.T) {
assert.Equal([]byte("{}"), data)
}

func TestListTetragonTracingPolicies(t *testing.T) {
assert := assert.New(t)
client := &fakeClient{}

tracingPolicies, err := client.ListTetragonTracingPolicies(context.Background(), metav1.ListOptions{})
assert.NoError(err)
assert.GreaterOrEqual(len(tracingPolicies.Items), 0)
}

func TestListCiliumEndpointSlices(t *testing.T) {
assert := assert.New(t)
client := &fakeClient{}
Expand Down Expand Up @@ -496,33 +486,6 @@ func (c *fakeClient) ListIngressClasses(_ context.Context, _ metav1.ListOptions)
panic("implement me")
}

func (c *fakeClient) ListTetragonTracingPolicies(_ context.Context, _ metav1.ListOptions) (*tetragonv1alpha1.TracingPolicyList, error) {
tetragonTracingPolicy := tetragonv1alpha1.TracingPolicyList{
TypeMeta: metav1.TypeMeta{
Kind: "List",
APIVersion: "v1",
},
ListMeta: metav1.ListMeta{},
Items: []tetragonv1alpha1.TracingPolicy{{
TypeMeta: metav1.TypeMeta{
Kind: "TracingPolicy",
APIVersion: "v1alpha",
},
ObjectMeta: metav1.ObjectMeta{
Name: "testPolicy1",
},
Spec: tetragonv1alpha1.TracingPolicySpec{
KProbes: []tetragonv1alpha1.KProbeSpec{},
Tracepoints: []tetragonv1alpha1.TracepointSpec{},
Loader: true,
},
},
},
}

return &tetragonTracingPolicy, nil
}

func (c *fakeClient) CreateEphemeralContainer(_ context.Context, _ *corev1.Pod, _ *corev1.EphemeralContainer) (*corev1.Pod, error) {
panic("implement me")
}
Expand All @@ -541,20 +504,3 @@ func (c *fakeClient) GetNamespace(_ context.Context, ns string, _ metav1.GetOpti
},
}
}

func (c *fakeClient) ListTetragonTracingPoliciesNamespaced(_ context.Context, _ string, _ metav1.ListOptions) (*tetragonv1alpha1.TracingPolicyNamespacedList, error) {
ret := tetragonv1alpha1.TracingPolicyNamespacedList{
TypeMeta: metav1.TypeMeta{
Kind: "List",
APIVersion: "v1",
},
ListMeta: metav1.ListMeta{},
Items: []tetragonv1alpha1.TracingPolicyNamespaced{},
}

return &ret, nil
}

func (c *fakeClient) ListTetragonPodInfo(_ context.Context, _ string, _ metav1.ListOptions) (*tetragonv1alpha1.PodInfoList, error) {
panic("implement me")
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7027d3e

Please sign in to comment.