我需要在 k8s 环境中将应用程序部署为 Job。
我的工作.yml
apiVersion: batch/v1
kind: Job
metadata:
name: hello-stackoverlow
labels:
app: hello-stackoverlow
group: hello-stackoverflow
version: 1.0.0
spec:
parallelism: 1
completions: 1
template:
spec:
containers:
- name: hello-stackoverflow
image: docker-registry:1234/hello-stackoverflow:1.0.0
volumeMounts:
- name: config
mountPath: /job/config
restartPolicy: OnFailure
volumes:
- name: config
configMap:
name: hello-stackoverflow
items:
- key: application.properties
path: application.properties
我的 configmap.yml
apiVersion: v1
kind: ConfigMap
metadata:
name: hello-stackoverflow
data:
application.properties: |
# spring application properties file
logging.file=test.log
logging.level.com.db=DEBUG
尝试部署作业时出现以下错误:
*Failure executing: POST at: {URL} Message: Job.batch "hello-stackoverflow" is invalid:
[spec.template.spec.containers[1].name: Required value, spec.template.spec.containers[1].image: Required value].
Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.spec.containers[1].nam
e, message=Required value, reason=FieldValueRequired, additionalProperties={}), StatusCause(field=spec.template.spec.containers[1].image,
message=Required value, reason=FieldValueRequired, additionalProperties={})]*
我的问题是:要将 configmap 附加到 k8s 中的 Job,您还需要一个 deployment.yml,或者是否可以在您的 job.yml 中完成?