'Pod identifier number
I'm trying to generate a Unique Key in the application, using date/time and a number sequence managed by the application. It works fine as we don't have multiapplication.
The application is running in a Kubernetes pod with auto scaling configured.
Is there any way to generate or get a unique and numeric identifier per pod and put them in the container environment variables? there is no need for the intentifier to be fixed to use the statefulSets
UPDATE
the problem we are having with the uid is the size of the collections, tha's why we're are looking for a solution that's about the size of a bigInt, and if there is any other numberic unique id similar as an alternative of use for the UID.
Solution 1:[1]
...get a unique and numeric identifier per pod and put them in the container environment variables?
apiVersion: v1
kind: Pod
metadata:
name: busybox
labels:
run: busybox
spec:
restartPolicy: Never
containers:
- name: busybox
image: busybox
command: ["ash","-c","echo ${MY_UID} && sleep 3600"]
env:
- name: MY_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
Run kubectl logs <pod> will print you the unique ID assigned to the environment variable in your pod.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gohm'c |
