narrow-monitor-83965
11/01/2023, 4:32 PMconst longhornSecret = new k8s.core.v1.Secret("longhorn-secret", {
metadata: {
name: "longhorn-auth",
namespace: "longhorn-system",
},
data: {
users: `|
${secretPassword}
`
}
}, {
dependsOn: [longhornIngress],
provider: k8sProvider,
})
The error is
error: Preview failed: resource longhorn-system/longhorn-auth was not successfully created by the Kubernetes API server : failed to convert new object (longhorn-system/longhorn-auth; /v1, Kind=Secret) to proper version: unable to convert unstructured object to /v1, Kind=Secret: error decoding from json: illegal base64 data at input byte 0
steep-toddler-94095
11/01/2023, 4:59 PMdata: {
users: secretPassword
}
narrow-monitor-83965
11/01/2023, 4:59 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?secretPassword
narrow-monitor-83965
11/01/2023, 5:03 PMhtpasswd -nb <username> <password> | base64
apiVersion: 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
}