Different credentials per machine in Kubernetes

3/14/2018

I have been trying to find online about this but it doesn't seem like I can find a solution built in Kubernetes or otherwise, what I need is to have different credentials/secrets on a per pod basis.

The idea is that I have a lot of different API keys and each different physical machines will have a different API key to make API calls with, right now I am using normal VMs and am using the hostname for it so machine-1 will tell me to use the key on index 1 on the array for example.

But I am looking to use kubernetes and I'm wondering if there's a way to pass a secret uniquely once per machine, or if there's even a service that can do that, I have looked at zookeeper but doesn't seem like it would solve this.

Thanks

-- ShinySides
kubernetes

1 Answer

3/15/2018

You could create a single secret (some long string) and use the hash of some combination of the secret with the hostname to generate a unique token for each machine. You can then index your keys on the tokens instead. The connections from your clients to the API must be encrypted and mutually authenticated.

More appropriately, you could use something like Hashicorp's Vault with vault-controller to supply a unique token to each Pod of a DaemonSet running on each node. This could then be used to authenticate with your API to retrieve the corresponding key. Doing it this way will allow you to roll authentication tokens more easily.

-- dippynark
Source: StackOverflow