From e5fc7f9c6386446fb98b42c31da46bc9b63f734c Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Fri, 26 Oct 2018 19:27:13 -0700 Subject: [PATCH 1/4] drafting instructions to export config --- .../cloning-clusters/_index.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md diff --git a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md new file mode 100644 index 00000000000..e838fc0f397 --- /dev/null +++ b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md @@ -0,0 +1,54 @@ +--- +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 and RKE to export the cluster configuration, modify it to your liking, and then quickly launch the duplicate clusters using RKE. + +## Caveats + +Only [cluster types]({{< baseurl >}}/content/rancher/v2.x/en/cluster-provisioning) that interact with cloud hosts over API can be duplicated. Duplication of imported clusters and custom clusters provisioned using Docker machine is not supported. + +
Compatible Cluster Types
+ +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/ +[2]: {{< baseurl >}}/rancher/v2.x/en/cluster-provisioning/rke-clusters/node-pools/ +[3]: {{< baseurl >}}/rancher/v2.x/en/cluster-provisioning/custom-clusters/ +[4]: {{< baseurl >}}/rancher/v2.x/en/cluster-provisioning/imported-clusters/ + +## Prerequisites + +- Download and install [Rancher CLI]({{< baseurl >}}/rancher/v2.x/en/cli). +- Download and install [RKE]({{< baseurl >}}/rke/v0.1.x/en/installation/). + + +## A. Export Cluster Config + +1. Open Terminal and change your directory to the location of the Rancher CLI binary, `rancher`. + +1. Enter the following command to list the clusters managed by Rancher. + + ``` + ./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 ``, 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 existing + ``` + + +## B. Modify Cluster Config + +## C. Launch Duplicate Cluster \ No newline at end of file From 4ae59f6246ed5ce1d2a394ba4a875b03e10e06ff Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Mon, 29 Oct 2018 14:52:20 -0700 Subject: [PATCH 2/4] completing draft --- .../cloning-clusters/_index.md | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md index e838fc0f397..672caba748b 100644 --- a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md +++ b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md @@ -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 and RKE to export the cluster configuration, modify it to your liking, and then quickly launch the duplicate clusters using RKE. +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. ## Caveats @@ -45,10 +45,24 @@ Cluster Type | Cloneable? 1. Enter the following command to export the configuration for your cluster. ``` - ./rancher inspect --format yaml existing + ./rancher inspect --format yaml ``` + **Step Result:** The Docker Compose YAML for your cluster prints to Terminal. + +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). ## B. Modify Cluster Config -## C. Launch Duplicate Cluster \ No newline at end of file +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. + +For information on how to make these edits, see the [Docker Compose](https://docs.docker.com/compose/) documentation. + +## C. Launch Duplicate Cluster + +Move `cluster-template.yaml` into the same directory as the Rancher CLI binary. Then run this command: + + +``` +./rancher up --file rancher-cluster.yaml +``` \ No newline at end of file From 207c038c11ed8d9f6c18722e97715f026a4b95fe Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Wed, 31 Oct 2018 18:08:58 -0700 Subject: [PATCH 3/4] finishing draft of how to clone clusters with yaml --- .../cloning-clusters/_index.md | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md index 672caba748b..903789cb627 100644 --- a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md +++ b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md @@ -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
Compatible Cluster Types
-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 ``, 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 - ``` - **Step Result:** The Docker Compose YAML for your cluster prints to Terminal. + ./rancher clusters export -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 (``). If your cloned configuration has the same cluster name as its source, the cluster will not provision. + + Version: v3 + clusters: + : # 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 -``` \ No newline at end of file +**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. \ No newline at end of file From 8bb7037def6a2fdc9d40ecdece6f0171ec0f95d0 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Thu, 1 Nov 2018 10:50:35 -0700 Subject: [PATCH 4/4] completing draft --- .../cloning-clusters/_index.md | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md index 903789cb627..531fe538cf3 100644 --- a/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md +++ b/content/rancher/v2.x/en/cluster-provisioning/cloning-clusters/_index.md @@ -29,7 +29,7 @@ Only [cluster types]({{< baseurl >}}/content/rancher/v2.x/en/cluster-provisionin 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 +## 1. Export Cluster Config 1. Open Terminal and change your directory to the location of the Rancher CLI binary, `rancher`. @@ -47,11 +47,11 @@ Download and install [Rancher CLI]({{< baseurl >}}/rancher/v2.x/en/cli). Remembe ./rancher clusters export - **Step Result:** The Kubeconfig YAML for a duplicate cluster prints to Terminal. + **Step Result:** The 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 +## 2. Modify Cluster Config Use your favorite text editor to modify the cluster configuration in `cluster-template.yml` for your duplicate cluster. @@ -59,28 +59,30 @@ Use your favorite text editor to modify the cluster configuration in `cluster-te 1. Change the name of your cluster (``). If your cloned configuration has the same cluster name as its source, the cluster will not provision. - Version: v3 - clusters: - : # 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 + ```yml + Version: v3 + clusters: + : # 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/). + For information on how to make these edits, see the official [Kubernetes documentation](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/). -## C. Launch Duplicate Cluster +## 3. Launch Duplicate Cluster 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 cluster-template.yml -**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. \ No newline at end of file +**Result:** Your duplicate cluster begins provisioning. Enter `./rancher cluster ls` to confirm. You can also log into the Rancher UI and open the **Global** view to watch your provisioning cluster's progress. \ No newline at end of file