cat << EOF | kubectl apply -f - --kubeconfig karmada-primaryapiVersion:apps.kruise.io/v1beta1kind:StatefulSetmetadata:name:samplespec:replicas:3serviceName:fake-serviceselector:matchLabels:app:sampletemplate:metadata:labels:app:samplespec:readinessGates:# A new condition that ensures the pod remains at NotReady state while the in-place update is happening- conditionType:InPlaceUpdateReadycontainers:- name:mainimage:nginx:alpinepodManagementPolicy:Parallel# allow parallel updates, works together with maxUnavailableupdateStrategy:type:RollingUpdaterollingUpdate:# Do in-place update if possible, currently only image update is supported for in-place updatepodUpdatePolicy:InPlaceIfPossible# Allow parallel updates with max number of unavailable instances equals to 2maxUnavailable:2---apiVersion:policy.karmada.io/v1alpha1kind:PropagationPolicymetadata:name:samplespec:resourceSelectors:- apiVersion:apps.kruise.io/v1beta1kind:StatefulSetname:sampleplacement:clusterAffinity:clusterNames:- primary- secondary# replicaScheduling:# replicaDivisionPreference: Weighted# replicaSchedulingType: DividedEOF
查看资源分发情况
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# kubectl get asts --kubeconfig karmada-primaryNAME DESIRED CURRENT UPDATED READY AGE
sample 3666 4m36s
# kubectl get asts --kubeconfig primaryNAME DESIRED CURRENT UPDATED READY AGE
sample 3333 3m7s
# kubectl get pod --kubeconfig primary -l app=sampleNAME READY STATUS RESTARTS AGE
sample-0 1/1 Running 0 3m28s
sample-1 1/1 Running 0 3m28s
sample-2 1/1 Running 0 3m28s
# kubectl get asts --kubeconfig secondaryNAME DESIRED CURRENT UPDATED READY AGE
sample 3333 3m38s
# kubectl get pod --kubeconfig secondary -l app=sampleNAME READY STATUS RESTARTS AGE
sample-0 1/1 Running 0 3m46s
sample-1 1/1 Running 0 3m46s
sample-2 1/1 Running 0 3m46s