DEV Community

Cover image for How to resolve `kubectrl apply`deployment conflict error
Jeff
Jeff

Posted on

4 2

How to resolve `kubectrl apply`deployment conflict error

Symton

When you try to apply a deployment yaml file to kubernetes cluster, you get the error:

kubectl apply -f tmp.yaml

The Deployment "xxx" is invalid:
* spec.template.spec.containers[0].env[53].valueFrom: Invalid value: "": may not be specified when `value` is not empty
Enter fullscreen mode Exit fullscreen mode

Analysis

The kubernetes api met some issues when diff your tmp.yaml with the current running deployment.

For example, your current running deployment file has a hardcoded environment, and your new tmp.yaml has an environment whose value is reading from other sources:

# current running deployment
- name: EXPRESS_LOG_LEVEL
  value: debug

# You are trying to update to
- name: EXPRESS_LOG_LEVEL
  valueFrom:
    configMapKeyRef:
      name: xxx-configmap
      key: EXPRESS_LOG_LEVEL
Enter fullscreen mode Exit fullscreen mode

How do I manually diff?

You can export the current deployment yaml by:

kubectl get deploy/your-current-deploy -o yaml | pbcopy
Enter fullscreen mode Exit fullscreen mode

Then you can diff them via https://www.diffchecker.com/diff .

Solution

Delete the conflicted environments and then apply again:

KUBE_EDITOR="vim" kubectl edit deploy/your-current-deploy

kubectl apply -f tmp.yaml

# Now you get the success message!
deployment.apps/xxx-app configured
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free