Search code examples
kubectlkopskubernetes

Kubernetes pod cannot see secret set with kubectl?


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?


Solution

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