你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

管理网络功能运营商扩展

本文将指导用户管理 Azure 运营商服务管理器 (AOSM) 网络功能运营商 (NFO) 扩展。 此 kubernetes 群集扩展是 AOSM 服务的一部分,用于管理由 Azure 运营商关系平台托管的基于容器的工作负载。

概述

这些命令将在 NAKS 群集准备好用于加载项扩展后执行,并且假定已安装 Azure CLI 并在目标订阅中进行了身份验证。

创建网络功能扩展

执行 Azure CLI 命令“az k8s-extension create”以安装 NFO 扩展。

命令

az k8s-extension create --cluster-name
                        --cluster-type {connectedClusters}
                        --extension-type {Microsoft.Azure.HybridNetwork}
                        --name
                        --resource-group
                        --scope {cluster}
                        --release-namespace {azurehybridnetwork}
                        --release-train {preview, stable}
                        --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator
                        [--auto-upgrade {false, true}]
                        [--config global.networkfunctionextension.enableClusterRegistry={false, true}]
                        [--config global.networkfunctionextension.enableLocalRegistry={false, true}]
                        [--config global.networkfunctionextension.enableEarlyLoading={false,true}]
                        [--config global.networkfunctionextension.clusterRegistry.highAvailability.enabled={true, false}]
                        [--config global.networkfunctionextension.clusterRegistry.autoScaling.enabled={true, false}]
                        [--config global.networkfunctionextension.webhook.highAvailability.enabled={true, false}]
                        [--config global.networkfunctionextension.webhook.autoScaling.enabled={true, false}]
                        [--config global.networkfunctionextension.clusterRegistry.storageClassName=]
                        [--config global.networkfunctionextension.clusterRegistry.storageSize=]
                        [--config global.networkfunctionextension.webhook.pod.mutation.matchConditionExpression=]
                        [--config global.networkfunctionextension.clusterRegistry.clusterRegistryGCCadence=]
                        [--config global.networkfunctionextension.clusterRegistry.clusterRegistryGCThreshold=]
                        [--version]

必需参数

--cluster-name -c

  • Kubernetes 群集的名称。

--cluster-type -t

  • 指定 Arc 群集或 Azure Kubernetes 服务 (AKS) 托管群集,或者 Arc 设备或 provisionedClusters。
  • 接受的值:connectedClusters。

--extension-type

  • 扩展类型的名称。
  • 接受的值:Microsoft.Azure.HybridNetwork。

--name -n

  • 扩展实例的名称。

--resource-group -g

  • 资源组的名称。 可以使用“az configure --defaults group=groupname”配置默认组。

--config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator

  • 必须提供此配置。

可选参数

--auto-upgrade

  • 自动升级扩展实例的次要版本。
  • 接受的值:false、true。
  • 默认值:true。

--release-train

  • 指定扩展类型的版本序列。
  • 接受的值:preview、stable。
  • 默认值:stable。

--version

  • 如果未启用“--auto-upgrade-minor-version”,请指定要为扩展实例安装的显式版本。

特定于可选功能的配置

旁加载

--config global.networkfunctionextension.enableLocalRegistry=

  • 此配置允许通过硬件驱动器将生成工件传送到边缘。
  • 接受的值:false、true。
  • 默认值:false。

Pod 变异 Webhook

--config global.networkfunctionextension.webhook.pod.mutation.matchConditionExpression=

  • 此配置是一个可选参数。 仅当容器网络功能 (CNF) 安装在相应的版本命名空间中时,它才会发挥作用。
  • 此配置基于规则和 namespaceSelectors 配置更精细的控制。
  • 默认值:30
    "((object.metadata.namespace != \"kube-system\") ||  (object.metadata.namespace == \"kube-system\" && has(object.metadata.labels) && (has(object.metadata.labels.app) && (object.metadata.labels.app == \"commissioning\") || (has(object.metadata.labels.name) && object.metadata.labels.name == \"cert-exporter\") || (has(object.metadata.labels.app) && object.metadata.labels.app == \"descheduler\"))))"
    

引用的 matchCondition 表示,只有当 kube-system 命名空间中接受的 Pod 至少具有以下标签之一时,它们才会发生变异:app ==“commissioning”,app ==“descheduler”,或 name ==“cert-exporter”。否则,它们不会发生变异,并会根据 CNF/Component/Application 的 Helm 图表继续从原始源拉取。

  • 接受的值:任何有效的 CEL 表达式。
  • 可以在网络功能 (NF) 扩展安装或更新期间设置或更新此参数。
  • 仅当 CNF/Component/Application 根据规则和 namespaceSelectors 安装到命名空间时,此条件才会发挥作用。 如果在该命名空间中启动更多 Pod,则会应用此条件。

