Help Center/ Ubiquitous Cloud Native Service/ FAQs/ Cluster Federation/ What Can I Do If an HPA Created on the Cluster Federation Management Plane Fails to Be Distributed to Member Clusters?
Updated on 2024-10-30 GMT+08:00

What Can I Do If an HPA Created on the Cluster Federation Management Plane Fails to Be Distributed to Member Clusters?

Context

After an HPA is created on the cluster federation management plane, the PropagationPolicy fails to distribute the HPA to the member cluster earlier than v1.23.

Possible Cause

Currently, the API server version of the UCS cluster federation is 1.25. Therefore, the HPA has two versions: autoscaling/v2 and autoscaling/v1. However, only HPA autoscaling/v2 is distributed. Clusters earlier than v1.23 do not support HPA autoscaling/v2. As a result, the HPA cannot be distributed to the member cluster earlier than v1.23. Check resourceBinding of the HPA. The error message "cluster(s) did not have the API resource" is displayed.

Solution

Before distributing the HPA, you can upgrade the member cluster to v1.23 or later, which supports the HPA autoscaling/v2 by default.

If you still want to distribute HPA autoscaling/v1 to member clusters, set the resourceSelectors[i].apiVersion field in your PropagationPolicy to autoscaling/v2, as shown in the example YAML. After the distribution is successful, you can query HPA autoscaling/v1 in the member cluster.

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: test-hpa
spec:
  maxReplicas: 5
  minReplicas: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: nginx
  targetCPUUtilizationPercentage: 10
---
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: test-hpa-pp
spec:
  placement:
    clusterAffinity:
      clusterNames:
        - member1
  resourceSelectors:
    - apiVersion: autoscaling/v2
      kind: HorizontalPodAutoscaler
      name: test-hpa
      namespace: default