|
10 | 10 | import tempfile |
11 | 11 | import time |
12 | 12 |
|
13 | | -from azext_aks_preview._consts import CONST_CUSTOM_CA_TEST_CERT |
| 13 | +from azext_aks_preview._consts import CONST_CUSTOM_CA_TEST_CERT, CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION, CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION |
14 | 14 | from azext_aks_preview._format import aks_machine_list_table_format |
15 | 15 | from azext_aks_preview.tests.latest.custom_preparers import ( |
16 | 16 | AKSCustomResourceGroupPreparer, |
@@ -3062,6 +3062,209 @@ def test_aks_nodepool_add_with_ossku_windows2025( |
3062 | 3062 | checks=[self.is_empty()], |
3063 | 3063 | ) |
3064 | 3064 |
|
| 3065 | + @AllowLargeResponse() |
| 3066 | + @AKSCustomResourceGroupPreparer( |
| 3067 | + random_name_length=17, name_prefix="clitest", location="westus2" |
| 3068 | + ) |
| 3069 | + def test_aks_cluster_kata( |
| 3070 | + self, resource_group, resource_group_location |
| 3071 | + ): |
| 3072 | + # reset the count so in replay mode the random names will start with 0 |
| 3073 | + self.test_resources_count = 0 |
| 3074 | + # kwargs for string formatting |
| 3075 | + aks_name = self.create_random_name("cliakstest", 16) |
| 3076 | + self.kwargs.update( |
| 3077 | + { |
| 3078 | + "resource_group": resource_group, |
| 3079 | + "name": aks_name, |
| 3080 | + "dns_name_prefix": self.create_random_name("cliaksdns", 16), |
| 3081 | + "location": resource_group_location, |
| 3082 | + "resource_type": "Microsoft.ContainerService/ManagedClusters", |
| 3083 | + "workload_runtime": CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION, |
| 3084 | + "ssh_key_value": self.generate_ssh_keys(), |
| 3085 | + } |
| 3086 | + ) |
| 3087 | + |
| 3088 | + # create |
| 3089 | + create_cmd = ( |
| 3090 | + "aks create --resource-group={resource_group} --name={name} --location={location} " |
| 3091 | + "--os-sku AzureLinux --workload-runtime {workload_runtime} --node-count 1 " |
| 3092 | + "--ssh-key-value={ssh_key_value} --node-vm-size Standard_D4s_v3" |
| 3093 | + ) |
| 3094 | + self.cmd( |
| 3095 | + create_cmd, |
| 3096 | + checks=[ |
| 3097 | + self.exists("fqdn"), |
| 3098 | + self.exists("nodeResourceGroup"), |
| 3099 | + self.check("provisioningState", "Succeeded"), |
| 3100 | + self.check("agentPoolProfiles[0].workloadRuntime", CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION), |
| 3101 | + ], |
| 3102 | + ) |
| 3103 | + |
| 3104 | + # delete |
| 3105 | + self.cmd( |
| 3106 | + "aks delete -g {resource_group} -n {name} --yes --no-wait", |
| 3107 | + checks=[self.is_empty()], |
| 3108 | + ) |
| 3109 | + |
| 3110 | + @AllowLargeResponse() |
| 3111 | + @AKSCustomResourceGroupPreparer( |
| 3112 | + random_name_length=17, name_prefix="clitest", location="westus2" |
| 3113 | + ) |
| 3114 | + def test_aks_nodepool_add_with_kata( |
| 3115 | + self, resource_group, resource_group_location |
| 3116 | + ): |
| 3117 | + # reset the count so in replay mode the random names will start with 0 |
| 3118 | + self.test_resources_count = 0 |
| 3119 | + # kwargs for string formatting |
| 3120 | + aks_name = self.create_random_name("cliakstest", 16) |
| 3121 | + node_pool_name = self.create_random_name('c', 6) |
| 3122 | + node_pool_name_second = self.create_random_name('c', 6) |
| 3123 | + self.kwargs.update( |
| 3124 | + { |
| 3125 | + "resource_group": resource_group, |
| 3126 | + "name": aks_name, |
| 3127 | + "node_pool_name": node_pool_name, |
| 3128 | + "node_pool_name_second": node_pool_name_second, |
| 3129 | + "location": resource_group_location, |
| 3130 | + "resource_type": "Microsoft.ContainerService/ManagedClusters", |
| 3131 | + "workload_runtime": CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION, |
| 3132 | + "ssh_key_value": self.generate_ssh_keys(), |
| 3133 | + } |
| 3134 | + ) |
| 3135 | + |
| 3136 | + # create |
| 3137 | + create_cmd = ( |
| 3138 | + "aks create --resource-group={resource_group} --name={name} " |
| 3139 | + "--nodepool-name {node_pool_name} -c 1 --ssh-key-value={ssh_key_value}" |
| 3140 | + ) |
| 3141 | + self.cmd(create_cmd, checks=[ |
| 3142 | + self.check('provisioningState', 'Succeeded'), |
| 3143 | + ]) |
| 3144 | + |
| 3145 | + # nodepool update with kata |
| 3146 | + update_cmd = ( |
| 3147 | + "aks nodepool add --cluster-name={name} --resource-group={resource_group} " |
| 3148 | + "--name={node_pool_name_second} --os-sku AzureLinux " |
| 3149 | + "--workload-runtime KataVmIsolation --node-vm-size Standard_D4s_v3" |
| 3150 | + ) |
| 3151 | + |
| 3152 | + self.cmd( |
| 3153 | + update_cmd, |
| 3154 | + checks=[ |
| 3155 | + self.check("provisioningState", "Succeeded"), |
| 3156 | + self.check("workloadRuntime", CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION), |
| 3157 | + ], |
| 3158 | + ) |
| 3159 | + |
| 3160 | + # delete |
| 3161 | + self.cmd( |
| 3162 | + "aks delete -g {resource_group} -n {name} --yes --no-wait", |
| 3163 | + checks=[self.is_empty()], |
| 3164 | + ) |
| 3165 | + |
| 3166 | + @AllowLargeResponse() |
| 3167 | + @AKSCustomResourceGroupPreparer( |
| 3168 | + random_name_length=17, name_prefix="clitest", location="westus2" |
| 3169 | + ) |
| 3170 | + def test_aks_cluster_kata_mshv_vm_isolation( |
| 3171 | + self, resource_group, resource_group_location |
| 3172 | + ): |
| 3173 | + # Testing the old kata name that is still in use in aks-preview |
| 3174 | + # reset the count so in replay mode the random names will start with 0 |
| 3175 | + self.test_resources_count = 0 |
| 3176 | + # kwargs for string formatting |
| 3177 | + aks_name = self.create_random_name("cliakstest", 16) |
| 3178 | + self.kwargs.update( |
| 3179 | + { |
| 3180 | + "resource_group": resource_group, |
| 3181 | + "name": aks_name, |
| 3182 | + "dns_name_prefix": self.create_random_name("cliaksdns", 16), |
| 3183 | + "location": resource_group_location, |
| 3184 | + "resource_type": "Microsoft.ContainerService/ManagedClusters", |
| 3185 | + "workload_runtime": CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION, |
| 3186 | + "ssh_key_value": self.generate_ssh_keys(), |
| 3187 | + } |
| 3188 | + ) |
| 3189 | + |
| 3190 | + # create |
| 3191 | + create_cmd = ( |
| 3192 | + "aks create --resource-group={resource_group} --name={name} --location={location} " |
| 3193 | + "--os-sku AzureLinux --workload-runtime {workload_runtime} --node-count 1 " |
| 3194 | + "--ssh-key-value={ssh_key_value} --node-vm-size Standard_D4s_v3" |
| 3195 | + ) |
| 3196 | + self.cmd( |
| 3197 | + create_cmd, |
| 3198 | + checks=[ |
| 3199 | + self.exists("fqdn"), |
| 3200 | + self.exists("nodeResourceGroup"), |
| 3201 | + self.check("provisioningState", "Succeeded"), |
| 3202 | + self.check("agentPoolProfiles[0].workloadRuntime", CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION), |
| 3203 | + ], |
| 3204 | + ) |
| 3205 | + |
| 3206 | + # delete |
| 3207 | + self.cmd( |
| 3208 | + "aks delete -g {resource_group} -n {name} --yes --no-wait", |
| 3209 | + checks=[self.is_empty()], |
| 3210 | + ) |
| 3211 | + |
| 3212 | + @AllowLargeResponse() |
| 3213 | + @AKSCustomResourceGroupPreparer( |
| 3214 | + random_name_length=17, name_prefix="clitest", location="westus2" |
| 3215 | + ) |
| 3216 | + def test_aks_nodepool_add_with_kata_mshv_vm_isolation( |
| 3217 | + self, resource_group, resource_group_location |
| 3218 | + ): |
| 3219 | + # reset the count so in replay mode the random names will start with 0 |
| 3220 | + self.test_resources_count = 0 |
| 3221 | + # kwargs for string formatting |
| 3222 | + aks_name = self.create_random_name("cliakstest", 16) |
| 3223 | + node_pool_name = self.create_random_name('c', 6) |
| 3224 | + node_pool_name_second = self.create_random_name('c', 6) |
| 3225 | + self.kwargs.update( |
| 3226 | + { |
| 3227 | + "resource_group": resource_group, |
| 3228 | + "name": aks_name, |
| 3229 | + "node_pool_name": node_pool_name, |
| 3230 | + "node_pool_name_second": node_pool_name_second, |
| 3231 | + "location": resource_group_location, |
| 3232 | + "resource_type": "Microsoft.ContainerService/ManagedClusters", |
| 3233 | + "workload_runtime": CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION, |
| 3234 | + "ssh_key_value": self.generate_ssh_keys(), |
| 3235 | + } |
| 3236 | + ) |
| 3237 | + |
| 3238 | + # create |
| 3239 | + create_cmd = ( |
| 3240 | + "aks create --resource-group={resource_group} --name={name} " |
| 3241 | + "--nodepool-name {node_pool_name} -c 1 --ssh-key-value={ssh_key_value}" |
| 3242 | + ) |
| 3243 | + self.cmd(create_cmd, checks=[ |
| 3244 | + self.check('provisioningState', 'Succeeded'), |
| 3245 | + ]) |
| 3246 | + |
| 3247 | + # nodepool update with kata |
| 3248 | + update_cmd = ( |
| 3249 | + "aks nodepool add --cluster-name={name} --resource-group={resource_group} " |
| 3250 | + "--name={node_pool_name_second} --os-sku AzureLinux " |
| 3251 | + "--workload-runtime {workload_runtime} --node-vm-size Standard_D4s_v3" |
| 3252 | + ) |
| 3253 | + |
| 3254 | + self.cmd( |
| 3255 | + update_cmd, |
| 3256 | + checks=[ |
| 3257 | + self.check("provisioningState", "Succeeded"), |
| 3258 | + self.check("workloadRuntime", CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION), |
| 3259 | + ], |
| 3260 | + ) |
| 3261 | + |
| 3262 | + # delete |
| 3263 | + self.cmd( |
| 3264 | + "aks delete -g {resource_group} -n {name} --yes --no-wait", |
| 3265 | + checks=[self.is_empty()], |
| 3266 | + ) |
| 3267 | + |
3065 | 3268 | @AllowLargeResponse() |
3066 | 3269 | @AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus') |
3067 | 3270 | def test_aks_nodepool_add_with_ossku_ubuntu2204(self, resource_group, resource_group_location): |
|
0 commit comments