Answer a question

I want to run two commands in my cronjob.yaml one after each other. The first command runs a python-scipt and the second changes an environment variable in another pod. The commands added separately work.

This is what I'm trying right now (found the syntax in How to set multiple commands in one yaml file with Kubernetes? ) but it gives me an error.

command:
- "/bin/bash"
- "-c"
args: ["python3 recalc.py && kubectl set env deployment recommender --env="LAST_MANUAL_RESTART=$(date)" --namespace=default"]

The error I get in cloudbuild:

error converting YAML to JSON: yaml: line 30: did not find expected ',' or ']'

(for the long line)

Answers

You have nested double quotes, try something more like this:

command:
- /bin/bash
- -c
- python3 recalc.py && kubectl set env deployment recommender --env="LAST_MANUAL_RESTART=$(date)" --namespace=default

i.e. without the outer double quotes.

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