ROS Operator
Resource Orchestration Service (ROS) Operator is a type of Kubernetes operator that Alibaba Cloud develops and integrates with ROS to help you define, create, and manage Alibaba Cloud resources in Container Service for Kubernetes (ACK) clusters.
Prerequisites
An ACK cluster is created. For more information, see Create a cluster.
The permissions on ROS and other related resources are granted to the ACK cluster. The permissions to manage the resources in a ROS stack are granted to the stack. For more information, see How do I assign a custom RAM role to an ACK cluster? You can also refer to the information described in the "Authorization" section of this topic.
kubectl is installed, configured, and connected to the ACK cluster. For more information, see the "kubectl" section of the Install Tools topic and Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.
Helm 3 is installed and configured. For more information, see Installing Helm.
ImportantIf the installed Helm version is earlier than Helm 3, you must initialize the Helm environment for connection to the cluster.
Install ROS Operator
Add the custom repository of the ros-operator plug-in
Install the
helm-acrplug-in.helm plugin install https://github.com/AliyunContainerService/helm-acrAdd the custom repository of the
ros-operatorplug-in.helm repo add ros-operator acr://aliyun-computenest-opensource-chart.cn-hangzhou.cr.aliyuncs.com/default/aliyun-ros-operator
Install the ros-operator plug-in
Install the plug-in of a desired version.
Latest version
helm install ros-operator ros-operator/ros-operatorSpecified version
helm install ros-operator ros-operator/ros-operator --version 0.0.2Define custom values for variables.
You can define custom values for the default variables, such as the image name, tag, and resource limit variables, by using the
values.ymlfile. Run the following command after you configure the file:helm install ros-operator -f your_values.yml ros-operator/ros-operator
(Optional) Delete the plug-in
Run the following command to delete the ros-operator plug-in if you no longer require the plug-in:
helm delete ros-operatorManage a ROS stack
Create a stack
Create the stack-sample.yml file.
touch stack-sample.ymlEdit the stack-sample.yml file.
Run the following command to enter the edit mode of the file:
vim stack-sample.ymlEnter the following sample ROS template in templateContent of the stack-sample.yml file. The template is used to create an Elastic Compute Service (ECS) instance, and the virtual private cloud (VPC), vSwitch, and security group of the instance. For more information about how to create a ROS template that is used to create Alibaba Cloud resources, see Getting started with template creation.
apiVersion: batch.operator.ros.io/v1 kind: RosStack metadata: name: sample-stack-ecs-instance-with-vpc labels: app: ecs_instance_with_vpc spec: templateContent: | ROSTemplateFormatVersion: '2015-09-01' Description: Creates VPC ECS instance Parameters: InstanceImageId: Default: centos_7 Type: String Description: zh-cn: >- en: >- Image ID, see detail:<b><a href='https://www.alibabacloud.com/help/en/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b> Label: en: Image SystemDiskCategory: Default: cloud_ssd Label: en: System Disk Type Type: String Description: zh-cn: >- en: >- <font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>] AllowedValues: - cloud_auto - cloud_efficiency - cloud_ssd - cloud - cloud_essd - ephemeral_ssd SystemDiskSize: Default: 20 Type: Number Description: ' en: 'System disk size, range of values: 20-500, units: GB.' Label: en: System Disk Space InstancePassword: Type: String Description: zh-cn: >- en: >- Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in). MinLength: 8 Label: en: Instance Password NoEcho: true MaxLength: 30 ConstraintDescription: ' en: >- Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in). InstanceType: AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType' AssociationPropertyMetadata: ZoneId: VSwitchZoneId Type: String Description: zh-cn: >- en: >- Fill in the specifications that can be used under the VSwitch availability zone.</b></font><br>general specifications:<font color='red'><b>ecs.c5.large</b></font><br>note: a few zones do not support general specifications<br>see detail: <a href='https://www.alibabacloud.com/help/en/doc-detail/25378.html' target='_blank'><b><font color='blue'>Instance Specification Family</font></a></b> Label: en: Instance Type VSwitchZoneId: AssociationProperty: 'ALIYUN::ECS::Instance:ZoneId' Type: String Description: zh-cn: >- en: >- Availability Zone ID.<br><b>note:<font color='blue'>before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources,which is recommended to be different from other VSwitch Availability Zone</font></b> Label: en: VSwitch Availability Zone InstancePublicIP: Default: false Type: Boolean Description: en: Whether to assign a common IP. Label: en: Allocate Public IP Outputs: EcsInstanceId: Value: 'Fn::GetAtt': - EcsInstance - InstanceId Resources: EcsSecurityGroup: Type: 'ALIYUN::ECS::SecurityGroup' Properties: SecurityGroupIngress: - Priority: 1 PortRange: '-1/-1' NicType: intranet SourceCidrIp: 0.0.0.0/0 IpProtocol: all VpcId: Ref: EcsVpc SecurityGroupEgress: - Priority: 1 PortRange: '-1/-1' IpProtocol: all NicType: intranet DestCidrIp: 0.0.0.0/0 EcsVSwitch: Type: 'ALIYUN::ECS::VSwitch' Properties: VpcId: Ref: EcsVpc CidrBlock: 192.168.0.0/24 ZoneId: Ref: VSwitchZoneId EcsVpc: Type: 'ALIYUN::ECS::VPC' Properties: VpcName: 'Fn::Join': - '-' - - StackId - Ref: 'ALIYUN::StackId' CidrBlock: 192.168.0.0/16 EcsInstance: Type: 'ALIYUN::ECS::Instance' Properties: SystemDiskCategory: Ref: SystemDiskCategory VpcId: Ref: EcsVpc SecurityGroupId: Ref: EcsSecurityGroup SystemDiskSize: Ref: SystemDiskSize ImageId: Ref: InstanceImageId AllocatePublicIP: Ref: InstancePublicIP VSwitchId: Ref: EcsVSwitch IoOptimized: optimized Password: Ref: InstancePassword InstanceType: Ref: InstanceType PrivateIpAddress: 192.168.0.1 name: sample-stack-ecs-instance-with-vpc timeoutInMinutes: 3 parameters: InstancePassword: Sample_Password InstanceType: ecs.g5.large VSwitchZoneId: cn-hangzhou-gImportantAuthorization: In this ROS template, ECS and VPC resources are used. You must the grant the permissions on ROS, ECS, and VPC to the ACK cluster. Perform the following operations: Go to the Clusters page in the ACK console, find the desired cluster, and click the cluster ID. In the left-side navigation pane, click Cluster Information. Click the Cluster Resources tab and the value of the Worker RAM Role parameter. Then, click Grant Permission to grant the permissions.
The value of "name" in the metadata field and the value of "name" in the spec field must be the same.
In the spec field, you can use one of templateId, templateContent, and templateURL to specify the ROS template.
Apply the stack-sample.yml file.
Run the following code to create an Alibaba Cloud ROS stack by using the ACK cluster:
kubectl apply -f stack-sample.ymlAfter the stack is created, the cluster stores the stack information in a ConfigMap. The following table describes the fields contained in the ConfigMap.
Field
Value
Description
RegionId
cn-hangzhou
The region ID.
StackId
b53e1b25-72c8-4356-b0f4-81d04972****
The stack ID.
Status
CREATE_COMPLETE
The state of the stack.
StatusReason
Stack CREATE completed successfully
The reason why the stack is in its current state.
Outputs_EcsInstanceId
i-2ze6gw6z2dfma1v7****
The ID of the created ECS instance.
NoteThe field prefixed with Outputs is returned from the stack. Other fields are the attributes of the stack itself.
Before you use the Outputs-prefixed field, we recommend that you check whether the stack is in a desired state.
View a stack
Run the following command to view the stack details, such as the stack status and the resources associated with the stack:
kubectl describe rosstacks sample-stack-ecs-instance-with-vpcUpdate a stack
Update the stack-sample.yml file.
Run the following command to edit the stack-sample.yml file. Then, update the ROS template in the stack-sample.yml file.
vim stack-sample.ymlApply the stack-sample.yml file.
Run the following command to trigger the update process. After the Alibaba Cloud resources are updated, data in the ConfigMap is also updated.
kubectl apply -f stack-sample.yml
Delete a stack
Run the following command to delete the stack that you no longer require. If you run the command, the Alibaba Cloud resources and the ConfigMap are also deleted.
kubectl delete rosstack sample-stack-ecs-instance-with-vpc