compute-nest-best-practice/opensource/kubernetes/oos/GetClusterPrivateAddressCredential.yaml (67 lines of code) (raw):
FormatVersion: OOS-2019-06-01
Description: 获取集群私网凭证
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Description: ECS实例
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
RegionId: regionId
RamRole: ''
Tasks:
- Name: getTag
Description:
en: Views the ECS instance tag
zh-cn: 获取ECS实例标签
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
tagValue:
Type: String
ValueSelector: .Instances.Instance[].Tags.Tag[] | select( .TagKey == "acs:computenest:serviceInstanceId") | .TagValue
- Name: getInstance
Description: 获取ECS实例
Action: ACS::ExecuteApi
Properties:
Service: ECS
API: DescribeInstances
Parameters:
RegionId: '{{ regionId }}'
InstanceName: '{{ getTag.tagValue }}-master-001'
Outputs:
instanceId:
Type: String
ValueSelector: Instances.Instance[].InstanceId
- Name: runCommand
Action: ACS::ECS::RunCommand
Description: 执行云助手命令
Properties:
regionId: '{{ regionId }}'
commandContent: |-
#!/bin/bash
if [ -d ~/.kube ]; then
cat ~/.kube/internal_ip_config
else
echo "~/.kube directory not found"
fi
instanceId: '{{ getInstance.instanceId }}'
commandType: RunShellScript
Outputs:
invocationOutput:
Type: String
ValueSelector: invocationOutput
Outputs:
KubeConfig:
Type: String
Value: '{{ runCommand.invocationOutput }}'