Azure-sdk-for-python AKS-如何在 AKS 上获取 Kubernetes 的可用最新版本
Azure-sdk-for-python AKS- How to get available latest version for Kubernetes on AKS
我正在尝试通过 python.sdk 在 AKS 上获取可用的 Kubernetes 版本,然后用最新版本升级 AKS。
考虑到此文档,这是我尝试过的方法 https://docs.microsoft.com/en-us/rest/api/aks/managed-clusters/get-upgrade-profile
for resource in list(resource_list):
if resource.type== "Microsoft.ContainerService/managedClusters":
print("ResourceName:", resource.name, "ResourceType:", resource.type)
containerservice_client = ContainerServiceClient(credential, sub.subscription_id)
get_aks = containerservice_client.managed_clusters.get(group.name, resource.name)
aks_get_upgrade = containerservice_client.managed_clusters.get_upgrade_profile(group.name, resource.name)
print("AKSGetUpdate", aks_get_upgrade)
然而 return kubernetesVersion.
如果有人可以提供帮助,我将不胜感激。
您可以尝试使用我在我的环境中测试过的以下代码:
from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.containerservice import ContainerServiceClient
from azure.mgmt.containerservice.models import ManagedClusterPoolUpgradeProfileUpgradesItem
credential = AzureCliCredential()
subscription_id = "SUBID"
resource_group= 'RG'
resouce_client=ResourceManagementClient(credential,subscription_id)
container_client=ContainerServiceClient(credential,subscription_id)
resouce_list=resouce_client.resources.list_by_resource_group(resource_group)
for resource in list (resouce_list) :
if resource.type == 'Microsoft.ContainerService/managedClusters':
print("ResourceName:", resource.name, "ResourceType:", resource.type)
get_aks = container_client.managed_clusters.get(resource_group, resource.name)
aks_get_details = container_client.managed_clusters.get_upgrade_profile(resource_group, resource.name)
aks_get_upgrade = aks_get_details.control_plane_profile
upgrades = aks_get_upgrade.upgrades
print("AKS_current_controlPlane", aks_get_upgrade.kubernetes_version)
for i in upgrades:
print("AKSGetUpdate_upgrade_controlPlane", i.kubernetes_version,i.is_preview)
输出:
我正在尝试通过 python.sdk 在 AKS 上获取可用的 Kubernetes 版本,然后用最新版本升级 AKS。
考虑到此文档,这是我尝试过的方法 https://docs.microsoft.com/en-us/rest/api/aks/managed-clusters/get-upgrade-profile
for resource in list(resource_list):
if resource.type== "Microsoft.ContainerService/managedClusters":
print("ResourceName:", resource.name, "ResourceType:", resource.type)
containerservice_client = ContainerServiceClient(credential, sub.subscription_id)
get_aks = containerservice_client.managed_clusters.get(group.name, resource.name)
aks_get_upgrade = containerservice_client.managed_clusters.get_upgrade_profile(group.name, resource.name)
print("AKSGetUpdate", aks_get_upgrade)
然而 return kubernetesVersion.
如果有人可以提供帮助,我将不胜感激。
您可以尝试使用我在我的环境中测试过的以下代码:
from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.containerservice import ContainerServiceClient
from azure.mgmt.containerservice.models import ManagedClusterPoolUpgradeProfileUpgradesItem
credential = AzureCliCredential()
subscription_id = "SUBID"
resource_group= 'RG'
resouce_client=ResourceManagementClient(credential,subscription_id)
container_client=ContainerServiceClient(credential,subscription_id)
resouce_list=resouce_client.resources.list_by_resource_group(resource_group)
for resource in list (resouce_list) :
if resource.type == 'Microsoft.ContainerService/managedClusters':
print("ResourceName:", resource.name, "ResourceType:", resource.type)
get_aks = container_client.managed_clusters.get(resource_group, resource.name)
aks_get_details = container_client.managed_clusters.get_upgrade_profile(resource_group, resource.name)
aks_get_upgrade = aks_get_details.control_plane_profile
upgrades = aks_get_upgrade.upgrades
print("AKS_current_controlPlane", aks_get_upgrade.kubernetes_version)
for i in upgrades:
print("AKSGetUpdate_upgrade_controlPlane", i.kubernetes_version,i.is_preview)
输出: