Errore di propagazione delle risorse: ClusterResourcePlacementScheduled è false
Questo articolo descrive come risolvere i problemi ClusterResourcePlacementScheduled
durante la propagazione delle risorse usando l'oggetto ClusterResourcePlacement
API in Azure Kubernetes Fleet Manager.
Sintomi
Quando si usa l'oggetto API in Azure Kubernetes Fleet Manager per propagare le risorse, l'utilità ClusterResourcePlacement
di pianificazione per i carichi di lavoro Fleet non riesce a trovare tutti i cluster necessari specificati dai criteri di pianificazione e lo stato della ClusterResourcePlacementScheduled
condizione viene visualizzato come False
.
Note
Per ottenere altre informazioni sul motivo per cui la pianificazione ha esito negativo, è possibile controllare i log dell'utilità di pianificazione.
Causa
Questo problema può verificarsi per uno dei motivi seguenti:
- I criteri di posizionamento sono impostati su
PickFixed
, ma i nomi dei cluster specificati non corrispondono ad alcun nome del cluster membro aggiunto nella flotta o il cluster specificato non è più connesso alla flotta. - I criteri di posizionamento sono impostati su
PickN
e vengono specificati n cluster, ma meno di N cluster hanno aggiunto la flotta o soddisfatto i criteri di posizionamento. - Il
ClusterResourcePlacement
selettore di risorse seleziona uno spazio dei nomi riservato.
Note
Quando i criteri di posizionamento sono impostati su PickAll
, la ClusterResourcePlacementScheduled
condizione viene impostata su True
.
Case study
Nell'esempio seguente, ClusterResourcePlacement
con un PickN
criterio di posizionamento tenta di propagare le risorse a due cluster etichettati env:prod
. I due cluster, denominati kind-cluster-1
e kind-cluster-2
, hanno unito la flotta. Tuttavia, solo un cluster membro, kind-cluster-1
, ha l'etichetta env:prod
.
Specifica ClusterResourcePlacement
spec:
policy:
affinity:
clusterAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
clusterSelectorTerms:
- labelSelector:
matchLabels:
env: prod
numberOfClusters: 2
placementType: PickN
resourceSelectors:
...
revisionHistoryLimit: 10
strategy:
type: RollingUpdate
Stato di ClusterResourcePlacement
status:
conditions:
- lastTransitionTime: "2024-05-07T22:36:33Z"
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-07T22:36:33Z"
message: All 1 cluster(s) start rolling out the latest resource
observedGeneration: 1
reason: RolloutStarted
status: "True"
type: ClusterResourcePlacementRolloutStarted
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: No override rules are configured for the selected resources
observedGeneration: 1
reason: NoOverrideSpecified
status: "True"
type: ClusterResourcePlacementOverridden
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: Works(s) are successfully created or updated in the 1 target clusters'
namespaces
observedGeneration: 1
reason: WorkSynchronized
status: "True"
type: ClusterResourcePlacementWorkSynchronized
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: The selected resources are successfully applied to 1 clusters
observedGeneration: 1
reason: ApplySucceeded
status: "True"
type: ClusterResourcePlacementApplied
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: The selected resources in 1 cluster are available now
observedGeneration: 1
reason: ResourceAvailable
status: "True"
type: ClusterResourcePlacementAvailable
observedResourceIndex: "0"
placementStatuses:
- clusterName: kind-cluster-1
conditions:
- lastTransitionTime: "2024-05-07T22:36:33Z"
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-07T22:36:33Z"
message: Detected the new changes on the resources and started the rollout process
observedGeneration: 1
reason: RolloutStarted
status: "True"
type: RolloutStarted
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: No override rules are configured for the selected resources
observedGeneration: 1
reason: NoOverrideSpecified
status: "True"
type: Overridden
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: All of the works are synchronized to the latest
observedGeneration: 1
reason: AllWorkSynced
status: "True"
type: WorkSynchronized
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: All corresponding work objects are applied
observedGeneration: 1
reason: AllWorkHaveBeenApplied
status: "True"
type: Applied
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: All corresponding work objects are available
observedGeneration: 1
reason: AllWorkAreAvailable
status: "True"
type: Available
- conditions:
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: 'kind-cluster-2 is not selected: ClusterUnschedulable, cluster does not
match with any of the required cluster affinity terms'
observedGeneration: 1
reason: ScheduleFailed
status: "False"
type: Scheduled
selectedResources:
...
Nello stato lo stato della ClusterResourcePlacement
ClusterResourcePlacementScheduled
condizione viene visualizzato come False
. Per capire perché l'utilità di pianificazione non è in grado di pianificare la risorsa per i criteri di posizionamento specificati, controllare la specifica e lo ClusterSchedulingPolicySnapshot
stato. Per informazioni su come ottenere la versione più recente ClusterSchedulingPolicySnapshot
, vedere Come è possibile trovare e verificare la versione più recente di ClusterSchedulingPolicySnapshot per una distribuzione ClusterResourcePlacement?
ClusterSchedulingPolicySnapshot più recente
apiVersion: placement.kubernetes-fleet.io/v1
kind: ClusterSchedulingPolicySnapshot
metadata:
annotations:
kubernetes-fleet.io/CRP-generation: "1"
kubernetes-fleet.io/number-of-clusters: "2"
creationTimestamp: "2024-05-07T22:36:33Z"
generation: 1
labels:
kubernetes-fleet.io/is-latest-snapshot: "true"
kubernetes-fleet.io/parent-CRP: crp-2
kubernetes-fleet.io/policy-index: "0"
name: crp-2-0
ownerReferences:
- apiVersion: placement.kubernetes-fleet.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: ClusterResourcePlacement
name: crp-2
uid: 48bc1e92-a8b9-4450-a2d5-c6905df2cbf0
resourceVersion: "10090"
uid: 2137887e-45fd-4f52-bbb7-b96f39854625
spec:
policy:
affinity:
clusterAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
clusterSelectorTerms:
- labelSelector:
matchLabels:
env: prod
placementType: PickN
policyHash: ZjE0Yjk4YjYyMTVjY2U3NzQ1MTZkNWRhZjRiNjQ1NzQ4NjllNTUyMzZkODBkYzkyYmRkMGU3OTI3MWEwOTkyNQ==
status:
conditions:
- lastTransitionTime: "2024-05-07T22:36:33Z"
message: could not find all the clusters needed as specified by the scheduling
policy
observedGeneration: 1
reason: SchedulingPolicyUnfulfilled
status: "False"
type: Scheduled
observedCRPGeneration: 1
targetClusters:
- clusterName: kind-cluster-1
clusterScore:
affinityScore: 0
priorityScore: 0
reason: picked by scheduling policy
selected: true
- clusterName: kind-cluster-2
reason: ClusterUnschedulable, cluster does not match with any of the required
cluster affinity terms
selected: false
Risoluzione
In questo scenario, per risolvere questo problema, aggiungere anche l'etichetta env:prod
alla risorsa cluster membro per kind-cluster-2
, in modo che l'utilità di pianificazione possa selezionare il cluster per propagare le risorse.
Contattaci per ricevere assistenza
In caso di domande o bisogno di assistenza, creare una richiesta di supporto tecnico oppure formula una domanda nel Supporto della community di Azure. È possibile anche inviare un feedback sul prodotto al feedback della community di Azure.