Kubernetes pod cannot see secret set with kubectl?

3/5/2018

So, i have a k8s cluster running on AWS, provisioned using kops. I have created a secret locally, using kubectl:

    kubectl create secret generic aws-es --from-file=./aws_key.txt --from-file=./aws_secret_key.txt

My service.yml has this env:

    - name: AWS_ACCESS_KEY_ID
        valueFrom:
          secretKeyRef:
            name: aws-es
            key: aws_key

And when i update the service in the cluster with:

    kubectl apply -f service.yml

I get the error running pod:

     Error: secrets "aws-es" not found
     Error syncing pod 

Obviously, my kops installation cannot see the locally created secret, is there a way for me to propagate that secret to kops' s3 storage?

-- dgmt
kops
kubectl
kubernetes

2 Answers

10/20/2019

Creating the secret in the same namespace as the deployment fixed this issue for me as well.

Error: secrets "xxx" not found

-- midacts
Source: StackOverflow

3/5/2018

Fixed it. The problem was i created secrets in default namespace, while my pods were running in kube-system namespace.

-- dgmt
Source: StackOverflow