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


Сбой распространения ресурсов: ClusterResourcePlacementRolloutStarted имеет значение false

В этой статье описывается, как устранять проблемы ClusterResourcePlacementRolloutStarted при распространении ресурсов с помощью ClusterResourcePlacement объекта API в Azure Kubernetes Fleet Manager.

Симптомы

При использовании ClusterResourcePlacement объекта API в Azure Kubernetes Fleet Manager для распространения ресурсов выбранные ресурсы не развертываются во всех запланированных кластерах, а ClusterResourcePlacementRolloutStarted состояние условия отображается как False.

Примечание.

Чтобы получить дополнительные сведения о том, почему развертывание не запускается, можно проверить журналы контроллера развертывания.

Причина

Стратегия развертывания размещения кластерных ресурсов заблокирована, так как RollingUpdate конфигурация слишком строгая.

Действия по устранению неполадок

  1. ClusterResourcePlacement В разделе состояния проверьте placementStatuses наличие кластеров с заданным значением RolloutStarted Falseсостояния.
  2. Найдите соответствующий ClusterResourceBinding для идентифицированного кластера. Дополнительные сведения см. в статье о том, как найти последний ресурс ClusterResourceBinding? Этот ресурс должен указывать Work состояние (было ли оно создано или обновлено).
  3. Проверьте значения maxUnavailable и maxSurge убедитесь, что они соответствуют вашим ожиданиям.

Пример использования

В следующем примере ClusterResourcePlacement пытается распространить пространство имен на три кластера членов. Однако во время первоначального ClusterResourcePlacementсоздания пространства имен не существовало в кластере концентратора, а флот в настоящее время состоит из двух кластеров-членов с именем kind-cluster-1 и kind-cluster-2.

Спецификация ClusterResourcePlacement

spec:
  policy:
    numberOfClusters: 3
    placementType: PickN
  resourceSelectors:
  - group: ""
    kind: Namespace
    name: test-ns
    version: v1
  revisionHistoryLimit: 10
  strategy:
    type: RollingUpdate

Состояние ClusterResourcePlacement

status:
  conditions:
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: could not find all the clusters needed as specified by the scheduling
      policy
    observedGeneration: 1
    reason: SchedulingPolicyUnfulfilled
    status: "False"
    type: ClusterResourcePlacementScheduled
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: All 2 cluster(s) start rolling out the latest resource
    observedGeneration: 1
    reason: RolloutStarted
    status: "True"
    type: ClusterResourcePlacementRolloutStarted
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: No override rules are configured for the selected resources
    observedGeneration: 1
    reason: NoOverrideSpecified
    status: "True"
    type: ClusterResourcePlacementOverridden
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: Works(s) are successfully created or updated in the 2 target clusters'
      namespaces
    observedGeneration: 1
    reason: WorkSynchronized
    status: "True"
    type: ClusterResourcePlacementWorkSynchronized
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: The selected resources are successfully applied to 2 clusters
    observedGeneration: 1
    reason: ApplySucceeded
    status: "True"
    type: ClusterResourcePlacementApplied
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: The selected resources in 2 cluster are available now
    observedGeneration: 1
    reason: ResourceAvailable
    status: "True"
    type: ClusterResourcePlacementAvailable
  observedResourceIndex: "0"
  placementStatuses:
  - clusterName: kind-cluster-2
    conditions:
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: 'Successfully scheduled resources for placement in kind-cluster-2 (affinity
        score: 0, topology spread score: 0): picked by scheduling policy'
      observedGeneration: 1
      reason: Scheduled
      status: "True"
      type: Scheduled
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: Detected the new changes on the resources and started the rollout process
      observedGeneration: 1
      reason: RolloutStarted
      status: "True"
      type: RolloutStarted
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: No override rules are configured for the selected resources
      observedGeneration: 1
      reason: NoOverrideSpecified
      status: "True"
      type: Overridden
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: All of the works are synchronized to the latest
      observedGeneration: 1
      reason: AllWorkSynced
      status: "True"
      type: WorkSynchronized
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: All corresponding work objects are applied
      observedGeneration: 1
      reason: AllWorkHaveBeenApplied
      status: "True"
      type: Applied
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: All corresponding work objects are available
      observedGeneration: 1
      reason: AllWorkAreAvailable
      status: "True"
      type: Available
  - clusterName: kind-cluster-1
    conditions:
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: 'Successfully scheduled resources for placement in kind-cluster-1 (affinity
        score: 0, topology spread score: 0): picked by scheduling policy'
      observedGeneration: 1
      reason: Scheduled
      status: "True"
      type: Scheduled
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: Detected the new changes on the resources and started the rollout process
      observedGeneration: 1
      reason: RolloutStarted
      status: "True"
      type: RolloutStarted
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: No override rules are configured for the selected resources
      observedGeneration: 1
      reason: NoOverrideSpecified
      status: "True"
      type: Overridden
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: All of the works are synchronized to the latest
      observedGeneration: 1
      reason: AllWorkSynced
      status: "True"
      type: WorkSynchronized
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: All corresponding work objects are applied
      observedGeneration: 1
      reason: AllWorkHaveBeenApplied
      status: "True"
      type: Applied
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: All corresponding work objects are available
      observedGeneration: 1
      reason: AllWorkAreAvailable
      status: "True"
      type: Available

