Open alexbrand opened 5 years ago
The commands don’t work in Windows because:
There’s no implicit line wrap due to double quotes in cmd.exe, so echo fails to create a valid certificate file.
The backslash doesn’t work as a line wrap either in cmd.exe. Even if echo was modified to create the certificate file, using echo results in Windows line feeds which makes embedded certificates invalid and subsequent commands fail due to invalid x509 cert. It needs to be converted to use UNIX new lines before embedding and base64 encoding.
Would be very useful to have Windows instructions. Because most of our devs work on a windows os.
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.
This could be fixed together with #136.
Do you have a PS example? For both, installing kubectl and kubectl config?
@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
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.
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.