# How to Save Current State of Cluster Using Cluster-info Dump Command.

## Problem

A "cluster dump" typically refers to a process or action of collecting comprehensive diagnostic information and logs from a Kubernetes cluster. This is done to troubleshoot issues, investigate problems, or provide detailed information to the support team for debugging purposes. Cluster dumps are useful for understanding the state of a cluster and diagnosing problems that may arise during cluster operations.

Here are some common use cases and information that may be included in a cluster dump:

1. **Logging**: Cluster dumps often include logs from various components of the Kubernetes cluster, such as control plane components (API server, etcd), worker nodes, and other add-ons (e.g., kube-proxy, kube-dns). These logs can help identify errors, warnings, and other relevant information.
2. **Resource Information**: Information about cluster resources, including nodes, pods, services, and configurations, may be included in a cluster dump. This can provide insights into the current state of the cluster and resource allocation.
3. **Configuration**: The cluster dump may contain configuration files and settings for various Kubernetes components. This can help identify any discrepancies or misconfigurations that could be causing issues.
4. **Cluster Metrics**: Cluster dumps may include metrics and statistics about cluster performance and resource usage. This information can be valuable for performance analysis and optimization.
5. **Network Information**: Details about networking configurations, routes, and network policies may be included. Network-related issues can often be diagnosed with this information.
6. **Event Logs**: Kubernetes events and audit logs may be part of the cluster dump. These logs can provide a historical record of cluster activity and events.
7. **Cluster State**: Information about the current state of objects in the cluster, such as pod statuses, node conditions, and API server status, can help diagnose problems and understand the overall health of the cluster.

Environment

* Platform9 Managed Kubernetes - v-5.4 and Higher

## Procedure

Th below command will save the information from all namespaces including customer's namespaces]:

{% tabs %}
{% tab title="Cluster dump command" %}

```javascript
# kubectl cluster-info dump -A  -o yaml --output-directory=/tmp/cluster-dump-$(date +%Y-%m-%d_%H-%M)
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Warning**

If there are sensitive/confidential applications running in the cluster it is recommended to avoid using "-A" in the above command which will take dump from all the namespaces including the application namespaces.

It is recommended to take clusterdump from the namespace which is having the issue. For that replace "-A" with "-n \<affected\_namespace>" in the above command.
{% endhint %}

The contents created as part of the cluster dump will be:

{% tabs %}
{% tab title="Contents" %}

```javascript
# ls -lsh /tmp/cluster-dump-2022-12-02_07-03
total 32K
   0 drwxr-xr-x  2 root root  170 Dec  2 07:03 default
   0 drwxr-xr-x  2 root root  170 Dec  2 07:03 kube-node-lease
   0 drwxr-xr-x  2 root root  170 Dec  2 07:03 kube-public
   0 drwxr-xr-x  4 root root  265 Dec  2 07:03 kubernetes-dashboard
4.0K drwxr-xr-x 20 root root 4.0K Dec  2 07:03 kube-system
 24K -rw-r--r--  1 root root  23K Dec  2 07:03 nodes.yaml
   0 drwxr-xr-x  3 root root  212 Dec  2 07:03 pf9-addons
4.0K drwxr-xr-x  9 root root 4.0K Dec  2 07:03 pf9-monitoring
   0 drwxr-xr-x  4 root root  248 Dec  2 07:03 pf9-operators
   0 drwxr-xr-x  3 root root  212 Dec  2 07:03 platform9-system
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Size of folder" %}

```javascript
# du -sch /tmp/cluster-dump-2022-12-02_07-03
16M	/tmp/cluster-dump-2022-12-02_07-03
16M	total
```

{% endtab %}
{% endtabs %}

## Additional Information

For reference:

1. [Troubleshooting a cluster](https://platform9.com/docs/PEC/troubleshooting-a-cluster#node-config).
2. [Kubernetes documentation.](https://kubernetes.io/docs/tasks/debug/debug-cluster/#listing-your-cluster)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmk/how-to/how-to-save-current-state-of-cluster-using-cluster-dump-command.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
