From 87dfad187460003f9486cd5cdff38a42bcc28900 Mon Sep 17 00:00:00 2001 From: Chris Tarazi Date: Tue, 25 Apr 2023 16:22:23 -0700 Subject: [PATCH] sysdump: Add support for CiliumCIDRGroup CRD Now that Cilium implemented support for CiliumCIDRGroups, let's support dumping it in sysdump. Signed-off-by: Chris Tarazi --- k8s/client.go | 4 ++++ sysdump/client.go | 1 + sysdump/constants.go | 1 + sysdump/sysdump.go | 14 ++++++++++++++ 4 files changed, 20 insertions(+) diff --git a/k8s/client.go b/k8s/client.go index 6697f967b5..97cda6ce7b 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -734,6 +734,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 b6133d88ef..0454a1a526 100644 --- a/sysdump/sysdump.go +++ b/sysdump/sysdump.go @@ -470,6 +470,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,