Поделиться через


Helm requirements overview

Helm — это менеджер пакетов для Kubernetes, который помогает упростить управление жизненным циклом приложений. Пакеты Helm называются диаграммами и состоят из файлов конфигурации и шаблонов YAML. После выполнения операции Helm диаграммы отображаются в файлах манифеста Kubernetes, чтобы активировать соответствующие действия жизненного цикла приложения. Для наиболее эффективной интеграции с Azure Operator Service Manager (AOSM) издатель должен учитывать определенные рекомендации при разработке диаграмм Helm.

Рекомендации по registryPath и imagePullSecrets

Every Helm chart generally requires a registryPath and imagePullSecrets. Чаще всего издатель предоставляет эти параметры в файле values.yaml. At first, AOSM depended upon the publisher managing these values in a strict manner (legacy approach), to be substituted for the proper Azure values during deployment. Со временем было обнаружено, что не все издатели могут легко соответствовать строгому контролю этих параметров. Some charts hide registryPath and/or imagePullSecrets behind conditionals, or other values restrictions, which were not always met. Some charts don't declare registryPath and/or imagePullSecrets as the expected named string, instead as an array. Чтобы уменьшить строгие требования к соответствию для издателей, AOSM представил два улучшенных метода: injectArtifactStoreDetail и реестр кластеров. Эти новые методы не зависят от registryPath или imagePullSecrets, которые имеются в пакете Helm. Instead, these methods use a webhook to inject proper Azure values directly into pod operations.

Сводка по методам registryPath и imagePullSecrets

Все три метода в настоящее время поддерживаются, как описано в этой статье. Издатель должен выбрать оптимальный вариант для своей сетевой функции (NF) и варианта использования.

Наследие

  • Requires publisher to parameterize registryPath & imagePullSecrets in helm values and deployment templates for substitution.
  • Изображения размещаются в реестре контейнеров Azure (ACR) издателя.

InjectArtifactStoreDetail

  • Uses a webhook to inject registryPath & imagePullSecrets directly into pod operations, with minimal dependencies on helm.
  • Images are still hosted in the publisher ACR.

Реестр кластеров

  • Uses a webhook to inject registryPath & imagePullSecrets directly into pod operations, with no dependency on helm.
  • Images are hosted in the local network function operator (NFO) extension cluster registry.

Примечание.

Во всех трех случаях AOSM заменяет любые значения, предоставляемые издателем в шаблонах, на значения из Azure. The only difference is method of substitution.

Устаревшие требования для registryPath и imagePullSecrets

Диспетчер служб Оператора Azure (AOSM) использует службу диспетчера сетевых функций (NFM) для развертывания контейнерных сетевых функций (CNFs). With the legacy method, NFM substitutes the AOSM container registryPath and imagePullSecrets values into the helm operation during Network Function (NF) deployment.

Использование устаревшего метода

В следующем helm deployment шаблоне показан пример того, как паблишер должен предоставлять registryPath и imagePullSecrets.

apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: nginx-deployment 
  labels: 
    app: nginx 
spec: 
  replicas: 3 
  selector: 
    matchLabels: 
      app: nginx 
  template: 
    metadata: 
      labels: 
        app: nginx 
    spec: 
      {{- if .Values.global.imagePullSecrets }} 
      imagePullSecrets: {{ toYaml .Values.global.imagePullSecrets | nindent 8 }} 
      {{- end }} 
      containers: 
      - name: contosoapp 
        image:{{ .Values.global.registryPath }}/contosoapp:1.14.2 
        ports: 
        - containerPort: 80 

В следующем values.yaml шаблоне показан пример предоставления издателем значений registryPath и imagePullSecretsvalue.

global: 
   imagePullSecrets: [] 
   registryPath: “” 

В следующем values.schema.json файле показан пример того, как издатель может легко определить registryPath и imagePullSecretsvalue.

{ 
  "$schema": "http://json-schema.org/draft-07/schema#", 
  "title": "StarterSchema", 
  "type": "object", 
  "required": ["global"], 
  "properties": { 
      "global" : {
          "type": "object",
          "properties": {
              “registryPath”: {“type”: “string”}, 
              “imagePullSecrets”: {“type”: “string”}, 
          }
          "required": [ "registryPath", "imagePullSecrets" ], 
      } 
   } 
} 

В следующем NFDV request payload примере показано, как издатель может предоставлять значения registryPath и imagePullSecretsvalue во время развертывания.

"registryValuesPaths": [ "global.registryPath" ], 
"imagePullSecretsValuesPaths": [ "global.imagePullSecrets" ], 

Примечание.

  • Параметр registryPath устанавливается без префикса, например https:// или oci://. If needed, publisher must define a prefix in the helm package.
  • imagePullSecrets and registryPath must be provided in the create NFDVersion onboarding step.

Other considerations with Legacy method

Издатель должен учитывать следующие рекомендации при использовании устаревшего метода:

  • Избегайте ссылок на внешний реестр
  • Выполнение ручной проверки
  • Ensure static image repository and tags

Избегайте ссылок на внешний реестр

