Deleting secret is not reflected kamussecret object
ragsonline opened this issue · 6 comments
Describe the bug
After deleting the secret created through CRD Object KamusSecret- Unable to re-create the secret with the same name as Kamus fails with error kamussecrets.soluto.com "secret" already exists
Versions used
Kamus (API images): soluto.com/v1alpha2
Kamus CLI: 0.3.0
Chart version: kamus-0.4.6
KMS provider: AWS KMS
Kubernetes flavour and version: (e.g. OpenShift Origin 3.9)
Docker-for-Desktop
To Reproduce
Steps to reproduce the behavior:
- Create secret using KamusSecret Kind
- Delete secret
- Re-creating the same secret fails as "kumasecret" already exists
Expected behavior
Should be this way that deleting kuberentes secret should also delete kumas secret.
It's kinda expected - KamusSecret is managing the Secret, not the other way around. So, if you delete the KamusSecret the secret will be deleted - but if delete the secret the state will be invalid: Kamus think the secret exists (because KamusSecret exists).
Can you share more about the error you had? WDYM Re-creating the same secret
? How?
Thanks for your prompt response @omerlh
What I meant about that error is because the KumaSecret object is not deleted or exists.
if I do, kubectl apply or create -f kumasecret.yaml that I used to create in the first place says already exists.
which now means. we need to delete and recreate KumaSecret object if we need to reuse the manifest file
Not following... So - you deleted the secret. Does the KamusSecret exist after deletion? Did you try to create the secret manually? Or, did you try to apply again the manifest and it failed because KamusSecret object exist, but the secret not?
If so, we can open another PR - asking that Kamus will watch Secrets managed by Kamus, and if such a secret is deleted it will recreate it. Does that makes sense?
Below are the steps i followed.
@omerlh
- KamusSecret manifest to create the secret
cat kamu-secret.yaml
apiVersion: "soluto.com/v1alpha2"
kind: KamusSecret
metadata:
name: this-kamus-secret-v2
namespace: test
stringData:
key:
serviceAccount: kamus-example-sa
-
kubectl create -f kamu-secret.yaml
kamussecret.soluto.com/this-kamus-secret-v2 created -
List KamusSecret and Kube Secret
kubectl get secret this-kamus-secret-v2
NAME TYPE DATA AGE
this-kamus-secret-v2 Opaque 1 26s
kubectl get kamussecret this-kamus-secret-v2
NAME AGE
this-kamus-secret-v2 35s
- Delete Kubernetes Secret Object
kubectl delete secret this-kamus-secret-v2
secret "this-kamus-secret-v2" deleted
- Still KamusSecret exists ---- [ now understood this is expected ]
kubectl get kamussecret
NAME AGE
this-kamus-secret-v2 2m49s
6. Trying to run the same manifest file to create the secret[ failed due to above step ]
kubectl create -f kamu-secret.yaml
Error from server (AlreadyExists): error when creating "kamu-secret.yaml": kamussecrets.soluto.com "this-kamus-secret-v2" already exists