Examples
Infra GitOps using RCTL¶
Here are some of the examples to scale an existing cluster through Infra GitOps using RCTL
Below is a cluster config sample yaml file
apiVersion: rafay.io/v1alpha1
kind: Cluster
metadata:
name: demo-akscluster
project: defaultproject
spec:
blueprint: default-aks
blueprintversion: latest
cloudprovider: akscredentials
clusterConfig:
apiVersion: rafay.io/v1alpha1
kind: aksClusterConfig
metadata:
name: demo-akscluster
spec:
managedCluster:
additionalMetadata:
acrProfile:
acrName: demo_registry
resourceGroupName: demoresoursegroup
apiVersion: "2021-05-01"
identity:
type: SystemAssigned
location: eastus2
properties:
apiServerAccessProfile:
enablePrivateCluster: false
dnsPrefix: demo-akscluster-dns
kubernetesVersion: 1.21.2
networkProfile:
loadBalancerSku: standard
networkPlugin: kubenet
networkPolicy: calico
sku:
name: Basic
tier: Free
tags:
role: demo
type: Microsoft.ContainerService/managedClusters
nodePools:
- apiVersion: "2021-05-01"
location: eastus2
name: primary
properties:
count: 1
enableAutoScaling: true
maxCount: 2
maxPods: 40
minCount: 1
mode: System
nodeLabels:
testdemo: demoworker
orchestratorVersion: 1.21.2
osType: Linux
type: VirtualMachineScaleSets
vmSize: Standard_DS2_v2
type: Microsoft.ContainerService/managedClusters/agentPools
resourceGroupName: demoresoursegroup
proxyconfig: {}
type: aks
Command to create a cluster using the config file:
./rctl apply -f <config-file.yaml>
Example:
./rctl apply -f demo-akscluster.yaml
Expected Output (with a task id):
{
"taskset_id": "dk3lekn",
"operations": [
{
"operation": "NodegroupCreation",
"resource_name": "primary",
"status": "PROVISION_TASK_STATUS_PENDING"
},
{
"operation": "ClusterCreation",
"resource_name": "demo-akscluster",
"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 creation operation, enter the below command with the generated task id
./rctl status apply dk3lekn
Expected Output
{
"taskset_id": "dk3lekn",
"operations": [
{
"operation": "NodegroupCreation",
"resource_name": "pool1",
"status": "PROVISION_TASK_STATUS_PENDING"
},
{
"operation": "ClusterCreation",
"resource_name": "demo-akscluster",
"status": "PROVISION_TASK_STATUS_PENDING"
}
],
"comments": "Configuration is applied to the cluster successfully",
"status": "PROVISION_TASKSET_STATUS_COMPLETE"
Cluster Sharing¶
For cluster sharing, add a new block to the cluster config (Rafay Spec) as highlighted in the below config file
apiVersion: rafay.io/v1alpha1
kind: Cluster
metadata:
name: aks-democluster
project: defaultproject
spec:
blueprint: bp-aks
blueprintversion: v5
cloudprovider: cp_aks
sharing:
enabled: true
projects:
- name: "demoproject1"
- name: "demoproject2"
clusterConfig:
apiVersion: rafay.io/v1alpha1
kind: aksClusterConfig
metadata:
name: aks-democluster
spec:
managedCluster:
apiVersion: "2021-05-01"
identity:
type: SystemAssigned
location: centralindia
properties:
apiServerAccessProfile:
enablePrivateCluster: false
dnsPrefix: aks-dns-demo
kubernetesVersion: 1.22.11
networkProfile:
loadBalancerSku: standard
networkPlugin: kubenet
sku:
name: Basic
tier: Free
type: Microsoft.ContainerService/managedClusters
nodePools:
- apiVersion: "2021-05-01"
location: centralindia
name: primary
properties:
count: 1
enableAutoScaling: true
maxCount: 1
maxPods: 40
minCount: 1
mode: System
orchestratorVersion: 1.22.11
osType: Linux
type: VirtualMachineScaleSets
vmSize: Standard_DS2_v2
type: Microsoft.ContainerService/managedClusters/agentPools
resourceGroupName: demo_group
proxyconfig: {}
type: aks
You can also use the wildcard operator "*" to share the cluster across projects
sharing:
enabled: true
projects:
- name: "*"
Notes: When passing the wildcard operator, users cannot pass other projects name
To remove any cluster sharing from the project(s), remove that specific project name(s) and run the apply command
Update Blueprint¶
Make the required change for Blueprint and use the command
./rctl apply -f demo-akscluster.yaml
Expected output (with a task id):
{
"taskset_id": "g29wek0",
"operations": [
{
"operation": "BlueprintUpdation",
"resource_name": "demo-akscluster",
"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 Blueprint apply operation, enter the below command with the generated task id
./rctl status apply g29wek0
Expected Output
{
"taskset_id": "g29wek0",
"operations": [
{
"operation": "BlueprintUpdation",
"resource_name": "demo-akscluster",
"status": "PROVISION_TASK_STATUS_SUCCESS"
}
],
"comments": "Configuration is applied to the cluster successfully",
"status": "PROVISION_TASKSET_STATUS_COMPLETE"
Update Cloud Credential¶
Make the required change for Cloud Credential and use the command
./rctl apply -f demo-akscluster.yaml
Expected output (with a task id):
{
"taskset_id": "j2q9jm9",
"operations": [
{
"operation": "CloudProviderUpdation",
"resource_name": "demo-akscluster",
"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 Cloud Credential apply operation, enter the below command with the generated task id
./rctl status apply j2q9jm9
Expected output
{
"taskset_id": "j2q9jm9",
"operations": [
{
"operation": "CloudProviderUpdation",
"resource_name": "demo-akscluster",
"status": "PROVISION_TASK_STATUS_SUCCESS"
}
],
"comments": "Configuration is applied to the cluster successfully",
"status": "PROVISION_TASKSET_STATUS_COMPLETE"
Cluster Labels¶
Users can update Cluster Labels via RCTL using the below Cluster Configuration Yaml file
apiVersion: rafay.io/v1alpha1
kind: Cluster
metadata:
labels:
newrole: cluslab1
roles: worker1
name: newrole_1
project: defaultproject
spec:
blueprint: default-aks
blueprintversion: latest
cloudprovider: aks-cloudcred
clusterConfig:
apiVersion: rafay.io/v1alpha1
kind: aksClusterConfig
metadata:
name: demo-akscluster
...
Command to apply the labels to the cluster:
./rctl apply -f <cluster-config.yaml>
Example:
./rctl apply -f demo-akscluster.yaml
Expected output (with a task id):
{
"taskset_id": "lk5dwme",
"operations": [
{
"operation": "ClusterLabelsUpdation",
"resource_name": "demo-akscluster",
"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 Label apply operation, enter the below command with the generated task id
./rctl status apply lk5dwme
Expected output:
{
"taskset_id": "lk5dwme",
"operations": [
{
"operation": "ClusterLabelsUpdation",
"resource_name": "demo-akscluster",
"status": "PROVISION_TASK_STATUS_SUCCESS"
}
],
"comments": "Configuration is applied to the cluster successfully",
"status": "PROVISION_TASKSET_STATUS_COMPLETE"