You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flink Kubernetes部署HPA报错:控制器无法获取Selector求助

我使用以下YAML部署Flink有状态应用,任务运行完全正常:

apiVersion: flink.apache.org/v1beta1
kind: FlinkDeployment
metadata:
  name: simple-flink
spec:
  image: flink-1.17-python-iceberg:1.17
  flinkVersion: v1_16
  ingress:
    template: "{{name}}.{{namespace}}.flink.k8s.io"
    className: "nginx"
    annotations:
      nginx.ingress.kubernetes.io/proxy-body-size: 50m
  flinkConfiguration:
    taskmanager.numberOfTaskSlots: "1"
    state.savepoints.dir: file:///flink-data/savepoints
    state.checkpoints.dir: file:///flink-data/checkpoints
    high-availability.type: kubernetes
    high-availability.storageDir: file:///flink-data/ha
    rest.client-max-content-length: "1004857600"
  serviceAccount: flink
  jobManager:
    replicas: 1
    resource:
      memory: "2048m"
      cpu: 1
  taskManager:
    replicas: 1
    resource:
      memory: "2048m"
      cpu: 1
  podTemplate:
    spec:
      containers:
        - name: flink-main-container
          volumeMounts:
          - mountPath: /flink-data
            name: flink-volume
          env:
          - name: HADOOP_CONF_DIR
            value: "/opt/hadoop-2.8.5/etc/hadoop:/opt/hadoop-2.8.5/share/hadoop/common/lib/*:/opt/hadoop-2.8.5/share/hadoop/common/*:/opt/hadoop-2.8.5/share/hadoop/hdfs:/opt/hadoop-2.8.5/share/hadoop/hdfs/lib/*:/opt/hadoop-2.8.5/share/hadoop/hdfs/*:/opt/hadoop-2.8.5/share/hadoop/yarn/lib/*:/opt/hadoop-2.8.5/share/hadoop/yarn/*:/opt/hadoop-2.8.5/share/hadoop/mapreduce/lib/*:/opt/hadoop-2.8.5/share/hadoop/mapreduce/*:/opt/hadoop-2.8.5/contrib/capacity-scheduler/*.jar"
      volumes:
      - name: flink-volume
        hostPath:
          path: /tmp
          type: Directory

为实现自动扩缩容,我创建了以下HPA配置:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: simple-flink
  namespace: default
spec:
  minReplicas: 1
  maxReplicas: 3
  metrics:
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageValue: "10Mi"
  scaleTargetRef:
    apiVersion: flink.apache.org/v1beta1
    kind: FlinkDeployment
    name: simple-flink

查看HPA状态时,出现以下错误事件:

Events:
  Type     Reason                        Age                    From                       Message
  ----     ------                        ----                   ----                       -------
  Warning  FailedComputeMetricsReplicas  6m23s (x12 over 9m8s)  horizontal-pod-autoscaler  selector is required
  Warning  SelectorRequired              4m8s (x21 over 9m8s)   horizontal-pod-autoscaler  selector is required

执行kubectl describe hpa simple-flink后,状态信息如下:

status:
  conditions:
  - lastTransitionTime: "2023-12-19T13:42:00Z"
    message: "the HPA controller was able to get the target's current scale"
    reason: "SucceededGetScale"
    status: "True"
    type: "AbleToScale"
  - lastTransitionTime: "2023-12-19T13:42:00Z"
    message: "the HPA target's scale is missing a selector"
    reason: "InvalidSelector"
    status: "False"
    type: "ScalingActive"

我曾尝试更新Flink Operator CRD到最新版本,执行了以下命令:

git clone https://github.com/apache/flink-kubernetes-operator
cd flink-kubernetes-operator
kubectl replace -f helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml

更新后重新创建了FlinkDeployment和HPA,但错误依旧。求解决该问题的建议。


内容的提问来源于stack exchange,提问作者Juan Pablo Converso

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 19:14:54