群集注册表

--config global.networkfunctionextension.enableClusterRegistry=

  • 此配置将群集中的注册表预配到本地缓存的生成工件。
  • 默认值会启用延迟加载模式,除非 global.networkfunctionextension.enableEarlyLoading=true。
  • 接受的值:false、true。
  • 默认值:false。

--config global.networkfunctionextension.clusterRegistry.highAvailability.enabled=

  • 如果启用了群集注册表,则此配置会在高可用性模式下预配群集注册表。
  • 默认值为 true,依据 AKS 建议使用 Nexus Azure kubernetes 服务 (NAKS) nexus 共享卷设置为 false。
  • 接受的值:true、false。
  • 默认值:true。

--config global.networkfunctionextension.clusterRegistry.autoScaling.enabled=

  • 此配置使用水平自动缩放预配群集注册表 Pod。
  • 接受的值:true、false。
  • 默认值:true。

--config global.networkfunctionextension.webhook.highAvailability.enabled=

  • 此配置预配 Webhook 的多个副本以实现高可用性。
  • 接受的值:true、false。
  • 默认值:true。

--config global.networkfunctionextension.webhook.autoScaling.enabled=

  • 此配置使用水平自动缩放预配 Webhook Pod。
  • 接受的值:true、false。
  • 默认值:true。

--config global.networkfunctionextension.enableEarlyLoading=

  • 此配置可在 Helm 安装或升级之前将生成工件提前加载到群集注册表中。
  • 仅当 global.networkfunctionextension.enableClusterRegistry=true 时,才能启用此配置。
  • 接受的值:false、true。
  • 默认值:false。

--config global.networkfunctionextension.clusterRegistry.storageClassName=

  • 当 global.networkfunctionextension.enableClusterRegistry=true 时,必须提供此配置。
  • NetworkFunctionExtension 会将 PVC 预配到此存储类的本地缓存生成工件。
  • 特定于平台的值
    • AKS:managed-csi
    • NAKS(默认):nexus-shared
    • NAKS(非 HA):nexus-volume
    • Azure Stack Edge (ASE):managed-premium
  • 默认值:nexus-shared。

--config global.networkfunctionextension.clusterRegistry.storageSize=

  • 当 global.networkfunctionextension.enableClusterRegistry=true 时,必须提供此配置。
  • 此配置会配置我们为群集注册表保留的大小。
  • 此配置使用 Gi 和 Ti 作为调整大小的单位。
  • 默认值:100Gi

--config global.networkfunctionextension.clusterRegistry.clusterRegistryGCCadence=

  • 此配置必须以标准 Unix crontab 格式作为计划提供。
  • 此配置指定为一个空字符串,将禁用计划作业,允许客户选择不运行垃圾收集。
  • 默认值:"0 0 * * *" -- 每天运行一次作业。

--config global.networkfunctionextension.clusterRegistry.clusterRegistryGCThreshold=

  • 此配置指定触发群集注册表垃圾回收过程的百分比阈值。
  • 当群集注册表使用率超过此值时,此配置将触发垃圾回收过程。
  • 默认值:0。

注意

  • 使用 AOSM 管理 NAKS 群集时,默认参数值将启用 HA 作为建议的配置。
  • 使用 AOSM 管理 AKS 群集时,必须使用以下配置选项禁用 HA:
   --config global.networkfunctionextension.clusterRegistry.highAvailability.enabled=false
   --config global.networkfunctionextension.webhook.highAvailability.enabled=false
   --config global.networkfunctionextension.clusterRegistry.storageClassName=managed-csi

更新网络功能扩展

执行 Azure CLI 命令“az k8s-extension update”以更新 NFO 扩展。

az k8s-extension update --resource-group
                        --cluster-name
                        --cluster-type {connectedClusters}
                        --extension-type {Microsoft.Azure.HybridNetwork}
                        --name
                        --release-namespace {azurehybridnetwork}
                        --release-train {preview, stable}
                        --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator
                        [--version] {version-target}
                        [--config global.networkfunctionextension.enableClusterRegistry={false, true}]
                        [--config global.networkfunctionextension.enableLocalRegistry={false, true}]
                        [--config global.networkfunctionextension.enableEarlyLoading={false,true}]
                        [--config global.networkfunctionextension.clusterRegistry.highAvailability.enabled={true, false}]
                        [--config global.networkfunctionextension.clusterRegistry.autoScaling.enabled={true, false}]
                        [--config global.networkfunctionextension.webhook.highAvailability.enabled={true, false}]
                        [--config global.networkfunctionextension.webhook.autoScaling.enabled={true, false}]
                        [--config global.networkfunctionextension.clusterRegistry.storageClassName=]
                        [--config global.networkfunctionextension.clusterRegistry.storageSize=]
                        [--config global.networkfunctionextension.webhook.pod.mutation.matchConditionExpression=]
                        [--config global.networkfunctionextension.clusterRegistry.clusterRegistryGCCadence=]
                        [--config global.networkfunctionextension.clusterRegistry.clusterRegistryGCThreshold=]

