CLI for Cluster Template
For purposes of automation, it is strongly recommended that users create and manage version controlled "cluster templates" to provision and manage the lifecycle of clusters. This is well suited for scenarios where the multiple cluster creation is required with the same configuration
Step 1: Create Cluster Template¶
Command to create Cluster Template:
./rctl apply -f <clustertemplate.yaml>
Below is an example of yaml file to create a cluster template named demotest with the configuration details provided in Step 1
kind: ClusterTemplate
metadata:
name: demotest
description: 'Creating demo-template'
clusterType: eks
To create this cluster template, use the command
./rctl apply -f demo-template.yaml
Output
{
"id": "yemp028",
"name": "demotest",
"description": "Creating demo-template",
"cluster_type": "eks",
"created_at": "2022-01-25T09:52:19.061555Z",
"modified_at": "2022-01-25T09:52:19.061555Z",
"organization_id": "9dk3emn",
"partner_id": "rx28oml",
"project_id": "pkv40kn",
"request_type": "TEMPLATE_FILE",
"input_template": "kind: ClusterTemplate\nmetadata:\n clusterType: eks\n description: Creating demo-template\n name: demotest\n"
}
Step 2: Create Cluster Template Snapshot¶
Command to create cluster Template Snapshot:
./rctl apply -f <clustertemplatesnapshot.yaml>
Below is an example of a cluster template snapshot yaml file named "demo_template.yaml". This configuration file is to set the required parameters on the cluster template. Users can modify these parameters when required and create multiple versions
kind: ClusterTemplateSnapshot
metadata:
description: Creating ct1
templateName: demotest
project: defaultproject
name: v1
parameters:
region:
default: us-west-1
override:
allow: true
values: ["us-west-1", "us-west-2"]
instanceType:
default: t3.small
override:
allow: false
dummy:
default: t3.medium
override:
allow: true
spec:
blueprint: default
blueprintversion: latest
cloudprovider: democred
config:
metadata:
region: '{{ region }}'
tags:
a: b
version: "1.20"
nodeGroups:
- instanceType: '{{ instanceType }}'
name: name1
privateNetworking: false
- instanceType: '{{ dummy }}'
name: name2
type: eks
Important
Users can parameterize the fields in the template with overrides and restricted values. In the above config file, the parameterized fields are maxSize, instanceType, region within the double curly braces
To create this cluster template snapshot, use the command
./rctl apply -f demo-template.yaml
Output
{
"id": "9d2wyk8",
"template_id": "yemp028",
"template_name": "demotest",
"name": "v1",
"cluster_type": "eks",
"created_at": "2022-01-25T09:53:25.474688Z",
"modified_at": "2022-01-25T09:53:25.474688Z",
"project_id": "pkv40kn",
"partner_id": "rx28oml",
"organization_id": "9dk3emn",
"request_type": "TEMPLATE_FILE",
"cloud_credential": "democred",
"blueprint_name": "default",
"blueprint_version": "latest",
"gen_template": "kind: ClusterTemplateSnapshot\nmetadata:\n description: Creating ct1\n name: v1\n project: defaultproject\n templateName: demotest\nparameters:\n dummy:\n default: t3.medium\n override:\n allow: true\n instanceType:\n default: t3.small\n override:\n allow: false\n region:\n default: us-west-1\n override:\n allow: true\n values:\n - us-west-1\n - us-west-2\nspec:\n blueprint: default\n blueprintversion: latest\n cloudprovider: democred\n config:\n metadata:\n region: '{{ region }}'\n tags:\n a: b\n version: \"1.20\"\n nodeGroups:\n - instanceType: '{{ instanceType }}'\n name: name1\n privateNetworking: false\n - instanceType: '{{ dummy }}'\n name: name2\n type: eks\n",
"input_template": "kind: ClusterTemplateSnapshot\nmetadata:\n description: Creating ct1\n name: v1\n project: defaultproject\n templateName: demotest\nparameters:\n dummy:\n default: t3.medium\n override:\n allow: true\n instanceType:\n default: t3.small\n override:\n allow: false\n region:\n default: us-west-1\n override:\n allow: true\n values:\n - us-west-1\n - us-west-2\nspec:\n blueprint: default\n blueprintversion: latest\n cloudprovider: democred\n config:\n metadata:\n region: '{{ region }}'\n tags:\n a: b\n version: \"1.20\"\n nodeGroups:\n - instanceType: '{{ instanceType }}'\n name: name1\n privateNetworking: false\n - instanceType: '{{ dummy }}'\n name: name2\n type: eks\n",
"publish": true
}
Step 3: Create Cluster out of template¶
Command to create cluster out of template:
./rctl apply -f <cluster.yaml>
An example of a yaml file named demo-cluster.yaml to create a cluster using the template created in Step 2:
kind: Cluster
metadata:
description: ""
name: demo-cluster
project: defaultproject
spec:
clusterTemplateRef:
name: demotest
version: v1
values:
region: us-west-2
where name: demo-template is the selected template for the new cluster
To create a cluster out of template, use the command
./rctl apply -f demo-cluster.yaml
Output
{
"taskset_id": "dkgv8kx",
"operations": [
{
"operation": "NodegroupCreation",
"resource_name": "name1",
"status": "PROVISION_TASK_STATUS_PENDING"
},
{
"operation": "NodegroupCreation",
"resource_name": "name2",
"status": "PROVISION_TASK_STATUS_PENDING"
},
{
"operation": "ClusterCreation",
"resource_name": "demo-cluster",
"status": "PROVISION_TASK_STATUS_PENDING"
}
],
"comments": "The status of the operations can be fetched using taskset_id",
"status": "PROVISION_TASKSET_STATUS_PENDING"
}
To know the status of the cluster template apply operation, enter the below command with the generated task id dkgv8kx
./rctl status apply dkgv8kx
Share Cluster Template¶
- Command to block sharing the cluster template to any project
./rctl share clustertemplate <template-name> --none
- Command to share the cluster template to all the projects
./rctl share clustertemplate <template-name> --all-projects
- Command to share the cluster template to a specific projects
./rctl share clustertemplate <template-name> --projects <project1>,<project2>
- Command to assign/unassign the cluster template from/to one or more project(s)
./rctl share clustertemplate <template-name> --unassign-projects <project1>,<project2>
Get Cluster Templates¶
- Command to get the list of cluster template details:
./rctl get clustertemplate
./rctl get clustertemplate <template-name>
Example:
./rctl get clustertemplate demotest
Output
{
"count": 1,
"results": [
{
"id": "yemp028",
"name": "demotest",
"cluster_type": "eks",
"created_at": "2022-01-25T09:52:19.061555Z",
"modified_at": "2022-01-25T09:52:19.061555Z",
"organization_id": "9dk3emn",
"partner_id": "rx28oml",
"project_id": "pkv40kn",
"request_type": "TEMPLATE_FILE",
"input_template": "kind: ClusterTemplate\nmetadata:\n clusterType: eks\n description: Creating demo-template\n name: demotest\n"
}
]
}
- Command to get all Cluster Template Snapshots:
./rctl get clustertemplatesnapshot <template-name>
- Command to get a Cluster Template Snapshot with a specific version
./rctl get clustertemplatesnapshot <template-name> <versionname>
Example:
./rctl get clustertemplatesnapshot demotest v1
Output
{
"count": 1,
"results": [
{
"id": "9d2wyk8",
"template_id": "yemp028",
"template_name": "demotest",
"name": "v1",
"cluster_type": "eks",
"created_at": "2022-01-25T09:53:25.474688Z",
"modified_at": "2022-01-25T09:53:25.474688Z",
"organization_id": "9dk3emn",
"partner_id": "rx28oml",
"project_id": "pkv40kn",
"request_type": "TEMPLATE_FILE",
"cloud_credential": "democred",
"blueprint_name": "default",
"blueprint_version": "latest",
"gen_template": "kind: ClusterTemplateSnapshot\nmetadata:\n description: Creating ct1\n name: v1\n project: defaultproject\n templateName: demotest\nparameters:\n dummy:\n default: t3.medium\n override:\n allow: true\n instanceType:\n default: t3.small\n override:\n allow: false\n region:\n default: us-west-1\n override:\n allow: true\n values:\n - us-west-1\n - us-west-2\nspec:\n blueprint: default\n blueprintversion: latest\n cloudprovider: democred\n config:\n metadata:\n region: '{{ region }}'\n tags:\n a: b\n version: \"1.20\"\n nodeGroups:\n - instanceType: '{{ instanceType }}'\n name: name1\n privateNetworking: false\n - instanceType: '{{ dummy }}'\n name: name2\n type: eks\n",
"input_template": "kind: ClusterTemplateSnapshot\nmetadata:\n description: Creating ct1\n name: v1\n project: defaultproject\n templateName: demotest\nparameters:\n dummy:\n default: t3.medium\n override:\n allow: true\n instanceType:\n default: t3.small\n override:\n allow: false\n region:\n default: us-west-1\n override:\n allow: true\n values:\n - us-west-1\n - us-west-2\nspec:\n blueprint: default\n blueprintversion: latest\n cloudprovider: democred\n config:\n metadata:\n region: '{{ region }}'\n tags:\n a: b\n version: \"1.20\"\n nodeGroups:\n - instanceType: '{{ instanceType }}'\n name: name1\n privateNetworking: false\n - instanceType: '{{ dummy }}'\n name: name2\n type: eks\n",
"publish": true
}
]
}
Delete Cluster Template and Snapshot¶
- Command to delete a cluster template
./rctl delete clustertemplate <template-name>
Example:
./rctl delete clustertemplate demotest
Output
Deleted demotest
Important
Deleting a cluster template deletes all the cluster template snapshots under this specific template
- Command to delete a cluster template snapshot
./rctl delete clustertemplatesnapshot <template-name> <clustersnapshot-name>
Example:
./rctl delete clustertemplatesnapshot demotest v1
Output
Deleted v1
Note: Users cannot delete a cluster template which is associated with a cluster