2

First I create a namespace "foo" using this .yaml file :

apiVersion: v1
kind: Namespace
metadata:
  name: foo                                                                                                                                                                                                                                                                                                                                                                                                      
tomas@ubunt:~$ kubectl apply -f namespace.yaml 
namespace/foo created

I then create a secret that is connected to this "foo" namespace using this .yaml file :

apiVersion: v1
kind: Secret
metadata:
  name: bar
  namespace: foo
type: Opaque
data:
    mongo-root-username: bW9uZ29kYg==
    mongo-root-password: Y29tbWFuZCA= 
tomas@ubunt:~/minikub/false$ kubectl apply -f secret.yaml 
secret/bar created

If I try to get more info about this secret it says there's no secret "bar":

tomas@ubunt:~$ kubectl get secret bar -o yaml
Error from server (NotFound): secrets "bar" not found

How come do I get this result when I have just created this secret and I got an output saying it was created.

Tomas.R
  • 195

1 Answers1

1

To get more info about the secret you also have to specify the namespace you have created your secret in and you do it like so :

kubectl -n foo get secret bar -o yaml

Tomas.R
  • 195