vmware-archive / gangway

An application that can be used to easily enable authentication flows via OIDC for a kubernetes cluster.
Apache License 2.0
409 stars 112 forks source link

Add command line instructions for users running on Windows #102

Open alexbrand opened 5 years ago

alexbrand commented 5 years ago

The commands displayed by gangway assume that the user is running a UNIX-based system.

Add instructions for downloading/configuring kubectl that work on Windows.

koushik82 commented 5 years ago

The commands don’t work in Windows because:

meilel commented 5 years ago

Would be very useful to have Windows instructions. Because most of our devs work on a windows os.

jimangel commented 5 years ago

Additional issues:

Suggestion: We could have 2 info boxes (PowerShell and BASH or Windows and Mac / Linux). My preference would be to model around PowerShell vs. CMD.

I'll help work on this if it doesn't get a ton of traction.

jbrunner commented 5 years ago

This could be fixed together with #136.

Do you have a PS example? For both, installing kubectl and kubectl config?

mrwonkerz commented 5 years ago

@jbrunner

Defently not perfect but this should work...


Install-Script -Name install-kubectl -Scope CurrentUser -Force
New-Item -Path 'C:\Program Files\Kubectl' -ItemType Directory
install-kubectl.ps1 -DownloadLocation 'C:\Program Files\Kubectl'

$ClusterCA = "{{ .ClusterCA }}"
Set-Content -Path ca-{{ .ClusterName }}.pem -Value $ClusterCA
kubectl config set-cluster {{ .ClusterName }} --server={{ .APIServerURL }} --certificate-authority=ca-{{ .ClusterName }}.pem --embed-certs
kubectl config set-credentials {{ .KubeCfgUser }}  `
    --auth-provider=oidc  `
    --auth-provider-arg='idp-issuer-url={{ .IssuerURL }}'  `
    --auth-provider-arg='client-id={{ .ClientID }}'  `
    --auth-provider-arg='client-secret={{ .ClientSecret }}' `
    --auth-provider-arg='refresh-token={{ .RefreshToken }}' `
    --auth-provider-arg='id-token={{ .IDToken }}'
kubectl config set-context {{ .ClusterName }} --cluster={{ .ClusterName }} --user={{ .KubeCfgUser }}
kubectl config use-context {{ .ClusterName }}
Remove-Item ca-{{ .ClusterName }}.pem
jimangel commented 5 years ago

Semi-hacky but a manual alternative (if the user can't run scripts outside company):

## INSTALL KUBECTL IN POWERSHELL ##
# Create a folder ‘k’ in C:\ for kubectl.exe
New-Item -ItemType directory -Path "C:\k"

# Make the ‘k’ folder executable by adding it to your user’s $PATH
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\k", [EnvironmentVariableTarget]::User)

# Start a new PowerShell session to see your changes take place.

# Validate that C:\k is now in your path
$env:PATH

# Download the windows kubectl client from your browser
https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/windows/amd64/kubectl.exe

# Move kubectl.exe to C:\k folder that was created in [Step 2]

The above example looks like a clean way to setup kubectl, the biggest problem was the CA cert and setting it as a var would solve that potentially.