diff --git a/k8s/client.go b/k8s/client.go index 8e726359f2..71f97b59d4 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -737,6 +737,10 @@ func (c *Client) ListCiliumBGPPeeringPolicies(ctx context.Context, opts metav1.L return c.CiliumClientset.CiliumV2alpha1().CiliumBGPPeeringPolicies().List(ctx, opts) } +func (c *Client) ListCiliumCIDRGroups(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumCIDRGroupList, error) { + return c.CiliumClientset.CiliumV2alpha1().CiliumCIDRGroups().List(ctx, opts) +} + func (c *Client) ListCiliumClusterwideNetworkPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumClusterwideNetworkPolicyList, error) { return c.CiliumClientset.CiliumV2().CiliumClusterwideNetworkPolicies().List(ctx, opts) } diff --git a/sysdump/client.go b/sysdump/client.go index 3815b0be06..41bc8929f9 100644 --- a/sysdump/client.go +++ b/sysdump/client.go @@ -41,6 +41,7 @@ type KubernetesClient interface { GetCiliumVersion(ctx context.Context, p *corev1.Pod) (*semver.Version, error) GetVersion(ctx context.Context) (string, error) ListCiliumBGPPeeringPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumBGPPeeringPolicyList, error) + ListCiliumCIDRGroups(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumCIDRGroupList, error) ListCiliumClusterwideNetworkPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumClusterwideNetworkPolicyList, error) ListCiliumClusterwideEnvoyConfigs(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumClusterwideEnvoyConfigList, error) ListCiliumIdentities(ctx context.Context) (*ciliumv2.CiliumIdentityList, error) diff --git a/sysdump/constants.go b/sysdump/constants.go index c336a98adc..0903b5a82b 100644 --- a/sysdump/constants.go +++ b/sysdump/constants.go @@ -46,6 +46,7 @@ const ( ciliumEtcdSecretFileName = "cilium-etcd-secrets-secret-.yaml" ciliumExternalWorkloadFileName = "ciliumexternalworkload-.yaml" ciliumIdentitiesFileName = "ciliumidentities-.yaml" + ciliumCIDRGroupsFileName = "ciliumcidrgroups-.yaml" ciliumLocalRedirectPoliciesFileName = "ciliumlocalredirectpolicies-.yaml" ciliumLoadBalancerIPPoolsFileName = "ciliumloadbalancerippools-.yaml" ciliumLogsFileName = "logs-%s-%s-.log" diff --git a/sysdump/sysdump.go b/sysdump/sysdump.go index cfd4b1c9f8..78afa61615 100644 --- a/sysdump/sysdump.go +++ b/sysdump/sysdump.go @@ -471,6 +471,20 @@ func (c *Collector) Run() error { return nil }, }, + { + Description: "Collecting Cilium CIDR Groups", + Quick: true, + Task: func(ctx context.Context) error { + v, err := c.Client.ListCiliumCIDRGroups(ctx, metav1.ListOptions{}) + if err != nil { + return fmt.Errorf("failed to collect Cilium CIDR Groups: %w", err) + } + if err := c.WriteYAML(ciliumCIDRGroupsFileName, v); err != nil { + return fmt.Errorf("failed to write Cilium CIDR Groups to file: %w", err) + } + return nil + }, + }, { Description: "Collecting Cilium local redirect policies", Quick: true, diff --git a/sysdump/sysdump_test.go b/sysdump/sysdump_test.go index a20e6ec937..2c7460f4ea 100644 --- a/sysdump/sysdump_test.go +++ b/sysdump/sysdump_test.go @@ -342,6 +342,10 @@ func (c *fakeClient) GetVersion(_ context.Context) (string, error) { panic("implement me") } +func (c *fakeClient) ListCiliumCIDRGroups(_ context.Context, _ metav1.ListOptions) (*ciliumv2alpha1.CiliumCIDRGroupList, error) { + panic("implement me") +} + func (c *fakeClient) ListCiliumClusterwideNetworkPolicies(_ context.Context, _ metav1.ListOptions) (*ciliumv2.CiliumClusterwideNetworkPolicyList, error) { panic("implement me") }