Kubernetes: Delete secret from pod

1/28/2019

I have pod running my application. The pod also contains my secret. The secret mapped to /secret/mysecret.json. I connecting to my pod with ssh and try to remove the secret from this pod instance:

rm /secret/mysecret.json

I getting the Error:

rm: cannot remove 'mysecret.json': Read-only file system

According to this article, I tried to changed the readOnly settings to False. No success.

Also tried to unmount it, got errors:

$ umount /secret/mysecret.json
  umount: /app/secrets/app-specific: must be superuser to unmount

How I can delete secret from a pod?

-- No1Lives4Ever
google-kubernetes-engine
kubectl
kubernetes

2 Answers

1/28/2019

You can not delete secret from pod as it is mapped as volume. Even if you managed to delete, it will be recreated. So if you want to remove secret from pod, change pod spec and delete that secret conf from spec itself.

-- Rajesh Deshpande
Source: StackOverflow

1/28/2019

The way you should handle this the kubernetes way is:

kubernetes delete secret <<secret name goes here>>
-- Raunak Jhawar
Source: StackOverflow