Retrieve secret value from openshift Retrieve secret value from openshift kubernetes kubernetes

Retrieve secret value from openshift


You can get key and value using "oc get secret/SECRETNAME -o yaml" simply, but you should decode the value by base64.After you retrieve the key using "oc get -o yaml", the value can decode simply as follows.

oc get secret ashish -n my-project \   -o go-template --template="{{.data.KEY|base64decode}}"VALUE

For example,

oc get secret ashish -n my-project \   -o go-template --template="{{.data.ashish|base64decode}}"...value...


You can use oc get secrets/ashish -o yaml or -o json where you'll see the base64-encoded value. You can then copy the value and decode it with something like echo <ENCODED_VALUE> | base64 -d

You can get the decode secret value, single oc command.

oc get secret ashish -n my-project --template={{.data.ashish}} | base64 -d