I am trying to implement Kubernetes resource deployment. For this I created deployment.yaml
and service.yaml
as my Kubernetes reources. And refering the dockerhub registry image with latest
tag in my deployment.yaml. When I am doing like this, latest image is not pulling with
latest` tag.
So I added the time stamp in deployment like following:
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
When I added time here , I am getting the error like the following,
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
Here what modification that I need to do to define my time stamp for uniquely identify my Docker image?
Don't add it as a label, but rather as an annotation.
template:
metadata:
labels:
app: test-kube-deployment
annotations:
date: "+%H:%M:%S %d/%m/%y"
PD.- You are getting the error because labels don't accept the +, % and : characters.