kubernetes generated names
Naming is hard
Naming is hard, especially for kubernetes resources that are some of the lowest possible deployable units, like pods, replication controllers and jobs.
Some of these resources cannot be changed once they are created. e.g. re-running a job with a different image version is not possible without changing it’s name.
But there’s a
generateName field on the yaml manifests that we can use instead:
Now when the job is started it will get a unique generated name like:
Then name being different allows
kubectl apply -f job.yaml as many times as you want with
different images / versions and new jobs will be created for each one.
Note; You will need to use
kubectl create and not
kubectl apply for generate name to work well.
This means that if we do something like:
We will get an error that says:
While the issue is being fixed, we can strip the name using sed: