FreeKB - OpenShift List Secrets using the oc get secrets command
OpenShift - List Secrets using the oc get secrets command

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

Before you can use the oc get secrets command, you must first use the oc login command to login, and also use the oc project command to select the project that contains the secrets.

oc get secrets

NAME           TYPE        DATA      AGE
mysecret1      Opaque      1         133d
mysecret2      Opaque      1         133d
mysecret3      Opaque      1         127d

 

The oc get secret command followed by the name of a secret can be used to display an individual secret.

oc get secret mysecret1

NAME           TYPE        DATA      AGE
mysecret1      Opaque      1         133d

 

The -o yaml option can be used to display the contents of the secret. In this example, the secret contains a key named "myKey" and the key contains an encrypted value of "anRwL7VzZ4JpZDxna1F2dpFt9HNw7HZ0cK5wYXlzd29aZD1TTnMjZG75Rwa=".

oc get secret mysecret1 -o yaml

apiVersion: v1
data:
  myKey: anRwL7VzZ4JpZDxna1F2dpFt9HNw7HZ0cK5wYXlzd29aZD1TTnMjZG75Rwa=
kind: Secret
metadata:
  creationTimestamp: "2020-02-03T17:02:04Z"
  name: mysecret1 
  namespace: myProject001
  resourceVersion: "74792019"
  selfLink: /api/v1/namespaces/myProject001/secrets/mysecret1
  uid: e6e760ae-46a6-11aa-9928-005056a39855
type: Opaque

 

The encrypted value can be decrypted using this command, which will return the cleartext secret.

echo "anRwL7VzZ4JpZDxna1F2dpFt9HNw7HZ0cK5wYXlzd29aZD1TTnMjZG75Rwa=" | base64 -d

 

The -A o --all-namespaces flag can be used to return every secret in every namespace.

oc get secrets --all-namespaces

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 87a51 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |