ps/Modules/Alkami.DevOps.Minikube/Public/Install-MinikubeDependencies.ps1

65 lines
2.1 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Install-MinikubeDependencies {
<#
.SYNOPSIS
Installs the dependencies required to run Alkami services in Minikube
.DESCRIPTION
Installs the dependencies required to run Alkami services in Minikube
.EXAMPLE
Install-MinikubeDependencies
#>
[CmdletBinding()]
param(
)
$ErrorActionPreference = "Stop"
$logLead = (Get-LogLeadName)
$chocoVersion = choco -v
Write-Host "$loglead : Installing Minikube dependencies"
if ($chocoVersion) {
Write-Host "$loglead : Using choco version: $chocoVersion"
}
else {
Write-Host "$loglead : Chocolatey not installed. Install Chocolatey before trying again."
}
Write-Host "$loglead : Installing Minikube..."
choco install minikube --version 1.25.1 -y
Write-Host "$loglead : Installing the kubectl..."
choco install kubernetes-cli --version 1.22.2 -y
Write-Host "$loglead : Installing helm..."
choco install kubernetes-helm --version 3.7.2 -y
Write-Host "$loglead : Installing skaffold..."
choco install skaffold --version 1.39.0 -y
Write-Host "$loglead : Installing yaml tools for powershell..."
choco install powershell-yaml --version 0.4.2 -y
$kerberosInstalled = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -Match 'MIT Kerberos for Windows' })
If (-Not $kerberosInstalled) {
Write-Host "$loglead : Installing mitkerberos..."
choco install mitkerberos --version 4.1 -y
}
$url = "alk-devdynamic.localhost"
Write-Host "$loglead : Checking if $url needs to be added to hosts..."
$hostsContent = Get-HostsFileContent
$hostsString = "127.0.0.1{0}{1}"
$hostsRegex = "^127\.0\.0\.1\s+$url"
if (($hostsContent | Where-Object {$_ -match $hostsRegex }).Count -gt 0) {
Write-Host "$loglead : Loopback Hosts File Entry for $url already exists"
} else {
Write-Host "$loglead : Adding alk-devdynamic.localhost to hosts..."
$newHostsEntry = ($hostsString -f "`t`t", $url)
Add-HostsFileContent -contentToAdd $newHostsEntry -Force
}
}