删除网络功能扩展

执行 Azure CLI 命令“az k8s-extension delete”以删除 NFO 扩展。

az k8s-extension delete --resource-group
                        --cluster-name
                        --cluster-type {connectedClusters}
                        --extension-type {Microsoft.Azure.HybridNetwork}
                        --name
                        --release-namespace {azurehybridnetwork}
                        --release-train {preview, stable}
                        --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator

示例

使用自动升级创建网络功能扩展。

az k8s-extension create --resource-group myresourcegroup --cluster-name mycluster --name myextension --cluster-type connectedClusters --extension-type Microsoft.Azure.HybridNetwork --scope cluster --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator --release-namespace azurehybridnetwork

使用固定版本创建网络功能扩展。

az k8s-extension create --resource-group myresourcegroup --cluster-name mycluster --name myextension --cluster-type connectedClusters --extension-type Microsoft.Azure.HybridNetwork --auto-upgrade-minor-version false --scope cluster --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator --release-namespace azurehybridnetwork --version 1.0.2711-7

在 NAKS 上创建启用了群集注册表(默认延迟加载模式)功能的网络功能扩展。

az k8s-extension create --resource-group myresourcegroup --cluster-name mycluster --name myextension --cluster-type connectedClusters --extension-type Microsoft.Azure.HybridNetwork --scope cluster --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator --release-namespace azurehybridnetwork --config global.networkfunctionextension.enableClusterRegistry=true --config global.networkfunctionextension.clusterRegistry.storageSize=100Gi

在 AKS 上创建启用了群集注册表(默认延迟加载模式)功能的网络功能扩展。

az k8s-extension create --resource-group myresourcegroup --cluster-name mycluster --name myextension --cluster-type connectedClusters --extension-type Microsoft.Azure.HybridNetwork --scope cluster --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator --release-namespace azurehybridnetwork --config global.networkfunctionextension.enableClusterRegistry=true --config global.networkfunctionextension.clusterRegistry.highAvailability.enabled=false --config global.networkfunctionextension.clusterRegistry.storageClassName=managed-csi --config global.networkfunctionextension.clusterRegistry.storageSize=100Gi

创建启用了群集注册表(早期加载)功能的网络功能扩展。

az k8s-extension create --resource-group myresourcegroup --cluster-name mycluster --name myextension --cluster-type connectedClusters --extension-type Microsoft.Azure.HybridNetwork --scope cluster --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator --release-namespace azurehybridnetwork --config global.networkfunctionextension.enableClusterRegistry=true --config global.networkfunctionextension.enableEarlyLoading=true --config global.networkfunctionextension.clusterRegistry.storageClassName=managed-csi --config global.networkfunctionextension.clusterRegistry.storageSize=100Gi

创建启用了旁加载功能的网络功能扩展。

az k8s-extension create --resource-group myresourcegroup --cluster-name mycluster --name myextension --cluster-type connectedClusters --extension-type Microsoft.Azure.HybridNetwork --scope cluster --config Microsoft.CustomLocation.ServiceAccount=azurehybridnetwork-networkfunction-operator --release-namespace azurehybridnetwork --config global.networkfunctionextension.enableLocalRegistry=true

更新网络功能扩展以启用群集注册表。

az k8s-extension update --resource-group naks-1-rg --cluster-name naks-1  --cluster-type connectedClusters --name networkfunction-operator  --extension-type Microsoft.Azure.HybridNetwork --release-namespace azurehybridnetwork --config networkFunctionExtension.EnableManagedInClusterEdgeRegistry=true –-config networkFunctionExtension.EdgeRegistrySizeInGB=1024

更新网络功能扩展以达到新的目标版本。

az k8s-extension update --resource-group naks-1-rg --cluster-name naks-1  --cluster-type connectedClusters --name networkfunction-operator  --extension-type Microsoft.Azure.HybridNetwork --release-namespace azurehybridnetwork --version X.X.XXXX-YYY