Deployment in version “v1” cannot be handled as a Deployment

Spread the love

 Deployment in version “v1” cannot be handled as a Deployment

json: cannot unmarshal number into Go struct field EnvVar.spec.template.spec.containers.env.value of type string
Photo by Brett Jordan on Unsplash


In this post, I will explain to you how to resolve the error while applying Kubernetes deployments. The error message suggests that there is an issue with the format of the value field in one of the environment variables defined in your Kubernetes deployment manifest. It seems that the field is expecting a string value, but it is being provided with a number instead.

To resolve this issue, ensure that all environment variable values in your deployment manifest are specified as strings. Make sure to enclose numeric values within quotes to explicitly define them as strings.

Error:  😡
                    
Error from server (BadRequest): error when creating “sonarqube.yaml”: Deployment in version “v1” cannot be handled as a Deployment: json: cannot unmarshal number into Go struct field EnvVar.spec.template.spec.containers.env.value of type string
 

For example, if you have an environment variable defined like this:

env:
  – name: MY_VARIABLE
    value: 123


Modify it to: 

env:
  – name: MY_VARIABLE
    value: “123”

By enclosing the value in double quotes, you explicitly define it as a string. Review your deployment manifest and ensure that all environment variables have their values defined as strings. Once you’ve made the necessary changes, the error should be resolved..

Linuxguru

1 thought on “Deployment in version “v1” cannot be handled as a Deployment”

Leave a comment