Specific name to auto generated secret token of namespace in Kubernetes

12/7/2017

I came up with the use case where I need to give specific name of secret token when it gets generated during creation of namespace.

So when we create a namespace in K8S we will get one secret token like below.

NAMESPACE               NAME                                    TYPE                                  DATA      AGE
dev                     secrets/default-token-vvlzv             kubernetes.io/service-account-token   3         1d
devops                  secrets/default-token-0xpt0             kubernetes.io/service-account-token   3         9d

So What we want is "default-token-vvlzv" should be generated as user given name like "dev-token".

Is there any way to achieve this ?

-- Nikit Swaraj
kubernetes
kubernetes-helm

2 Answers

2/15/2018

echoing chrishuen's answer above, I do not believe there is a way to do this currently. However, you might be able to write your own Custom Resource Definition and Controller to help automate this.

-- Frank Reno
Source: StackOverflow

12/19/2017

To the best of my knowledge, there is no such option. However, if you're creating your namespaces via software and not manually through kubectl, you can always clone the secret token to a copy with a name of your liking upon namespace creation. Do you automatically create namespaces or is that for a manual use-case?

Cheers, Christian

-- chrishuen
Source: StackOverflow