Delen via


Fout bij doorgeven van resources: ClusterResourcePlacementApplied is onwaar

In dit artikel wordt beschreven hoe u problemen oplost ClusterResourcePlacementApplied wanneer u resources doorgeeft met behulp van de ClusterResourcePlacement object-API in Microsoft Azure Kubernetes Fleet Manager.

Symptomen

Wanneer u het ClusterResourcePlacement API-object in Azure Kubernetes Fleet Manager gebruikt om resources door te geven, mislukt de implementatie. De ClusterResourcePlacementApplied status wordt weergegeven als False.

Oorzaak

Dit probleem kan optreden vanwege een van de volgende redenen:

  • De resource bestaat al in het cluster en wordt niet beheerd door de vlootcontroller. U kunt dit probleem oplossen door het ClusterResourcePlacement YAML-manifestbestand bij te werken AllowCoOwnership ApplyStrategy zodat de fleetcontroller de resource kan beheren.
  • Een andere ClusterResourcePlacement implementatie beheert de resource voor het geselecteerde cluster al met behulp van een andere strategie voor toepassen.
  • De ClusterResourcePlacement implementatie past het manifest niet toe vanwege syntaxisfouten of ongeldige resourceconfiguraties. Dit kan ook gebeuren als een resource wordt doorgegeven via een envelopobject.

Stappen voor probleemoplossing

  1. Bekijk de ClusterResourcePlacement status en zoek de placementStatuses sectie. Controleer de placementStatuses waarde om te bepalen op welke clusters de ResourceApplied voorwaarde is ingesteld Falseen noteer de clusterName bijbehorende waarde.
  2. Zoek het Work object in het hubcluster. Gebruik de geïdentificeerde clusterName om het Work object te zoeken dat is gekoppeld aan het lidcluster. Zie De juiste werkresource zoeken die is ClusterResourcePlacementgekoppeld aan .
  3. Controleer de status van het Work object om inzicht te krijgen in de specifieke problemen die een geslaagde resourcetoepassing verhinderen.

Casestudy

In het volgende voorbeeld ClusterResourcePlacement probeert u een naamruimte met een implementatie door te geven aan twee lidclusters. De naamruimte bestaat echter al in één lidcluster, met name kind-cluster-1.

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

ClusterResourcePlacement-status

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

In de failedPlacements sectie voor kind-cluster-1wordt message uitgelegd waarom de resource niet is toegepast op het lidcluster. In de voorgaande conditions sectie wordt de Applied voorwaarde gemarkeerd kind-cluster-1 als false en wordt de NotAllWorkHaveBeenApplied reden weergegeven. Dit geeft aan dat het Work object dat is bedoeld voor het lidcluster kind-cluster-1 niet is toegepast. Zie De juiste werkresource zoeken die is ClusterResourcePlacementgekoppeld aan .

Werkstatus van soort-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

Controleer de Work status, met name de manifestConditions sectie. U kunt zien dat de naamruimte niet kan worden toegepast, maar de implementatie in de naamruimte is doorgegeven van de hub naar het lidcluster.

Oplossing

In deze situatie is een mogelijke oplossing het instellen van het AllowCoOwnership true beleid ApplyStrategy. Het is echter belangrijk om te zien dat deze beslissing door de gebruiker moet worden genomen omdat de resources mogelijk niet worden gedeeld.

Daarnaast kunt u de logboeken voor de Werkcontroller toepassen bekijken voor meer inzicht in waarom de resources niet beschikbaar zijn.

Contacteer ons voor hulp

Als u vragen hebt of hulp nodig hebt, maak een ondersteuningsaanvraag of vraag de Azure-communityondersteuning. U kunt ook productfeedback verzenden naar de Azure-feedbackcommunity.