Compartir a través de


Error de propagación de recursos: ClusterResourcePlacementApplied es False

En este artículo se describe cómo solucionar problemas ClusterResourcePlacementApplied al propagar recursos mediante la ClusterResourcePlacement API de objetos de Microsoft Azure Kubernetes Fleet Manager.

Síntomas

Cuando se usa el ClusterResourcePlacement objeto de API en Azure Kubernetes Fleet Manager para propagar recursos, se produce un error en la implementación. El ClusterResourcePlacementApplied estado se muestra como False.

Causa

Este problema puede producirse debido a uno de los siguientes motivos:

  • El recurso ya existe en el clúster y el controlador de flota no lo administra. Para resolver este problema, actualice el archivo YAML de ClusterResourcePlacement manifiesto que se va a usar AllowCoOwnership dentro ApplyStrategy para permitir que el controlador de flota administre el recurso.
  • Otra ClusterResourcePlacement implementación ya está administrando el recurso para el clúster seleccionado mediante una estrategia de aplicación diferente.
  • La ClusterResourcePlacement implementación no aplica el manifiesto debido a errores de sintaxis o configuraciones de recursos no válidas. Esto también puede ocurrir si un recurso se propaga a través de un objeto envelope.

Pasos para solucionar problemas

  1. Vea el ClusterResourcePlacement estado y busque la placementStatuses sección. Compruebe el placementStatuses valor para identificar qué clústeres tienen la ResourceApplied condición establecida Falseen y anote su clusterName valor.
  2. Busque el Work objeto en el clúster del concentrador. Use el objeto identificado clusterName para buscar el Work objeto asociado al clúster de miembros. Para obtener más información, vea Cómo buscar el recurso work correcto asociado a ClusterResourcePlacement.
  3. Compruebe el estado del Work objeto para comprender los problemas específicos que impiden la aplicación de recursos correcta.

Caso práctico

En el ejemplo siguiente, ClusterResourcePlacement está intentando propagar un espacio de nombres que contiene una implementación en dos clústeres miembro. Sin embargo, el espacio de nombres ya existe en un clúster miembro, específicamente kind-cluster-1.

Especificaciones de ClusterResourcePlacement

apiVersion: placement.kubernetes-fleet.io/v1beta1
kind: ClusterResourcePlacement
metadata:
  name: crp
spec:
  policy:
    clusterNames:
    - kind-cluster-1
    - kind-cluster-2
    placementType: PickFixed
  resourceSelectors:
  - group: ""
    kind: Namespace
    name: test-ns
    version: v1
  revisionHistoryLimit: 10
  strategy:
    type: RollingUpdate

Estado ClusterResourcePlacement

status:
  conditions:
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message:couldn't find all the clusters needed as specified by the scheduling
      policy
    observedGeneration: 1
    reason: SchedulingPolicyUnfulfilled
    status: "False"
    type: ClusterResourcePlacementScheduled
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message: All 2 cluster(s) start rolling out the latest resource
    observedGeneration: 1
    reason: RolloutStarted
    status: "True"
    type: ClusterResourcePlacementRolloutStarted
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message: No override rules are configured for the selected resources
    observedGeneration: 1
    reason: NoOverrideSpecified
    status: "True"
    type: ClusterResourcePlacementOverridden
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message: Works(s) are succcesfully created or updated in the 2 target clusters'
      namespaces
    observedGeneration: 1
    reason: WorkSynchronized
    status: "True"
    type: ClusterResourcePlacementWorkSynchronized
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message: Failed to apply resources to 1 clusters, please check the `failedPlacements`
      status
    observedGeneration: 1
    reason: ApplyFailed
    status: "False"
    type: ClusterResourcePlacementApplied
  observedResourceIndex: "0"
  placementStatuses:
  - clusterName: kind-cluster-2
    conditions:
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      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:32:40Z"
      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:32:40Z"
      message: No override rules are configured for the selected resources
      observedGeneration: 1
      reason: NoOverrideSpecified
      status: "True"
      type: Overridden
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: All of the works are synchronized to the latest
      observedGeneration: 1
      reason: AllWorkSynced
      status: "True"
      type: WorkSynchronized
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: All corresponding work objects are applied
      observedGeneration: 1
      reason: AllWorkHaveBeenApplied
      status: "True"
      type: Applied
    - lastTransitionTime: "2024-05-07T23:32:49Z"
      message: The availability of work object crp-4-work isn't trackable
      observedGeneration: 1
      reason: WorkNotTrackable
      status: "True"
      type: Available
  - clusterName: kind-cluster-1
    conditions:
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      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:32:40Z"
      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:32:40Z"
      message: No override rules are configured for the selected resources
      observedGeneration: 1
      reason: NoOverrideSpecified
      status: "True"
      type: Overridden
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: All of the works are synchronized to the latest
      observedGeneration: 1
      reason: AllWorkSynced
      status: "True"
      type: WorkSynchronized
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: Work object crp-4-work isn't applied
      observedGeneration: 1
      reason: NotAllWorkHaveBeenApplied
      status: "False"
      type: Applied
    failedPlacements:
    - condition:
        lastTransitionTime: "2024-05-07T23:32:40Z"
        message: 'Failed to apply manifest: failed to process the request due to a
          client error: resource exists and isn't managed by the fleet controller
          and co-ownernship is disallowed'
        reason: ManifestsAlreadyOwnedByOthers
        status: "False"
        type: Applied
      kind: Namespace
      name: test-ns
      version: v1
  selectedResources:
  - kind: Namespace
    name: test-ns
    version: v1
  - group: apps
    kind: Deployment
    name: test-nginx
    namespace: test-ns
    version: v1

En la failedPlacements sección de kind-cluster-1, los message campos explican por qué el recurso no se aplicó en el clúster miembro. En la sección anterior conditions , la Applied condición de kind-cluster-1 se marca como false y muestra el NotAllWorkHaveBeenApplied motivo. Esto indica que no se aplicó el Work objeto destinado al clúster kind-cluster-1 de miembros. Para obtener más información, vea Cómo buscar el recurso work correcto asociado a ClusterResourcePlacement.

Estado de trabajo de kind-cluster-1

 status:
  conditions:
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message: 'Apply manifest {Ordinal:0 Group: Version:v1 Kind:Namespace Resource:namespaces
      Namespace: Name:test-ns} failed'
    observedGeneration: 1
    reason: WorkAppliedFailed
    status: "False"
    type: Applied
  - lastTransitionTime: "2024-05-07T23:32:40Z"
    message: ""
    observedGeneration: 1
    reason: WorkAppliedFailed
    status: Unknown
    type: Available
  manifestConditions:
  - conditions:
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: 'Failed to apply manifest: failed to process the request due to a client
        error: resource exists and isn't managed by the fleet controller and co-ownernship
        is disallowed'
      reason: ManifestsAlreadyOwnedByOthers
      status: "False"
      type: Applied
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: Manifest isn't applied yet
      reason: ManifestApplyFailed
      status: Unknown
      type: Available
    identifier:
      kind: Namespace
      name: test-ns
      ordinal: 0
      resource: namespaces
      version: v1
  - conditions:
    - lastTransitionTime: "2024-05-07T23:32:40Z"
      message: Manifest is already up to date
      observedGeneration: 1
      reason: ManifestAlreadyUpToDate
      status: "True"
      type: Applied
    - lastTransitionTime: "2024-05-07T23:32:51Z"
      message: Manifest is trackable and available now
      observedGeneration: 1
      reason: ManifestAvailable
      status: "True"
      type: Available
    identifier:
      group: apps
      kind: Deployment
      name: test-nginx
      namespace: test-ns
      ordinal: 1
      resource: deployments
      version: v1

Compruebe el Work estado, especialmente la manifestConditions sección . Puede ver que no se pudo aplicar el espacio de nombres, pero la implementación dentro del espacio de nombres se propagó desde el centro al clúster miembro.

Solución

En esta situación, una posible solución consiste en establecer en AllowCoOwnership true en la directiva ApplyStrategy. Sin embargo, es importante tener en cuenta que el usuario debe tomar esta decisión porque es posible que los recursos no se compartan.

Además, puede revisar los registros de Apply Work Controller para obtener más información sobre por qué los recursos no están disponibles.

Ponte en contacto con nosotros para obtener ayuda

Si tiene preguntas o necesita ayuda, cree una solicitud de soporte o busque consejo en la comunidad de Azure. También puede enviar comentarios sobre el producto con los comentarios de la comunidad de Azure.