unknown field "labels" in io.k8s.autoscaling.v1.VerticalPodAutoscaler.spec

2/10/2021

I am getting the following error in aws EKS version 16 .

Failed to install app test. Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(VerticalPodAutoscaler.spec): unknown field "labels" in io.k8s.autoscaling.v1.VerticalPodAutoscaler.spec

This is my yaml, And also I tried with apiVersion: autoscaling.k8s.io/v1beta2 but same error

---
apiVersion: "autoscaling.k8s.io/v1"
kind: VerticalPodAutoscaler
metadata:
  name: web
spec:
  labels:
    app: web
  targetRef:
    apiVersion: "apps/v1"
    kind:       StatefulSet
    name:       web
  updatePolicy:
    updateMode: "Auto"
...
-- user3756483
amazon-eks
kubernetes
kubernetes-helm
rancher

2 Answers

2/11/2021

Error below literally sais you: there is no labels objects in the autoscaling.k8s.io/v1 API. Each time you see such errors - you should refer to API spec, either to source code, either to kubectl explain command to check what exact objects and fields you are able to use in each API version

In addition to source code you can check official documentation, e.g Vertical Pod autoscaling Reference to be sure you are using correct values.

Failed to install app test. Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(VerticalPodAutoscaler.spec): unknown field "labels" in io.k8s.autoscaling.v1.VerticalPodAutoscaler.spec

enter image description here

Also thanks @Kiran for provided code reference.

-- Vit
Source: StackOverflow

2/10/2021

Check this repo .

https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L61

Spec has only three field:

TargetRef, UpdatePolicy, ResourcePolicy

This is true for all three versions available autoscaling.k8s.io/v1 , autoscaling.k8s.io/v1beta1, autoscaling.k8s.io/v1beta2

-- Kiran
Source: StackOverflow