Skip to content

Secrets are decoded from Base64 #614

@matthew-walker-prolucid

Description

@matthew-walker-prolucid

Hello,

I used F# code similar to the following to retrieve a secret from the k8s API:

open k8s
open k8s.Models
open System.IO
open System.Threading

let retrieveSecret (client: IKubernetes) (nspace: string) (secret: string) : Async<string> =
    async {
        let! v1Secret = client.ReadNamespacedSecretAsync (secret, nspace, "false", CancellationToken.None) |> Async.AwaitTask
        return Yaml.SaveToString v1Secret
    }

[<EntryPoint>]
let main argv =
    let kClientConfig = KubernetesClientConfiguration.BuildDefaultConfig()
    use kClient = new Kubernetes(kClientConfig)
    
    async {
        let! secretText = retrieveSecret kClient "mynamespace" "mysecret"
        return printfn "%s" secretText
    } |> Async.RunSynchronously

    0

Which will print the secret mysecret from the namespace mynamespace. The issue is that the secret is printed with a data field, which is assumed to be base64-encoded, but is instead printed as plain text, making the secret printed ill-formed.

As a workaround, I have replaced "\ndata:" with "\nstringData:" in the output, but this is obviously less than ideal and the secret returned should be of the correct form.

Unfortunately, I do not currently have the time to offer to help fix this.

Versions:

k8s server: tested on 1.17.6
KubernetesClient for .NET: 5.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions