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

管理 NFO 扩展

本文指导用户如何管理 Azure 操作服务管理器的网络功能运营商 (NFO) 扩展。 使用此 Kubernetes 群集扩展来管理 Azure 操作员 Nexus 平台托管的基于容器的工作负荷。

在使 Nexus Azure Kubernetes 服务 (NAKS) 群集准备好用于加载项扩展后,请运行本文中的命令。 这些命令假定已安装 Azure CLI,并已在目标订阅中进行身份验证。

创建 NFO 扩展

若要创建 NFO 扩展,请运行 Azure CLI 命令 az k8s-extension create

命令

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=]
                        [--config global.networkfunctionextension.clusterRegistry.registryService.scale={"small", "medium", "large"}]
                        [--version]

必需的参数

--cluster-name -c

  • Kubernetes 群集的名称。

--cluster-type -t

  • 指定 Azure Arc 群集、Azure Kubernetes 服务(AKS)托管群集、Azure 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

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

--release-train

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

--version

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

可选特定功能的配置

侧载

--config global.networkfunctionextension.enableLocalRegistry=

  • 此配置允许通过硬件驱动器将项目传送到边缘。
  • 接受的值:falsetrue
  • 默认值:false

Pod 可变 Webhook

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

  • 此配置是一个可选参数。 仅当容器网络功能 (CNF) 安装在相应的版本命名空间中时,它才会发挥作用。

  • 此配置在规则和 namespaceSelectors 之上设置了更精细的控制。

  • 默认值:

    "((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\"))))"
    

    引用的匹配条件意味着,kube-system 命名空间中接受的 Pod 只有在具有至少一个以下标签时,才会发生变异:app == "commissioning"app == "descheduler"name == "cert-exporter"。 否则,它们不会发生变异,并会根据 CNF、组件或应用程序的 Helm 图表继续从原始源拉取。

  • 接受的值:任何有效的公共表达式语言(CEL)表达式。

  • 可以在安装或更新 NFO 扩展期间设置或更新此参数。

  • 仅当按照规则 namespaceSelectors将 CNF、组件或应用程序安装到命名空间时,才会生效此条件。 如果在该命名空间中创建更多 Pod,则会应用此条件。

群集注册表

--config global.networkfunctionextension.enableClusterRegistry=

  • 此配置在群集中配置注册表以本地缓存制品。
  • 默认值启用延迟加载模式,除非 global.networkfunctionextension.enableEarlyLoading=true
  • 接受的值:falsetrue
  • 默认值:false

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

  • 如果启用了群集注册表,则此配置在高可用性(HA)模式下预配群集注册表。
  • 如果该值设置为 false,则此配置将根据 AKS 建议使用 NAKS nexus-shared 卷。
  • 注册表 pod 的副本计数范围是从最小值 3 到最大值 5
  • 接受的值:truefalse
  • 默认值:true

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

  • 此配置将群集注册表 Pod 设置为支持水平自动伸缩。
  • 接受的值:truefalse
  • 默认值:true

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

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

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

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

--config global.networkfunctionextension.enableEarlyLoading=

  • 此配置允许在 Helm 安装或升级之前将项目提前加载到群集注册表中。
  • 仅当global.networkfunctionextension.enableClusterRegistry=true时,才能启用此配置。
  • 接受的值:falsetrue
  • 默认值: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:managed-premium
  • 默认值:nexus-shared

注意

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

--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

--config global.networkfunctionextension.clusterRegistry.registryService.scale=

  • 此配置将群集注册表的 CPU 和内存资源设置为预定义的缩放选项。

  • 接受的值:smallmediumlarge

  • 默认值:medium

  • 以下是所有三种规模的注册表资源规范:

        - requests:
          - small: cpu: 100m, memory: 250Mi
          - medium: cpu: 250m, memory: 500Mi
          - large: cpu: 500m, memory: 1Gi
        - limits:
          - small: cpu: 100m, memory: 2Gi
          - medium: cpu: 500m, memory: 2Gi
          - large: cpu: 1, memory: 4Gi
    

更新 NFO 扩展

若要更新 NFO 扩展,请运行 Azure CLI 命令 az k8s-extension update

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=]

删除 NFO 扩展名

若要删除 NFO 扩展,请运行 Azure CLI 命令 az k8s-extension delete

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

示例

创建具有自动升级的 NFO 扩展:

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

使用固定版本创建 NFO 扩展:

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 上启用的群集注册表(默认延迟加载模式)功能创建 NFO 扩展:

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 上启用的群集注册表(默认延迟加载模式)功能创建 NFO 扩展:

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

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

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

创建启用了旁加载功能的 NFO 扩展:

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

更新 NFO 扩展以启用群集注册表:

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

更新 NFO 扩展以达到新的目标版本:

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