If your original cluster configuration files are missing or out of sync with
the current state of a cluster, the `gkectl get-config` command lets you
generate a new set of files that accurately represents the cluster. This
document shows you how to generate configuration files for admin and user
clusters and lists the files that the command generates.

## About generated configuration files

One way to create a cluster is to use the `gkectl` command-line tool. First you
create a set of configuration files for the cluster. Then you run
`gkectl create admin` to create an admin cluster or `gkectl create cluster` to
create a user cluster.

Over time, your original configuration files might become out of sync with the
actual state of your cluster. For example, if you update a cluster by editing a
custom resource, then your original configuration files might not be an
accurate representation of the cluster.

If you create a cluster by using the Google Cloud console, you don't have any
cluster configuration files. Later, you might need cluster configuration files
so that you can make certain updates to the cluster.

In either case, you can use `gkectl get-config` to generate configuration files
that match the current state of the cluster.

> [!NOTE]
> **Note:** `gkectl get-config` doesn't support clusters that use [topology domains](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/topology-domains-set-up.md.txt). This limitation applies to an admin cluster that has `infraConfigFilePath` set in its configuration file and to all user clusters that the admin cluster manages. If you run `gkectl get-config` for these clusters, the command fails. Instead, keep the configuration files that you use to create and update these clusters, including the [vSphere infrastructure configuration file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/reference/vsphere-infrastructure-configuration-file.md.txt) and [IP block files](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/ip-block-file.md.txt).

## Generate configuration files

To generate a new set of configuration files for a user cluster:

```
gkectl get-config cluster --kubeconfig ADMIN_CLUSTER_KUBECONFIG \
    --cluster-name USER_CLUSTER_NAME
```

Replace the following:

- <var translate="no">ADMIN_CLUSTER_KUBECONFIG</var>: the path of the kubeconfig file for the
  admin cluster

- <var translate="no">USER_CLUSTER_NAME</var>: the name of the user cluster

To generate a new set of configuration files for an admin cluster:

```
gkectl get-config admin --kubeconfig ADMIN_CLUSTER_KUBECONFIG \
    --bundle-path BUNDLE
```

Replace the following:

- <var translate="no">ADMIN_CLUSTER_KUBECONFIG</var>: the kubeconfig file for the admin cluster

- <var translate="no">BUNDLE</var>: the path of the Google Distributed Cloud software only for VMware bundle file. The
  bundle file is on your admin workstation, typically at
  `/var/lib/gke/bundles/gke-onprem-vsphere-VERSION-full.tgz`.
  If you don't already have a bundle file, you can
  [download one](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/downloads.md.txt#bundle).

By default, the generated configuration files are written to a subdirectory of
the current directory. For a user cluster, the output directory is named
`user-cluster-config-output`. For an admin cluster, the output directory is
named `admin-cluster-config-output`.

If you prefer to have the generated files in a different directory, you can
use the `--output-dir` parameter to specify the path of an output directory.
For example:

```
gkectl get-config cluster --kubeconfig my-kubeconfig \
    --cluster-name my-cluster \
    --output-dir /home/me/configuration/generated-files
```

If there are already files in the default output directory or a specified output
directory, you must include the `--force` flag so that the newly generated files
will replace the existing files. Otherwise the command will fail. For example:

```
gkectl get-config cluster --kubeconfig my-kubeconfig \
    --cluster-name my-cluster \
    --output-dir /home/me/configuration/generated-files \
    --force
```

## Generated files for an admin cluster

| Filename | Description |
|---|---|
| `admin-cluster.yaml` | [Admin cluster configuration file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/admin-cluster-configuration-file-latest.md.txt) Always generated |
| `admin-cluster-creds.yaml` | [Cluster credentials file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/credentials-configuration-file.md.txt) Always generated |
| `component-access-key.json` | JSON key file for your [component access service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#component_access_service_account) Always generated |
| `vcenter-ca-cert.pem` | [Root certificate](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/vcenter-ca-cert-path.md.txt) for your vCenter Server Always generated |
| `admin-cluster-ipblock.yaml` | [IP block file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/ip-block-file.md.txt) for cluster nodes Generated if the cluster nodes use [static IP addresses](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/admin-cluster-configuration-file-latest.md.txt#network-ipmode-type-field) |
| `connect-register-key.json` | JSON key file for your [connect register service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#connect_register_service_account) Always generated |
| `private-registry-ca.crt` | Root certificate for your private registry server Generated if the cluster uses a [private registry](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/admin-cluster-configuration-file-latest.md.txt#privateregistry-cacertpath-field) |
| `stackdriver-key.json` | JSON key file for your [logging monitoring service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#logging_monitoring_service_account) Generated if the cluster is configured to export logs and metrics to [Cloud Logging](https://docs.cloud.google.com/logging/docs.md.txt) and [Cloud Monitoring](https://docs.cloud.google.com/monitoring/docs.md.txt) (`stackdriver` section in the cluster configuration file) |
| `audit-logging-key.json` | JSON key file for your [audit logging service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#audit_logging_service_account) Generated if the cluster uses Cloud Audit Logs |

## Generated files for a user cluster

| Filename | Description |
|---|---|
| `user-cluster.yaml` | [User cluster configuration file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/user-cluster-configuration-file-latest.md.txt) Always generated |
| `user-cluster-creds.yaml` | [Cluster credentials file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/credentials-configuration-file.md.txt) Generated if the cluster is not using prepared credentials |
| `vcenter-ca-cert.pem` | [Root certificate](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/vcenter-ca-cert-path.md.txt) for your vCenter Server Always generated |
| `user-cluster-ipblock.yaml` | [IP block file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/ip-block-file.md.txt) for cluster nodes Generated if the cluster nodes use [static IP addresses](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/user-cluster-configuration-file-latest.md.txt#network-ipmode-type-field) |
| `private-registry-ca.crt` | Root certificate for your private registry server Generated if the cluster uses a [private registry](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/user-cluster-configuration-file-latest.md.txt#privateregistry-cacertpath-field) |
| `component-access-key.json` | JSON key file for your [component access service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#component_access_service_account) Generated if the cluster is not using a private registry |
| `connect-register-key.json` | JSON key file for your [connect register service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#connect_register_service_account) Always generated |
| `stackdriver-key.json` | JSON key file for your [logging monitoring service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#logging_monitoring_service_account) Generated if the cluster is configured to export logs and metrics to [Cloud Logging](https://docs.cloud.google.com/logging/docs.md.txt) and [Cloud Monitoring](https://docs.cloud.google.com/monitoring/docs.md.txt) (`stackdriver` section in the cluster configuration file) |
| `audit-logging-key.json` | JSON key file for your [audit logging service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#audit_logging_service_account) Generated if the cluster uses Cloud Audit Logs |
| `usage-metering-key.json` | JSON key file for your [usage metering service account](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/service-accounts.md.txt#usage_metering_service_account) Generated if the cluster stores usage data in a BigQuery dataset |
| `secrets.yaml` | [Secrets configuration file](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/secrets-configuration-file.md.txt) Generated if the cluster uses [prepared credentials](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/prepared-credentials.md.txt) For this file to be generated, you must include the `--export-secrets-config` flag in the `gkectl get-config cluster` command. |
| `sni-cert.pem` | Additional serving certificate for the Kubernetes API server Generated if the cluster is configured to use [Server Name Indication (SNI)](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/vmware/docs/how-to/user-cluster-configuration-file-latest.md.txt#authentication-sni-section) |
| `sni-key.json` | Private key file for the additional serving certificate Generated if the cluster is configured to use SNI |