Dela via


Resursspridningsfel: ClusterResourcePlacementApplied är falskt

I den här artikeln beskrivs hur du felsöker ClusterResourcePlacementApplied problem när du sprider resurser med hjälp av objekt-API:et ClusterResourcePlacement i Microsoft Azure Kubernetes Fleet Manager.

Symptom

När du använder ClusterResourcePlacement API-objektet i Azure Kubernetes Fleet Manager för att sprida resurser misslyckas distributionen. Statusen ClusterResourcePlacementApplied visas som False.

Orsak

Det här problemet kan inträffa på grund av någon av följande orsaker:

  • Resursen finns redan i klustret och hanteras inte av vagnparksstyrenheten. Lös problemet genom att uppdatera ClusterResourcePlacement YAML-manifestfilen som ska användas AllowCoOwnership inom ApplyStrategy så att vagnparksstyrenheten kan hantera resursen.
  • En annan ClusterResourcePlacement distribution hanterar redan resursen för det valda klustret med hjälp av en annan tillämpad strategi.
  • Distributionen ClusterResourcePlacement tillämpar inte manifestet på grund av syntaxfel eller ogiltiga resurskonfigurationer. Detta kan också inträffa om en resurs sprids via ett kuvertobjekt.

Felsökningsanvisningar

  1. Visa status och ClusterResourcePlacement leta upp avsnittet placementStatuses . Kontrollera värdet placementStatuses för att identifiera vilka kluster som har villkoret ResourceApplied inställt på Falseoch notera deras clusterName värde.
  2. Leta upp objektet Work i hubbklustret. Använd identifierade clusterName för att hitta objektet Work som är associerat med medlemsklustret. Mer information finns i Så här hittar du rätt arbetsresurs som är associerad med ClusterResourcePlacement.
  3. Kontrollera objektets Work status för att förstå de specifika problem som hindrar ett lyckat resursprogram.

Fallstudie

I följande exempel ClusterResourcePlacement försöker sprida ett namnområde som innehåller en distribution till två medlemskluster. Namnområdet finns dock redan i ett medlemskluster, särskilt kind-cluster-1.

ClusterResourcePlacement-specifikationer

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

I avsnittet failedPlacements för kind-cluster-1förklarar fälten message varför resursen inte tillämpades på medlemsklustret. I föregående conditions avsnitt flaggas villkoret Applied för kind-cluster-1 som false och visar NotAllWorkHaveBeenApplied orsaken. Detta indikerar att objektet Work som är avsett för medlemsklustret kind-cluster-1 inte tillämpades. Mer information finns i Så här hittar du rätt arbetsresurs som är associerad med ClusterResourcePlacement.

Arbetsstatus för 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

Kontrollera statusen Work , särskilt avsnittet manifestConditions . Du kan se att namnområdet inte kunde tillämpas, men distributionen i namnområdet spreds från hubben till medlemsklustret.

Åtgärd

I den här situationen är en potentiell lösning att ange AllowCoOwnership till true i ApplyStrategy-principen. Det är dock viktigt att observera att det här beslutet bör fattas av användaren eftersom resurserna kanske inte delas.

Dessutom kan du granska loggarna för Apply Work Controller (Tillämpa arbetskontrollant) för mer information om varför resurserna inte är tillgängliga.

Kontakta oss för att få hjälp

Om du har frågor eller behöver hjälp skapar du en supportförfrågan eller frågar Azure community support. Du kan också skicka produktfeedback till Azure-feedbackcommunityn.