Search code examples
kubernetesfabric8java-client

How to get kubernetes secret data from java


By following link https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/ it is described how to add secret (encripted) data.

How to get that key-value s with from java client?


Solution

  • You can use the official Java client for Kubernetes’ REST API and read the secret as defined in this doc. You will get a result of return type V1Secret.

    V1Secret result = apiInstance.readNamespacedSecret(name, namespace, pretty, exact, export);

    This object result has a property data of type Map<String, byte> to get the key value pairs from.