// Module included in the following assemblies:
//
// * hosted_control_planes/hcp-troubleshooting.adoc

:_mod-docs-content-type: PROCEDURE
[id="hcp-must-gather-cli_{context}"]
= Gathering data for a hosted cluster by using the CLI

[role="_abstract"]
You can gather {product-title} debugging information for a hosted cluster by using the command-line interface (CLI).

.Prerequisites

* You must have `cluster-admin` access to the management cluster.

* You need the `name` value for the `HostedCluster` resource and the namespace where the CR is deployed.

* You must have the `hcp` command-line interface installed. For more information, see "Installing the {hcp} command-line interface".

* You must have the OpenShift CLI (`oc`) installed.

* You must ensure that the `kubeconfig` file is loaded and is pointing to the management cluster.

.Procedure

. Generate the `kubeconfig` file by entering the following command:
+
[source,terminal]
----
$ hcp create kubeconfig --namespace <hosted_cluster_namespace> \
  --name <hosted_cluster_name> > <hosted_cluster_name>.kubeconfig
----

. After you save the `kubeconfig` file, you can access the hosted cluster by entering the following example command:
+
[source,terminal]
----
$ oc --kubeconfig <hosted_cluster_name>.kubeconfig get nodes
----

. Collect the must-gather information by entering the following command:
+
[source,terminal]
----
$ oc adm must-gather
----
