Is there a way to generate a unique identifier value only once (if not set) and cannot be edited by user

4/2/2019

I want to generate a unique identifier of a specific length and use this value across multiple pods internally. Since the length must be specific, and I'd prefer this to be handled internally rather than be adjustable by a user, I'd prefer to create the unique identifier on install/upgrade (only once if has not been set already) and not be changeable.

I want to use the identifiers internally as part of a naming schema for objects created within a specific deployment. I want to share these objects across other deployments, and need the identifier to determine if a given object belongs to a given deployment.

I was looking into setting a value in Secrets using randAlphaNum. Some problems I face with using Secrets are:

  1. Related to this issue: https://github.com/helm/helm/issues/3053 It looks like the Secret value will be overwritten on upgrade. There is an open PR for a possible fix: https://github.com/helm/helm/pull/5290 But I don't have the ability to upgrade helm/kubernetes atm

  2. Secret value is b64 encoded. I want to pass the value as an environment variable to various pods decoded. It doesn't really matter if the user knows the unique identifier. So, maybe I don't need a Secret? But, again, I don't want the user to be able to edit the value and the value should never change for a given deployment.

Any help or suggestions are appreciated! Thanks

-- philip yoo
kubernetes-helm

1 Answer

4/3/2019

You may then try to use ConfigMap instead. Seems it doesn't change on helm upgrade. Then you can use this guide to pass the value from ConfigMap to the pods.

-- Anna Slastnikova
Source: StackOverflow