sparse-intern-71089
11/01/2023, 4:32 PMsteep-toddler-94095
11/01/2023, 4:59 PMdata: {
users: secretPassword
}
narrow-monitor-83965
11/01/2023, 4:59 PMnarrow-monitor-83965
11/01/2023, 5:00 PMsteep-toddler-94095
11/01/2023, 5:01 PM|
is yaml syntax for a multiline string, so you'd never use it when creating a json object (and base64 strings are always single lines anyways)
> How would I add more users?
this requires knowing a bit more about what you're trying to do. how are you intending the program to consume this secrets info?steep-toddler-94095
11/01/2023, 5:02 PMsecretPassword
narrow-monitor-83965
11/01/2023, 5:03 PMhtpasswd -nb <username> <password> | base64
narrow-monitor-83965
11/01/2023, 5:05 PMapiVersion: v1
kind: Secret
metadata:
name: authsecret
namespace: default
data:
users: |2
dGVzdDokYXByMSRINnVza2trVyRJZ1hMUDZld1RyU3VCa1RycUU4d2ovCnRlc3QyOiRhcHIxJGQ5
aHI5SEJCJDRIeHdnVWlyM0hQNEVzZ2dQL1FObzAK
steep-toddler-94095
11/01/2023, 5:14 PM2
in |2
means, but here are a couple options that you could do. keep in mind the data
field must take a single base64 encoded string, but there's also the option of stringData
which can take a regular string (the base64 encoding will. be done for you)
const secretpasswords = [
'user1:redactedpassword',
'user2:redactedpassword',
...
]
...
stringData: {
users: secretpasswords.join("\n")
}
or
const encodedSecretpasswords = btoa([
'user1:redactedpassword',
'user2:redactedpassword',
...
].join("\n"))
...
data: {
users: encodedSecretpasswords
}