Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions windows/setup_k8s.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ $kubectlVersion = "v1.32.0"

Write-Host "Starting kubernetes setup..."

if (-not (Test-Path -Path "anon.conf" -PathType Leaf)) {
Write-Host "Please download anon.conf from the AMD OSSCI confluence site to get started"
# Exit early if KUBECONFIG is not set to a valid path
$kubeconfigPath = [System.Environment]::GetEnvironmentVariable('KUBECONFIG')
if ( -not $kubeconfigPath) {
Write-Host "KUBECONFIG is not set or empty. Exiting"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it KUBECONFIG is not set, it'll be default to ~/.kube/config

The assumption here is KUBECONFIG has to be se. Please verify the correctness of this assumption

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the documentation: "If the KUBECONFIG env variable doesn't exist, kubectl uses the default kubeconfig file, $HOME/.kube/config"

Because we are not giving instructions to our customers about the default kubeconfig file and are going with the KUBECONFIG environment variable route, I think we should have this check.

I am also fine with providing more instructions around the kubeconfig settings and removing this check completely.

Write-Host "Please download the authentication file from the AMD OSSCI confluence site and set KUBECONFIG env variable to the file path"
Write-Host "You will need this auth file to access the k8s cluster"
exit 1
}
elseif ( -not (Test-Path -Path $kubeconfigPath)) {
Write-Host "File $kubeconfigPath does not exit. Exiting"
Write-Host "Plese make sure the KUBECONFIG env variable is correctly set to the authentication file path"
exit 1
}
else {
Write-Host "KUBECONFIG is set to: $kubeconfigPath"
}

Write-Host "Downloading kubectl..."
curl.exe -LO "https://dl.k8s.io/release/$kubectlVersion/bin/windows/amd64/kubectl.exe"
Expand All @@ -32,10 +43,6 @@ if ($calculatedHash -eq $expectedHash) {

# Requires elevated powershell
Write-Host "Adding current directory to PATH..."
[System.Environment]::SetEnvironmentVariable(
"Path",
[System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) + ";$PWD",
[System.EnvironmentVariableTarget]::Machine
)
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) + ";$PWD"

Write-Host "Setup completed successfully!"