Hi all, I am trying to create a secret with yaml file. I guess, I have the conte . . .

Vasu BK:
Hi all,
I am trying to create a secret with yaml file. I guess, I have the content right, but still failing. Details are below. Can u help me understand whats wrong with my input? Thanks in advance.


root@controlplane:~# kubectl create -f my-secrete.yaml
Error from server (BadRequest): error when creating “my-secrete.yaml”: Secret in version “v1” cannot be handled as a Secret: v1.Secret.Data: decode base64: illegal base64 data at input byte 4, error found in #10 byte of …|t":“sql01”,"DB_Passw|…, bigger context …|{“apiVersion”:“v1”,“data”:{“DB_Host”:“sql01”,“DB_Password”:“password123”,“DB_User”:“root”},"ki|…
root@controlplane:~# vi my-secrete.yaml
root@controlplane:~# cat my-secrete.yaml
apiVersion: v1
kind: Secret
metadata:
name: db-secret
data:
DB_Host: sql01
DB_User: root
DB_Password: password123
root@controlplane:~#

Bharath A G:
You had to pass the secret value as base64

Bharath A G:
echo -n “mysql”|base64

Vasu BK:
Thank you Bharth for response. In theory session, examples mentioned with plain text as input for both data: option and external file option.
–from-literal option also we are using plain text format. So, would you please elaborate on that

Tej_Singh_Rana:
Hello, @Vasu BK
When you create secret from command line, we don’t need to encode in base64. kubectl command line tool take care of it. From declarative way, we have to encode first.

Vasu BK:
Hi Tej,
Thank you for clarification