diff --git a/k8s/client.go b/k8s/client.go index 36d750af34..fbf8bd9f34 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -652,6 +652,10 @@ func (c *Client) ListUnstructured(ctx context.Context, gvr schema.GroupVersionRe return c.DynamicClientset.Resource(gvr).Namespace(*namespace).List(ctx, o) } +func (c *Client) ListEndpoints(ctx context.Context, o metav1.ListOptions) (*corev1.EndpointsList, error) { + return c.Clientset.CoreV1().Endpoints(corev1.NamespaceAll).List(ctx, o) +} + func (c *Client) ListNetworkPolicies(ctx context.Context, o metav1.ListOptions) (*networkingv1.NetworkPolicyList, error) { return c.Clientset.NetworkingV1().NetworkPolicies(corev1.NamespaceAll).List(ctx, o) } diff --git a/sysdump/client.go b/sysdump/client.go index 6d452a918d..d1c7cda2d5 100644 --- a/sysdump/client.go +++ b/sysdump/client.go @@ -41,6 +41,7 @@ type KubernetesClient interface { ListCiliumNodes(ctx context.Context) (*ciliumv2.CiliumNodeList, 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) ListNamespaces(ctx context.Context, o metav1.ListOptions) (*corev1.NamespaceList, error) ListNetworkPolicies(ctx context.Context, o metav1.ListOptions) (*networkingv1.NetworkPolicyList, error) ListNodes(ctx context.Context, options metav1.ListOptions) (*corev1.NodeList, error) diff --git a/sysdump/constants.go b/sysdump/constants.go index b4b464bbed..758b0bdf99 100644 --- a/sysdump/constants.go +++ b/sysdump/constants.go @@ -53,6 +53,7 @@ const ( hubbleRelayConfigMapFileName = "hubble-relay-configmap-.yaml" hubbleRelayDeploymentFileName = "hubble-relay-deployment-.yaml" hubbleUIDeploymentFileName = "hubble-ui-deployment-.yaml" + kubernetesEndpointsFileName = "k8s-endpoints-.yaml" kubernetesEventsFileName = "k8s-events-.yaml" kubernetesNamespacesFileName = "k8s-namespaces-.yaml" kubernetesNetworkPoliciesFileName = "k8s-networkpolicies-.yaml" diff --git a/sysdump/sysdump.go b/sysdump/sysdump.go index fe41819c4d..1c0ced3a1b 100644 --- a/sysdump/sysdump.go +++ b/sysdump/sysdump.go @@ -334,6 +334,20 @@ func (c *Collector) Run() error { return nil }, }, + { + Description: "Collecting Kubernetes endpoints", + Quick: true, + Task: func(ctx context.Context) error { + v, err := c.Client.ListEndpoints(ctx, metav1.ListOptions{}) + if err != nil { + return fmt.Errorf("failed to collect Kubernetes endpoints: %w", err) + } + if err := c.WriteYAML(kubernetesEndpointsFileName, v); err != nil { + return fmt.Errorf("failed to collect Kubernetes endpoints: %w", err) + } + return nil + }, + }, { Description: "Collecting Cilium network policies", Quick: true, diff --git a/sysdump/sysdump_test.go b/sysdump/sysdump_test.go index 97bbbf22ce..067051358f 100644 --- a/sysdump/sysdump_test.go +++ b/sysdump/sysdump_test.go @@ -189,6 +189,10 @@ func (c *fakeClient) ListNamespaces(ctx context.Context, o metav1.ListOptions) ( panic("implement me") } +func (c *fakeClient) ListEndpoints(ctx context.Context, o metav1.ListOptions) (*corev1.EndpointsList, error) { + panic("implement me") +} + func (c *fakeClient) ListNetworkPolicies(ctx context.Context, o metav1.ListOptions) (*networkingv1.NetworkPolicyList, error) { panic("implement me") }