Skip to content

Commit

Permalink
sysdump: Add support for Ingress, CCWEC, CEV
Browse files Browse the repository at this point in the history
This commit is to add support for 3 new resources Ingress, CCEC and CEV.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
  • Loading branch information
sayboras committed May 2, 2022
1 parent 5e6f238 commit b827ee4
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
12 changes: 12 additions & 0 deletions k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ func (c *Client) ListCiliumEndpoints(ctx context.Context, namespace string, opti
return c.CiliumClientset.CiliumV2().CiliumEndpoints(namespace).List(ctx, options)
}

func (c *Client) ListCiliumEnvoyConfigs(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2alpha1.CiliumEnvoyConfigList, error) {
return c.CiliumClientset.CiliumV2alpha1().CiliumEnvoyConfigs(namespace).List(ctx, options)
}

func (c *Client) ListNodes(ctx context.Context, options metav1.ListOptions) (*corev1.NodeList, error) {
return c.Clientset.CoreV1().Nodes().List(ctx, options)
}
Expand Down Expand Up @@ -583,6 +587,10 @@ func (c *Client) ListCiliumClusterwideNetworkPolicies(ctx context.Context, opts
return c.CiliumClientset.CiliumV2().CiliumClusterwideNetworkPolicies().List(ctx, opts)
}

func (c *Client) ListCiliumClusterwideEnvoyConfigs(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumClusterwideEnvoyConfigList, error) {
return c.CiliumClientset.CiliumV2alpha1().CiliumClusterwideEnvoyConfigs().List(ctx, opts)
}

func (c *Client) GetCiliumClusterwideNetworkPolicy(ctx context.Context, name string, opts metav1.GetOptions) (*ciliumv2.CiliumClusterwideNetworkPolicy, error) {
return c.CiliumClientset.CiliumV2().CiliumClusterwideNetworkPolicies().Get(ctx, name, opts)
}
Expand Down Expand Up @@ -656,6 +664,10 @@ func (c *Client) ListEndpoints(ctx context.Context, o metav1.ListOptions) (*core
return c.Clientset.CoreV1().Endpoints(corev1.NamespaceAll).List(ctx, o)
}

func (c *Client) ListIngresses(ctx context.Context, o metav1.ListOptions) (*networkingv1.IngressList, error) {
return c.Clientset.NetworkingV1().Ingresses(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
3 changes: 3 additions & 0 deletions sysdump/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ type KubernetesClient interface {
GetSecret(ctx context.Context, namespace, name string, opts metav1.GetOptions) (*corev1.Secret, error)
GetVersion(ctx context.Context) (string, error)
ListCiliumClusterwideNetworkPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2.CiliumClusterwideNetworkPolicyList, error)
ListCiliumClusterwideEnvoyConfigs(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumClusterwideEnvoyConfigList, error)
ListCiliumIdentities(ctx context.Context) (*ciliumv2.CiliumIdentityList, error)
ListCiliumEgressNATPolicies(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumEgressNATPolicyList, error)
ListCiliumEndpoints(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2.CiliumEndpointList, error)
ListCiliumEnvoyConfigs(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2alpha1.CiliumEnvoyConfigList, error)
ListCiliumLocalRedirectPolicies(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2.CiliumLocalRedirectPolicyList, error)
ListCiliumNetworkPolicies(ctx context.Context, namespace string, opts metav1.ListOptions) (*ciliumv2.CiliumNetworkPolicyList, error)
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)
ListIngresses(ctx context.Context, o metav1.ListOptions) (*networkingv1.IngressList, 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
3 changes: 3 additions & 0 deletions sysdump/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ const (
awsNodeDaemonSetFileName = "aws-node-daemonset-<ts>.yaml"
ciliumBugtoolFileName = "cilium-bugtool-%s-<ts>.tar.gz"
ciliumClusterWideNetworkPoliciesFileName = "ciliumclusterwidenetworkpolicies-<ts>.yaml"
ciliumClusterwideEnvoyConfigsFileName = "ciliumclusterwideenvoyconfigs-<ts>.yaml"
ciliumConfigMapFileName = "cilium-configmap-<ts>.yaml"
ciliumDaemonSetFileName = "cilium-daemonset-<ts>.yaml"
ciliumIngressesFileName = "ciliumingresses-<ts>.yaml"
ciliumEgressNATPoliciesFileName = "ciliumegressnatpolicies-<ts>.yaml"
ciliumEndpointsFileName = "ciliumendpoints-<ts>.yaml"
ciliumEnvoyConfigsFileName = "ciliumenvoyconfigs-<ts>.yaml"
ciliumEtcdSecretFileName = "cilium-etcd-secrets-secret-<ts>.yaml"
ciliumIdentitiesFileName = "ciliumidentities-<ts>.yaml"
ciliumLocalRedirectPoliciesFileName = "ciliumlocalredirectpolicies-<ts>.yaml"
Expand Down
42 changes: 42 additions & 0 deletions sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,48 @@ func (c *Collector) Run() error {
return nil
},
},
{
Description: "Collecting Ingress",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.ListIngresses(ctx, metav1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to collect Ingress: %w", err)
}
if err := c.WriteYAML(ciliumIngressesFileName, v); err != nil {
return fmt.Errorf("failed to collect Ingress: %w", err)
}
return nil
},
},
{
Description: "Collecting CiliumClusterwideEnvoyConfigs",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.ListCiliumClusterwideEnvoyConfigs(ctx, metav1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to collect CiliumClusterwideEnvoyConfigs: %w", err)
}
if err := c.WriteYAML(ciliumClusterwideEnvoyConfigsFileName, v); err != nil {
return fmt.Errorf("failed to collect CiliumClusterwideEnvoyConfigs: %w", err)
}
return nil
},
},
{
Description: "Collecting CiliumEnvoyConfigs",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.ListCiliumEnvoyConfigs(ctx, corev1.NamespaceAll, metav1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to collect CiliumEnvoyConfigs: %w", err)
}
if err := c.WriteYAML(ciliumEnvoyConfigsFileName, v); err != nil {
return fmt.Errorf("failed to collect CiliumEnvoyConfigs: %w", err)
}
return nil
},
},
{
Description: "Collecting Cilium etcd secret",
Quick: true,
Expand Down
15 changes: 15 additions & 0 deletions sysdump/sysdump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ type fakeClient struct {
nodeList *corev1.NodeList
}

func (c *fakeClient) ListCiliumClusterwideEnvoyConfigs(ctx context.Context, opts metav1.ListOptions) (*ciliumv2alpha1.CiliumClusterwideEnvoyConfigList, error) {
//TODO implement me
panic("implement me")
}

func (c *fakeClient) ListCiliumEnvoyConfigs(ctx context.Context, namespace string, options metav1.ListOptions) (*ciliumv2alpha1.CiliumEnvoyConfigList, error) {
//TODO implement me
panic("implement me")
}

func (c *fakeClient) ListIngresses(ctx context.Context, o metav1.ListOptions) (*networkingv1.IngressList, error) {
//TODO implement me
panic("implement me")
}

func (c *fakeClient) CopyFromPod(ctx context.Context, namespace, pod, container string, fromFile, destFile string) error {
panic("implement me")
}
Expand Down

0 comments on commit b827ee4

Please sign in to comment.