我有ConfigMap,ImageStream,BuildConfig和DeploymentConfig API,它们可以成功部署我的应用程序并根据要求启动Pod的数量。但是我现在想使用CronJob。
是否完全替换DeploymentConfig?因为这个想法是根据传递给CronJob API的 Jade 米表达式启动一个新的pod。
最佳答案
是的,为什么不🤷,您可以重复使用DeploymentConfig
的template📓部分。例如:
kind: "DeploymentConfig"
apiVersion: "v1"
metadata:
name: "frontend"
spec:
template:
metadata:
labels:
name: "frontend"
spec:
containers:
- name: "helloworld"
image: "openshift/origin-ruby-sample"
ports:
- containerPort: 8080
protocol: "TCP"
replicas: 5
triggers:
- type: "ConfigChange"
- type: "ImageChange"
imageChangeParams:
automatic: true
containerNames:
- "helloworld"
from:
kind: "ImageStreamTag"
name: "origin-ruby-sample:latest"
strategy:
type: "Rolling"
paused: false
revisionHistoryLimit: 2
minReadySeconds: 0
会变成这样的📃🏃:apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: frontend
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
metadata:
labels:
name: "frontend"
spec:
containers:
- name: "helloworld"
image: "openshift/origin-ruby-sample"
ports:
- containerPort: 8080
protocol: "TCP"
restartPolicy: OnFailure
✌️关于kubernetes - OCP CronJob需要哪些API,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62962384/