mintel / dex-k8s-authenticator

A Kubernetes Dex Client Authenticator
MIT License
374 stars 146 forks source link

Windows instructions for setting certificate are not working #147

Open martinlosse opened 3 years ago

martinlosse commented 3 years ago

The windows instructions for Copy Kubernetes CA Certificate From PEM do not work in Powershell. In our deployment of dex (v1.2.0) the following command is proposed:

mkdir -p ${HOME}/.kube/certs/k8s.dev.example.com/ && cat << EOF > ${HOME}/.kube/certs/k8s.dev.example.com/k8s-ca.crt
-----BEGIN CERTIFICATE-----
<certificate her>
-----END CERTIFICATE-----

EOF

I think the problem is with a lack of support for <<

A Powershell friendlier version might look like this:

mkdir -p ${HOME}/.kube/certs/k8s.dev.example.com/ && `
"-----BEGIN CERTIFICATE-----
<certificate here>
-----END CERTIFICATE-----" > ${HOME}/.kube/certs/k8s.dev.example.com/k8s-ca.crt
nabadger commented 3 years ago

@summon128 there's a related (but old) PR at #86

I don't have a Windows box readily available so always found testing a bit of a pain :)

Couple of question really.

1) Does the introduction of WSL help here? i.e. is specific support for powershell still required these days? 2) Do you also require the use of %USERPROFILE% in the related PR, or is $HOME sufficient?

martinlosse commented 3 years ago

WSL can help, but obviously only if you have it installed, which it is not by default. And even then there's additional setup involved if you want to share the kubectl configuration between Windows and the Linux subsystem (namely linking config directories between the user homes which will be different for Windows and WSL).

Regarding %USERPROFILE% vs $HOME my observation is that the first one returns the user's home directory in the old command prompt but not in Powershell, while the latter does not yield a result in CMD but returns the user's home directory in Powershell.

marians commented 2 years ago

At Giant Swarm (on the customer side) we have actual users who would like to use the generated Windows commands either in cmd.exe or in PowerShell. If we can help to advance in the direction of https://github.com/mintel/dex-k8s-authenticator/pull/86 please let me know.