OOS簡介
Operation Orchestration Service,簡稱OOS,是全面、免費的雲上自動化運維平台,提供運維任務的管理和執行。典型使用場景包括:事件驅動運維,批量操作運維,定時運維任務,跨地域運維等,OOS為重要運維場景提供審批,通知等功能。OOS幫您實作标準化運維任務,進而實踐運維即代碼(Operations as Code)的先進理念。關于OOS更詳細的介紹請參見
什麼是運維編排服務。
場景介紹
基于OOS實作自動删除建立于7天前的鏡像。
操作步驟
1.登陸
OOS控制台 ,找到我的模闆,點選建立模闆。
FormatVersion: OOS-2019-06-01
Description: ''
Parameters:
regionId:
Type: String
Description:
en: The id of region.
zh-cn: 地域ID。
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
force:
Description:
en: Specifies whether to forcibly delete the image.
zh-cn: 是否強制删除鏡像。
Type: Boolean
Default: false
expiredDays:
Description:
en: The expired days of image.
zh-cn: 鏡像過期天數。
Type: Number
Default: 7
rateControl:
Description:
en: Concurrency ratio of task execution.
zh-cn: 任務執行的并發比率。
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 100%
Concurrency: 10
Tasks:
- Name: describeImages
Action: 'ACS::ExecuteAPI'
Description: ''
Properties:
Service: ECS
API: DescribeImages
Parameters:
RegionId: '{{ regionId }}'
ImageOwnerAlias: self
Filter:
- Key: CreationEndTime
Value:
'Fn::FormatUTCTime':
- 'Fn::AddHour':
- '{{ ACS::CurrentUTCTime }}'
- "Fn::Eval":
- '-{{ expiredDays }}*24'
- '%Y-%m-%dT00:00Z'
Outputs:
imageIds:
Type: List
ValueSelector: '.Images.Image[].ImageId'
- Name: deleteImages
Action: 'ACS::ExecuteAPI'
Description:
en: Delete the expired images.
zh-cn: 删除過期鏡像。
Properties:
Service: ECS
API: DeleteImage
Parameters:
RegionId: '{{ regionId }}'
ImageId: '{{ ACS::TaskLoopItem }}'
Force: '{{ force }}'
Loop:
Items: '{{ describeImages.imageIds }}'
RateControl: '{{ rateControl }}'
Outputs:
deletedImageIds:
Type: List
Value: '{{ describeImages.imageIds }}'
定時執行模版
1.找到定時運維,點選建立,選擇周期性重複執行,設定定時執行的規則。
截圖所示規則:截止規則結束時間,每天0點0分定時執行制指定模闆
2.模闆選擇,選擇上文建立的模闆。參數設定,選擇目标地域,點選确認風險并執行。
3.在執行詳情頁中可以檢視定時執行清單和所操作的資源。