Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: collect Kubernetes Endpoints in sysdump #794

Merged
merged 1 commit into from
Apr 14, 2022
Merged
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
4 changes: 4 additions & 0 deletions k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions sysdump/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions sysdump/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
hubbleRelayConfigMapFileName = "hubble-relay-configmap-<ts>.yaml"
hubbleRelayDeploymentFileName = "hubble-relay-deployment-<ts>.yaml"
hubbleUIDeploymentFileName = "hubble-ui-deployment-<ts>.yaml"
kubernetesEndpointsFileName = "k8s-endpoints-<ts>.yaml"
kubernetesEventsFileName = "k8s-events-<ts>.yaml"
kubernetesNamespacesFileName = "k8s-namespaces-<ts>.yaml"
kubernetesNetworkPoliciesFileName = "k8s-networkpolicies-<ts>.yaml"
Expand Down
14 changes: 14 additions & 0 deletions sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions sysdump/sysdump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down