Skip to content

Commit

Permalink
sysdump: collect CiliumEgressGatewayPolicies
Browse files Browse the repository at this point in the history
Cilium v1.12 introduced CEGP as alternative way of configuring EgressGW
policies. Collect them in the sysdump.

Signed-off-by: Julian Wiedmann <[email protected]>
  • Loading branch information
julianwiedmann authored and tklauser committed Nov 22, 2022
1 parent aef2146 commit beceb46
Show file tree
Hide file tree
Showing 5 changed files with 24 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 @@ -820,6 +820,10 @@ func (c *Client) ListCiliumEgressNATPolicies(ctx context.Context, opts metav1.Li
return c.CiliumClientset.CiliumV2alpha1().CiliumEgressNATPolicies().List(ctx, opts)
}

func (c *Client) ListCiliumEgressGatewayPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumEgressGatewayPolicyList, error) {
return c.CiliumClientset.CiliumV2().CiliumEgressGatewayPolicies().List(ctx, opts)
}

func (c *Client) ListCiliumLocalRedirectPolicies(ctx context.Context, namespace string, opts metav1.ListOptions) (*ciliumv2.CiliumLocalRedirectPolicyList, error) {
return c.CiliumClientset.CiliumV2().CiliumLocalRedirectPolicies(namespace).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 @@ -42,6 +42,7 @@ type KubernetesClient interface {
ListCiliumClusterwideEnvoyConfigs(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumClusterwideEnvoyConfigList, error)
ListCiliumIdentities(ctx context.Context) (*ciliumv2.CiliumIdentityList, error)
ListCiliumEgressNATPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumEgressNATPolicyList, error)
ListCiliumEgressGatewayPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumEgressGatewayPolicyList, error)
ListCiliumEndpoints(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2.CiliumEndpointList, error)
ListCiliumEnvoyConfigs(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2.CiliumEnvoyConfigList, error)
ListCiliumLocalRedirectPolicies(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2.CiliumLocalRedirectPolicyList, error)
Expand Down
1 change: 1 addition & 0 deletions sysdump/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
ciliumDaemonSetFileName = "cilium-daemonset-<ts>.yaml"
ciliumIngressesFileName = "ciliumingresses-<ts>.yaml"
ciliumEgressNATPoliciesFileName = "ciliumegressnatpolicies-<ts>.yaml"
ciliumEgressGatewayPoliciesFileName = "ciliumegressgatewaypolicies-<ts>.yaml"
ciliumEndpointsFileName = "ciliumendpoints-<ts>.yaml"
ciliumEnvoyConfigsFileName = "ciliumenvoyconfigs-<ts>.yaml"
ciliumEtcdSecretFileName = "cilium-etcd-secrets-secret-<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 @@ -428,6 +428,20 @@ func (c *Collector) Run() error {
return nil
},
},
{
Description: "Collecting Cilium Egress Gateway policies",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.ListCiliumEgressGatewayPolicies(ctx, metav1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to collect Cilium Egress Gateway policies: %w", err)
}
if err := c.WriteYAML(ciliumEgressGatewayPoliciesFileName, v); err != nil {
return fmt.Errorf("failed to collect Cilium Egress Gateway policies: %w", err)
}
return nil
},
},
{
Description: "Collecting Cilium local redirect 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 @@ -296,6 +296,10 @@ func (c *fakeClient) ListCiliumEgressNATPolicies(ctx context.Context, opts metav
panic("implement me")
}

func (c *fakeClient) ListCiliumEgressGatewayPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumEgressGatewayPolicyList, error) {
panic("implement me")
}

func (c *fakeClient) ListCiliumEndpoints(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2.CiliumEndpointList, error) {
panic("implement me")
}
Expand Down

0 comments on commit beceb46

Please sign in to comment.