kubernetes service account secrets is not listed

12/29/2020

I created a secret of type service-account using the below code. The secret got created but when I run the kubectl get secrets the service-account secret is not listed. Where am I going wrong

apiVersion: v1
kind: Secret
metadata:
  name: secret-sa-sample
  annotations:
    kubernetes.io/service-account.name: "sa-name"
type: kubernetes.io/service-account-token
data:
  # You can include additional key value pairs as you do with Opaque Secrets
  extra: YmFyCg==
kubectl create -f  sa-secret.yaml
secret/secret-sa-sample created```
-- zilcuanu
kubernetes
kubernetes-secrets

1 Answer

12/29/2020

it might have been created in default namespace. Specify namespace explicitly using -n $NS argument to kubectl

-- Sameer Naik
Source: StackOverflow