5

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?

emanuel07
  • 738
  • 12
  • 27

1 Answers1

6

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.

Javatar81
  • 579
  • 3
  • 12
  • Thank you dear @Javatar81 ,and can I write key-value s from java? – emanuel07 May 31 '18 at 06:43
  • You could use Patch as described here https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/CoreV1Api.md#patchNamespacedSecret – Javatar81 May 31 '18 at 06:51
  • Nice! And a last question,where I must put my kube host:port,for connectiing? by calling ApiClient.setBasePath? – emanuel07 May 31 '18 at 07:14
  • 1
    In case anyone was wondering like I was, the class being used is CoreV1Api. readNamespacedSecret – Bruce T. Feb 26 '20 at 22:07