Search code examples
kuberneteskubernetes-secrets

Kubernetes storing key-value pair in Secret.yml


I am wondering if it is possible to store a key-value pair in Secret.yml. I want to be able to store an encryption key as a value and an id as its key which I can use to retrieve the encryption key stored in Secret.yml.

Is such functionality available with Kubernetes?

EDIT I should have said in my original message, I want to be able to store multiple pairs and add pairs during the lifespan of my application and use different encryption key on the fly without/minimal update to my application.


Solution

  • Thank you guys for your answers. I've found using the below format in Secret.yaml works well:

    encryptionKey |
    KeyName: 123456abcdef
    SecondKeyName: abcdef123456
    

    I would then get the key value pairs as a Map in my Java application and treat it as such so I can, for example, search for key KeyName and get the value I need.