Skip to content

Commit

Permalink
sysdump: Add support for CiliumCIDRGroup CRD
Browse files Browse the repository at this point in the history
Now that Cilium implemented support for CiliumCIDRGroups, let's support
dumping it in sysdump.

Signed-off-by: Chris Tarazi <[email protected]>
  • Loading branch information
christarazi committed Apr 25, 2023
1 parent f8b16b6 commit 87dfad1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
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 {
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)
Expand Down
1 change: 1 addition & 0 deletions sysdump/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
ciliumEtcdSecretFileName = "cilium-etcd-secrets-secret-<ts>.yaml"
ciliumExternalWorkloadFileName = "ciliumexternalworkload-<ts>.yaml"
ciliumIdentitiesFileName = "ciliumidentities-<ts>.yaml"
ciliumCIDRGroupsFileName = "ciliumcidrgroups-<ts>.yaml"
ciliumLocalRedirectPoliciesFileName = "ciliumlocalredirectpolicies-<ts>.yaml"
ciliumLoadBalancerIPPoolsFileName = "ciliumloadbalancerippools-<ts>.yaml"
ciliumLogsFileName = "logs-%s-%s-<ts>.log"
Expand Down
14 changes: 14 additions & 0 deletions sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 87dfad1

Please sign in to comment.