使用最新标记向Kubernetes部署添加时间戳
我正在尝试实现Kubernetes资源部署。为此,我创建了使用最新标记向Kubernetes部署添加时间戳,kubernetes,yaml,Kubernetes,Yaml,我正在尝试实现Kubernetes资源部署。为此,我创建了deployment.yaml和service.yaml作为我的Kubernetes资源。并在mydeployment.yaml中引用带有latest标记的dockerhub注册表映像。当我这样做时,最新的图像不是用latest`标签拉的 因此,我在部署中添加了时间戳,如下所示: template: metadata: labels: app: test-kube-deployment date: date "+%H
deployment.yaml
和service.yaml
作为我的Kubernetes资源。并在mydeployment.yaml中引用带有latest
标记的dockerhub注册表映像。当我这样做时,最新的图像不是用
latest`标签拉的
因此,我在部署中添加了时间戳,如下所示:
template:
metadata:
labels:
app: test-kube-deployment
date: date "+%H:%M:%S %d/%m/%y"
spec:
imagePullSecrets:
- name: "regcred"
containers:
- name: test-kube-deployment-container
image: spacestudymilletech010/spacestudykubernetes:latest
imagePullPolicy: Always
ports:
- name: http
containerPort: 8085
protocol: TCP
当我在这里添加时间时,我得到如下错误:
The Deployment "test-kube-deployment" is invalid: spec.template.labels: Invalid value: "date \"+%H:%M:%S %d/%m/%y\"": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character
这里我需要做什么修改来定义我的时间戳以唯一标识Docker图像?不要将其添加为标签,而是作为注释
template:
metadata:
labels:
app: test-kube-deployment
annotations:
date: "+%H:%M:%S %d/%m/%y"
PD.-出现错误是因为标签不接受+、%和:字符 不要将其添加为标签,而是作为注释模板:元数据:标签:app:test kube部署注释:日期:“++%H:%M:%S%d/%M/%y”日期:日期“++%H:%M:%S%d/%M/%y”``最好还是将其作为图像的标记,例如
../spacestudykubernetes:20191025.2302
。如果此图像因任何原因无法正常工作,则很容易恢复到以前的图像。