Предыдущие выходные данные указывают на то, что пространство имен ресурсов test-ns никогда не существовало в кластере концентратора и отображает следующие ClusterResourcePlacement состояния условий:

  • Состояние ClusterResourcePlacementScheduled условия отображается так False, как указанная политика направлена на выбор трех кластеров, но планировщик может размещать только размещение в двух доступных и присоединенных кластерах.
  • Состояние ClusterResourcePlacementRolloutStarted условия отображается как True, так как процесс развертывания начался с двух выбранных кластеров.
  • Состояние ClusterResourcePlacementOverridden условия отображается как True, так как правила переопределения не настроены для выбранных ресурсов.
  • Состояние ClusterResourcePlacementWorkSynchronized условия отображается как True.
  • Состояние ClusterResourcePlacementApplied условия отображается как True.
  • Состояние ClusterResourcePlacementAvailable условия отображается как True.

Чтобы обеспечить простое распространение пространства имен в соответствующих кластерах, перейдите к созданию test-ns пространства имен в кластере концентратора.

Состояние ClusterResourcePlacement после создания пространства имен test-ns в кластере концентратора

status:
  conditions:
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: could not find all the clusters needed as specified by the scheduling
      policy
    observedGeneration: 1
    reason: SchedulingPolicyUnfulfilled
    status: "False"
    type: ClusterResourcePlacementScheduled
  - lastTransitionTime: "2024-05-07T23:13:51Z"
    message: The rollout is being blocked by the rollout strategy in 2 cluster(s)
    observedGeneration: 1
    reason: RolloutNotStartedYet
    status: "False"
    type: ClusterResourcePlacementRolloutStarted
  observedResourceIndex: "1"
  placementStatuses:
  - clusterName: kind-cluster-2
    conditions:
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: 'Successfully scheduled resources for placement in kind-cluster-2 (affinity
        score: 0, topology spread score: 0): picked by scheduling policy'
      observedGeneration: 1
      reason: Scheduled
      status: "True"
      type: Scheduled
    - lastTransitionTime: "2024-05-07T23:13:51Z"
      message: The rollout is being blocked by the rollout strategy
      observedGeneration: 1
      reason: RolloutNotStartedYet
      status: "False"
      type: RolloutStarted
  - clusterName: kind-cluster-1
    conditions:
    - lastTransitionTime: "2024-05-07T23:08:53Z"
      message: 'Successfully scheduled resources for placement in kind-cluster-1 (affinity
        score: 0, topology spread score: 0): picked by scheduling policy'
      observedGeneration: 1
      reason: Scheduled
      status: "True"
      type: Scheduled
    - lastTransitionTime: "2024-05-07T23:13:51Z"
      message: The rollout is being blocked by the rollout strategy
      observedGeneration: 1
      reason: RolloutNotStartedYet
      status: "False"
      type: RolloutStarted
  selectedResources:
  - kind: Namespace
    name: test-ns
    version: v1

В предыдущих выходных данных ClusterResourcePlacementScheduled состояние условия отображается как False. Состояние ClusterResourcePlacementRolloutStarted также отображается как False в сообщении: The rollout is being blocked by the rollout strategy in 2 cluster(s)

Проверьте последнюю версию ClusterResourceSnapshot , выполнив команду в разделе "Как найти последний ресурс ClusterResourceBinding?

Последняя версия ClusterResourceSnapshot

apiVersion: placement.kubernetes-fleet.io/v1
kind: ClusterResourceSnapshot
metadata:
  annotations:
    kubernetes-fleet.io/number-of-enveloped-object: "0"
    kubernetes-fleet.io/number-of-resource-snapshots: "1"
    kubernetes-fleet.io/resource-hash: 72344be6e268bc7af29d75b7f0aad588d341c228801aab50d6f9f5fc33dd9c7c
  creationTimestamp: "2024-05-07T23:13:51Z"
  generation: 1
  labels:
    kubernetes-fleet.io/is-latest-snapshot: "true"
    kubernetes-fleet.io/parent-CRP: crp-3
    kubernetes-fleet.io/resource-index: "1"
  name: crp-3-1-snapshot
  ownerReferences:
  - apiVersion: placement.kubernetes-fleet.io/v1beta1
    blockOwnerDeletion: true
    controller: true
    kind: ClusterResourcePlacement
    name: crp-3
    uid: b4f31b9a-971a-480d-93ac-93f093ee661f
  resourceVersion: "14434"
  uid: 85ee0e81-92c9-4362-932b-b0bf57d78e3f
