cb-spider
cb-spider copied to clipboard
[Azure] PMKS Server-Driver Integration Test
@inno-cloudbarista
[활용 자원]
[활용 API]
curl -sX POST http://localhost:1024/spider/cluster -H 'Content-Type: application/json' -d '{
"ConnectionName": "azure-eastus-config",
"ReqInfo": {
"Name": "myk8scluser-01",
"Version": "1.22.11",
"VPCName": "vpc-01",
"SubnetNames": ["subnet-01"],
"SecurityGroupNames": ["sg-01"],
"NodeGroupList": [
{
"Name": "nodegroup0",
"VMSpecName": "Standard_B2s",
"RootDiskSize": "60",
"KeyPairName": "keypair-01",
"OnAutoScaling": "true",
"DesiredNodeSize": "1",
"MinNodeSize": "1",
"MaxNodeSize": "3"
}
]
}
}
}' |json_pp
- 위를 실행하면, 다음과 같은 오류가 발생합니다.
{ "message" : "Failed to Create Cluster. err = failed get Cluster BaseSecurityGroup err = The maximum number of verification requests has been exceeded while waiting for the creation of that resource" }
- 다음처럼, 240초를 기다려도 동일 오류가 발생하고 있습니다.
1701 func waitingClusterBaseSecurityGroup(createdClusterIID irs.IID, managedClustersClient *containerservice.ManagedClustersClient, securityGroupsClient *network.Sec urityGroupsClient, ctx context.Context, credentialInfo idrv.CredentialInfo, regionInfo idrv.RegionInfo) (network.SecurityGroup, error) {
1702 // exist Cluster
1703 apiCallCount := 0
1704 //maxAPICallCount := 60
1705 maxAPICallCount := 240
- 찍어보니 1733에서
len(securityGroupList.Values())
값이 계속 0 입니다. - 제가 사용한 자원 값 설정 등 확인 부탁드립니다.
1731 for { 1732 securityGroupList, err := securityGroupsClient.List(ctx, clusterManagedResourceGroup) 1733 if err == nil && len(securityGroupList.Values()) > 0 {
-혹시,
- Server에서 Azure Driver로 NetworkInfo의 SecurityGroupIID 정보를 내려 보낼때,
- IID의 NameId와 SytemId 설정 값이 잘못되어 그럴수도 있겠습니다. (추정)
- 그러면, 사용자가 추가한 SG를 못찾을 것이고,
- 자동 생성된 Resource Group 내부의 SecurityGroup 설정 시에 오류가 발생되어 혹시, 지우는 것은 아닌지...
- 일단, Server단에서 Driver로 내려 보낼때 SG IID 값이 기존과 동일한 형태인지 확인해보도록 하겠습니다.
위 이슈에 대해서 내용 공유 드립니다.
1732 securityGroupList, err := securityGroupsClient.List(ctx, clusterManagedResourceGroup)
clusterManagedResourceGroup는 클러스터의 의해 만들어진 리소스그룹입니다.
위 부분에서 찾는 securityGroup은 클러스터 생성으로 만들어지는 리소스 그룹에서 새로 만들어지는 SecurityGroup을 찾는 과정입니다.(사용자가 입력한 SecurityGroup의 Rule이 덮어 씌워질 원본의 SecurityGroup)
위에서 문제가 발생했다면, 클러스터는 생성은 성공하였으나, 클러스터에 의해 만들어지는 기본적인 SecurityGroup이 만들어지지 않았음을 의미합니다.(사용자가 입력한 SecurityGroup과는 아직 무관한 부분이라 판단됩니다.)
해당부분의 확인을 위해, 위에 주신 curl을 기반으로 실제로 들어오는 값을 확인하여 테스트해보겟습니다.
추가적으로 테스트 도중, 발생한 이슈에 관해 공유드립니다.
nodegroup의 NameID가 nodegroup0로 입력될 경우, 실제 드라이버로 들어오는 값은 nodegroup0-xxxxxxxxxxx 값으로 들어오게 됩니다. 그런데, nodegroup의 이름은 -와 같은 특수 문자는 불가합니다.
여기서 Cluster가 생성 실패가 되어야하는데 다음 단계로 넘어가는게 의문입니다.......(저의 경우 API테스트로는 실패하여, Vpc와 SecurityGroup,KeyPair는 웹으로 생성 후 코드내에서 아래와 같은 값을 입력하여 다음 단계로 넘어갔습니다.)
createreq := irs.ClusterInfo{
IId: irs.IID{
NameId: "test-cluster-2",
},
Network: irs.NetworkInfo{
VpcIID: irs.IID{NameId: "cluster-1108-cdkq7jfofm7b2k36eej0"},
SubnetIIDs: []irs.IID{{NameId: "subnet-01-cdkq7jfofm7b2k36eejg"}},
SecurityGroupIIDs: []irs.IID{{NameId: "cluster-1108-sgcdkq7pvofm7b2k36eek0"}},
},
Version: "1.22.11",
// ImageIID
NodeGroupList: []irs.NodeGroupInfo{
{
IId: irs.IID{NameId: "nodegroup-cdkqaufofm74obkloccg"},
VMSpecName: "Standard_B2s",
RootDiskSize: "default",
KeyPairIID: irs.IID{NameId: "keypair-01-cdkq847ofm7b2k36eekg"},
DesiredNodeSize: 1,
MaxNodeSize: 2,
MinNodeSize: 1,
OnAutoScaling: true,
},
},
}
혹시, 위 과정사이에서 콘솔 상의 Cluster는 생성이 되는지 알수 있을까요?
현재 드라이버 내에서 위와 같은 현상이 재현되지 않지만, 여러 방법으로 테스트 중에 있습니다. 추가적인 내용 있으면 바로 공유드리겠습니다.
@inno-cloudbarista
[NodeGroup Name 관련]
- 다음 사항 확인하였습니다.
# NodeGroup Name 규칙(12자 이하, '-' 사용 불가) : 일단 SPXID를 입력 값으로 설정
The name for this node pool. Node pool must contain only lowercase letters and numbers. For Linux node pools the name cannot be longer than 12 characters, and for Windows node pools the name cannot be longer than 6 characters.
-
관련하여,
-
현재 서버 개발시 임시 코드로 추가된 내용이 다음과 같습니다.
- 아래 코드는 임시 코드이니 변경될 수 있습니다.
-
일단, 시험시 아래 코드만 추가하시면 해당 부분 통과 가능합니다.
-
vi cloud-control-manager/iid-manager/IIDManager.go
360 if cccInfo.ProviderName == "AZURE" && rsType == "nodegroup" { 361 return uid, nil 362 }
@inno-cloudbarista
[Credential Role 및 scope 지정 시험 결과]
-
credential: Owner role 발급하여 시험 => 결과 동일
$ az ad sp create-for-rbac --sdk-auth -n "api://spider" --role="Owner"
-
credential: Contributor role 및 명시적으로 Subscriptions scope 지정 발급하여 시험 (사실 default 설정임) => 결과 동일
$ az ad sp create-for-rbac --sdk-auth -n "api://spider-subscriptions-scope" --role="Contributor" --scopes="/subscriptions/a20fed83-96bd-4480-92a9-140b8e3b7c3a"
-
참고: 추가한 credential을 콘솔로 본 정보
[cli 시험 결과]
-
자동 생성된 RG 설정으로 nsg 목록 요청
$ az network nsg list -g cb_cb-group-wip_myk8scluser-01-cdl4q4ncl16eiaobggd0_eastus
=> API에서와 마찬가지로 출력 되지 않음 -
RG 설정 없이 nsg 목록 요청
$ az network nsg list |grep aks-agentpool-28772489-nsg
"id": "/subscriptions/xxxx-xxxx-xxxx/resourceGroups/cb_cb-group-wip_myk8scluser-01-cdl4q4ncl16eiaobggd0_eastus/providers/Microsoft.Network/networkSecurityGroups/aks-agentpool-28772489-nsg/defaultSecurityRules/AllowVnetInBound", ... 중략
[API 시험 결과]
-
관련 API
-
ListAll(ctx) 단순 교체 적용 후 성공(활용하시려면 별도 검증 필요합니다.)
-
위 상태에서 List/Get/Delete Cluster는 성공(출력 정보 검증은 미확인)
-
AddNodeGroup()은 유사 오류 발생
{
"message" : "Failed to Add NodeGroup. err = failed add agentPool err = failed get Cluster VirtualMachineScaleSet err = The maximum number of verification requests has been exceeded while waiting for the creation of that resource"
}
- 여전히 이상한 점은 이노그리드 계정은 기존 코드 성공한다는 점
- 다른 권한이나 설정 방법이 있을 수도 있겠습니다.
[계획(안)]
- 일단, Azure NodeGroup Name 제약을 위한 임시 코드를 반영 해두었습니다.
- 추후 좀더 통합 시험 시에 정식 코드로 교체
- createCluster() Async 호출 및 ListAll을 nsg, VMScaleset 등 반영 후
- 전체(CRUD/ADD) 재시험 부탁드립니다.
- 시험은 아래 REST API 활용한 시험 부탁 드리겠습니다.
- 위 5번 항목에 대해서는 시간을 가지고 확인 부탁 드립니다.
[REST API Test Scripts 참고]
[Create] # NodeGroup Name 규칙: 소문자, 12자 이하, '-' 사용 불가
curl -sX POST http://localhost:1024/spider/cluster -H 'Content-Type: application/json' -d \
'{
"ConnectionName": "azure-eastus-config",
"ReqInfo": {
"Name": "myk8scluser-01",
"Version": "1.22.11",
"VPCName": "vpc-01",
"SubnetNames": ["subnet-01"],
"SecurityGroupNames": ["sg-01"],
"NodeGroupList": [
{
"Name": "nodegroup0",
"VMSpecName": "Standard_B2s",
"RootDiskSize": "60",
"KeyPairName": "keypair-01",
"OnAutoScaling": "true",
"DesiredNodeSize": "1",
"MinNodeSize": "1",
"MaxNodeSize": "3"
}
]
}
}
}' |json_pp
[List]
curl -sX GET http://localhost:1024/spider/cluster -H 'Content-Type: application/json' -d \
'{
"ConnectionName": "azure-eastus-config"
}' |json_pp
[Get]
curl -sX GET http://localhost:1024/spider/cluster/myk8scluser-01 -H 'Content-Type: application/json' -d \
'{
"ConnectionName": "azure-eastus-config"
}' |json_pp
[AddNodeGroup] # Image: Azure가 자동 지정, RootDisType: PremiumSSD 고정(가능 값: "", "default", "PremiumSSD")
curl -sX POST http://localhost:1024/spider/cluster/myk8scluser-01/nodegroup -H 'Content-Type: application/json' -d \
'{
"ConnectionName": "azure-eastus-config",
"ReqInfo": {
"Name": "economy",
"VMSpecName": "Standard_B2s",
"RootDiskSize": "60",
"KeyPairName": "keypair-01",
"OnAutoScaling": "true",
"DesiredNodeSize": "2",
"MinNodeSize": "2",
"MaxNodeSize": "5"
}
}' |json_pp
[Remove NodeGroup]
curl -sX DELETE http://localhost:1024/spider/cluster/myk8scluser-01/nodegroup/economy -H 'Content-Type: application/json' -d \
'{
"ConnectionName": "azure-eastus-config"
}' |json_pp
[Delete]
curl -sX DELETE http://localhost:1024/spider/cluster/myk8scluser-01 -H 'Content-Type: application/json' -d \
'{
"ConnectionName": "azure-eastus-config"
}' |json_pp
[Azure]
- @todo
- USER SecurityGroup => NodeGroup SecurityGroup 반영 방법 점검 필요
- Injection vs Subnet link 등
@powerkimhub GetCluster, ListCluster시에 NodeGroupList정보가 비어서 넘어옵니다. 반면 curl로 조회하는 클러스터를 Handler 코드상에서 조회할 경우에는 값이 담겨서 리턴합니다.
혹시 중간에 필터되는 것이 아닐까합니다.
@inno-cloudbarista
- 현황 공유 감사드립니다.
- 서버파트에서 확인하면 해결 될 것 같습니다.
@powerkimhub GetCluster, ListCluster시에 NodeGroupList정보가 비어서 넘어오는 사항은 권한에 대한 가이드 문서 작성하면서, 권한을 누락시켜서 발생하는 문제인거 같습니다.
권한 설정후엔 문제없이 잘 됩니다.
@inno-cloudbarista
- 통합 시험시 확인해보겠습니다.
- 캄사합니다.