Пользователи должны избегать использования ссылок на внешний реестр. Например, если в deployment.yaml используется жестко закодированный путь к реестру или ссылки на внешний реестр, это приведет к ошибке проверки.

Выполнение ручной проверки

Review the images and container specs created to ensure the images have prefix of registryPath and the imagePullSecrets are populated with secretName.

 helm template --set "global.imagePullSecrets[0].name=<secretName>" --set "global.registry.url=<registryPath>" <release-name> <chart-name> --dry-run

OR

 helm install --set "global.imagePullSecrets[0].name=<secretName>" --set "global.registry.url=<registryPath>" <release-name> <chart-name> --dry-run
 kubectl create secret <secretName> regcred --docker-server=<registryPath> --dockerusername=<regusername> --docker-password=<regpassword>

Ensure static image repository and tags

Each helm chart should contain static image repository and tags. Статические значения задаются следующим образом:

  • Setting them in the image line or,
  • Setting them in values.yaml and not exposing these values in the Network Function Design Version (NFDV).

A Network Function Design Version (NFDV) should map to a static set of helm charts and images. Диаграммы и изображения обновляются только путем публикации новой версии конструктора сетевых функций (NFDV).

 image: "{{ .Values.global.registryPath }}/contosoapp:1.14.2“

Or

 image: "{{ .Values.global.registryPath }}/{{ .Values.image.repository }}:{{ .Values.image.tag}}“
 
YAML values.yaml
image:
  repository: contosoapp
  tag: 1.14.2
 image: http://myUrl/{{ .Values.image.repository }}:{{ .Values.image.tag}}

injectArtifactStoreDetails requirements for registryPath and imagePullSecrets

In some cases, third-party helm charts may not be fully compliant with AOSM requirements for registryPath. In this case, the injectArtifactStoreDetails feature can be used to avoid making compliance changes to helm packages. With injectArtifactStoreDetails enabled, a webhook method is used to inject the proper registryPath and imagePullSecrets dynamically during the pod operations. This overrides the values which are configured in the helm package. A publisher still must use legal dummy values where registryPath and imagePullSecrets are referenced, usually in the global section of values.yaml.

В следующем values.yaml примере показано, как издатель может предоставить значения registryPath и imagePullSecretsvalue для обеспечения совместимости с подходом injectArtifactStoreDetails.

global: 
   registryPath: “azure.io”
   imagePullSecrets: ["abc123"] 

Примечание.

If registryPath is left blank in underlying helm package, site network service (SNS) deployment fails while trying to download image.

Использование метода injectArtifactStoreDetails

To enable injectArtifactStoreDetails, set the installOptions parameter in the NF resource roleOverrides section to true, as shown in the following example.

resource networkFunction 'Microsoft.HybridNetwork/networkFunctions@2023-09-01' = {
  name: nfName
  location: location
  properties: {
    nfviType: 'AzureArcKubernetes'
    networkFunctionDefinitionVersionResourceReference: {
      id: nfdvId
      idType: 'Open'
    }
    allowSoftwareUpdate: true
    nfviId: nfviId
    deploymentValues: deploymentValues
    configurationType: 'Open'
    roleOverrideValues: [
      // Use inject artifact store details feature on test app 1
      '{"name":"testapp1", "deployParametersMappingRuleProfile":{"helmMappingRuleProfile":{"options":{"installOptions":{"atomic":"false","wait":"false","timeout":"60","injectArtifactStoreDetails":"true"},"upgradeOptions": {"atomic": "false", "wait": "true", "timeout": "100", "injectArtifactStoreDetails": "true"}}}}}'
    ]
  }
}

Примечание.

The helm chart package must still expose properly formatted registryPath and imagePullSecrets values.

Требования к реестру кластера для registryPath и imagePullSecrets

With cluster registry, images are copied from the publisher ACR to a local docker repository on the nexus AKS (NAKS) cluster. When enabled, a webhook method is used to inject the proper registryPath and imagePullSecrets dynamically during the pod operations. This overrides the values which are configured in the helm package. A publisher still must use legal dummy values where registryPath and imagePullSecrets are referenced, usually in global section of values.yaml.

В следующем values.yaml примере показано, как издатель может предоставить значения registryPath и imagePullSecretsvalue для обеспечения совместимости с подходом к реестру кластера.

global: 
   registryPath: “azure.io”
   imagePullSecrets: ["abc123"] 

Примечание.

Если registryPath остается пустым в базовом пакете helm, развертывание SNS завершается сбоем при попытке скачать образ.

Сведения об использовании реестра кластеров см. в документации по концепции.

Ограничения неизменяемости диаграммы

Ограничения неизменяемости препятствуют изменению файла или каталога. Например, неизменяемый файл нельзя изменить или переименовать. Пользователи должны избегать использования изменяемых тегов, таких как последние, разработки или стабильные. For example, if deployment.yaml used 'latest' for the .Values.image.tag the deployment would fail.

 image: "{{ .Values.global.registryPath }}/{{ .Values.image.repository }}:{{ .Values.image.tag}}“

Chart CRD declaration and usage split

We recommend splitting the declaration and usage of customer resource definitions (CRD) into separate helm charts to support updates. Подробную информацию см. в статье method-2-separate-charts