spec:
  selectedResources:
  - apiVersion: v1
    kind: Namespace
    metadata:
      labels:
        kubernetes.io/metadata.name: test-ns
      name: test-ns
    spec:
      finalizers:
      - kubernetes

ClusterResourceSnapshot В спецификации в selectedResources разделе теперь отображается пространство test-nsимен.

ClusterResourceBinding kind-cluster-1 Проверьте, была ли она обновлена после создания пространства test-ns имен. Дополнительные сведения см. в статье "Как найти последний ресурс ClusterResourceBinding?".

ClusterResourceBinding для kind-cluster-1

apiVersion: placement.kubernetes-fleet.io/v1
kind: ClusterResourceBinding
metadata:
  creationTimestamp: "2024-05-07T23:08:53Z"
  finalizers:
  - kubernetes-fleet.io/work-cleanup
  generation: 2
  labels:
    kubernetes-fleet.io/parent-CRP: crp-3
  name: crp-3-kind-cluster-1-7114c253
  resourceVersion: "14438"
  uid: 0db4e480-8599-4b40-a1cc-f33bcb24b1a7
spec:
  applyStrategy:
    type: ClientSideApply
  clusterDecision:
    clusterName: kind-cluster-1
    clusterScore:
      affinityScore: 0
      priorityScore: 0
    reason: picked by scheduling policy
    selected: true
  resourceSnapshotName: crp-3-0-snapshot
  schedulingPolicySnapshotName: crp-3-0
  state: Bound
  targetCluster: kind-cluster-1
status:
  conditions:
  - lastTransitionTime: "2024-05-07T23:13:51Z"
    message: The resources cannot be updated to the latest because of the rollout
      strategy
    observedGeneration: 2
    reason: RolloutNotStartedYet
    status: "False"
    type: RolloutStarted
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: No override rules are configured for the selected resources
    observedGeneration: 2
    reason: NoOverrideSpecified
    status: "True"
    type: Overridden
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: All of the works are synchronized to the latest
    observedGeneration: 2
    reason: AllWorkSynced
    status: "True"
    type: WorkSynchronized
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: All corresponding work objects are applied
    observedGeneration: 2
    reason: AllWorkHaveBeenApplied
    status: "True"
    type: Applied
  - lastTransitionTime: "2024-05-07T23:08:53Z"
    message: All corresponding work objects are available
    observedGeneration: 2
    reason: AllWorkAreAvailable
    status: "True"
    type: Available

Останки ClusterResourceBinding остаются неизменными. В спецификации resourceSnapshotName все еще ссылается на старое ClusterResourceBinding ClusterResourceSnapshot имя. Эта проблема возникает при отсутствии явных RollingUpdate входных данных от пользователя, так как применяются значения по умолчанию:

  • Значение maxUnavailable настроено на 25 % × 3 (требуемое число), округлено до 1.
  • Значение maxSurge настроено на 25 % × 3 (требуемое число), округлено до 1.

Почему ClusterResourceBinding не обновляется

Первоначально, когда ClusterResourcePlacement он был создан, были созданы два ClusterResourceBindings . Однако, так как развертывание не применялось к начальному этапу, ClusterResourcePlacementRolloutStarted условие было задано True.

После создания test-ns пространства имен в кластере концентратора контроллер развертывания попытался обновить два существующих ClusterResourceBindings. Однако было установлено 1 значение maxUnavailable из-за отсутствия кластеров членов, что привело RollingUpdate к слишком строгой конфигурации.

Примечание.

При обновлении, если одна из привязок не применяется, она также нарушает RollingUpdate конфигурацию, что приводит maxUnavailable к настройке 1.

Решение

В этой ситуации, чтобы устранить эту проблему, рекомендуется вручную задать maxUnavailable значение больше, чем 1 для расслабления конфигурации RollingUpdate . Кроме того, можно присоединиться к третьему кластеру-члену.

Свяжитесь с нами для получения помощи

Если у вас есть вопросы или вам нужна помощь, создайте запрос в службу поддержки или обратитесь за поддержкой сообщества Azure. Вы также можете отправить отзыв о продукте в сообщество отзывов Azure.