finishing draft of how to clone clusters with yaml

This commit is contained in:
Mark Bishop
2018-10-31 18:08:58 -07:00
parent 4ae59f6246
commit 207c038c11
@@ -3,7 +3,7 @@ title: Duplicating Clusters
weight: 2400
---
If you have a cluster in Rancher that you want to use as a template for creating similar clusters, you can use Rancher CLI to duplicate the cluster's Compose file, edit it, and then use it to quickly launch the duplicate cluster.
If you have a cluster in Rancher that you want to use as a template for creating similar clusters, you can use Rancher CLI to duplicate the cluster's configuration, edit it, and then use it to quickly launch the duplicate cluster.
## Caveats
@@ -11,12 +11,12 @@ Only [cluster types]({{< baseurl >}}/content/rancher/v2.x/en/cluster-provisionin
<figcaption>Compatible Cluster Types</figcaption>
Cluster Type | Cloneable?
-------------|-------------
[Hosted Kubernetes Providers][1] | ✓
[Nodes Hosted by IaaS][2] | ✓
[Custom Cluster][3] |
[Imported Cluster][4] |
| Cluster Type | Cloneable? |
| -------------------------------- | ------------- |
| [Hosted Kubernetes Providers][1] | ✓ |
| [Nodes Hosted by IaaS][2] | ✓ |
| [Custom Cluster][3] | |
| [Imported Cluster][4] | |
[1]: {{< baseurl >}}/rancher/v2.x/en/cluster-provisioning/hosted-kubernetes-clusters/
@@ -26,8 +26,7 @@ Cluster Type | Cloneable?
## Prerequisites
- Download and install [Rancher CLI]({{< baseurl >}}/rancher/v2.x/en/cli).
- Download and install [RKE]({{< baseurl >}}/rke/v0.1.x/en/installation/).
Download and install [Rancher CLI]({{< baseurl >}}/rancher/v2.x/en/cli). Remember to [create an API bearer token]({{< baseurl >}}/rancher/v2.x/en/user-settings/api-keys) if necessary.
## A. Export Cluster Config
@@ -36,33 +35,52 @@ Cluster Type | Cloneable?
1. Enter the following command to list the clusters managed by Rancher.
```
./rancher cluster ls
```
./rancher cluster ls
1. Find the cluster that you want to clone, and copy either its resource `ID` or `NAME` to your clipboard. From this point on, we'll refer to the resource `ID` or `NAME` as `<RESOURCE_ID>`, which is used as a placeholder in the next step.
1. Enter the following command to export the configuration for your cluster.
```
./rancher inspect --format yaml <RESOURCE_ID>
```
**Step Result:** The Docker Compose YAML for your cluster prints to Terminal.
./rancher clusters export <RESOURCE_ID>
1. Copy the YAML to your clipboard and paste it in a new file. Save the file as `cluster-template.yaml` (or any other name, as long as it has a `.yaml` extension).
**Step Result:** The Kubeconfig YAML for a duplicate cluster prints to Terminal.
1. Copy the YAML to your clipboard and paste it in a new file. Save the file as `cluster-template.yml` (or any other name, as long as it has a `.yml` extension).
## B. Modify Cluster Config
Use your favorite text editor to modify the configuration in `cluster-template.yaml` for your duplicate cluster. Save the configuration changes when you're done.
Use your favorite text editor to modify the cluster configuration in `cluster-template.yml` for your duplicate cluster.
For information on how to make these edits, see the [Docker Compose](https://docs.docker.com/compose/) documentation.
1. Open `cluster-template.yml` (or whatever you named your config) in your favorite test editor.
1. Change the name of your cluster (`<CLUSTER_NAME>`). If your cloned configuration has the same cluster name as its source, the cluster will not provision.
Version: v3
clusters:
<CLUSTER_NAME>: # CHANGE THIS NAME
amazonElasticContainerServiceConfig:
accessKey: 00000000000000000000
associateWorkerNodePublicIp: true
instanceType: t2.medium
maximumNodes: 3
minimumNodes: 1
region: us-west-2
secretKey: 0000000000000000000000000000000000000000
dockerRootDir: /var/lib/docker
enableNetworkPolicy: false
1. Edit any other configuration values to customize the cloned cluster. Save the configuration when you're done.
For information on how to make these edits, see the official Kubernetes [Kubeconfig documentation](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/).
## C. Launch Duplicate Cluster
Move `cluster-template.yaml` into the same directory as the Rancher CLI binary. Then run this command:
Move `cluster-template.yml` into the same directory as the Rancher CLI binary. Then run this command:
./rancher up --file rancher-cluster.yml
```
./rancher up --file rancher-cluster.yaml
```
**Result:** Your duplicate cluster begins provisioning. Enter `./rancher cluster ls` to confirm. Log into the Rancher UI and open the **Global** view to watch your provisioning cluster's progress.