k8s-vagrant-dev/K8s-Deploy.ps1
2023-06-11 18:49:48 +02:00

48 lines
2.2 KiB
PowerShell

if ($null -eq (Get-VMSwitch -SwitchName "k8s-Switch" -ErrorAction Ignore)) {
New-VMSwitch -SwitchName k8s-Switch -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.99.1 -PrefixLength 24 -InterfaceIndex (Get-NetAdapter | Where-Object {$_.Name -match "k8s-Switch"}).ifIndex -AddressFamily IPv4
}
if($null -eq (Get-NetNat | Where-Object {$_.Name -match "K8s-NATNetwork"})) {
New-NetNAT -Name K8s-NATNetwork -InternalIPInterfaceAddressPrefix 192.168.99.0/24
}
# cmd /c ssh-keygen -t id_ed25519 -f '$PSScriptRoot\.ssh\id_ed25519' -P ''
# TODO must change file permissions!!! as key file is too open
Set-Location $PSScriptRoot
cmd /c "vagrant plugin install --plugin-clean-sources --plugin-source https://rubygems.org vagrant-reload"
cmd /c "vagrant plugin install --plugin-clean-sources --plugin-source https://rubygems.org vagrant-scp"
cmd /c "vagrant up"
# replace with custom ssh private_key file
Get-ChildItem -Path ".\.vagrant\machines" | Foreach-Object {
Rename-Item -Path "$($_.FullName)\hyperv\private_key" -NewName "private_key.bak"
Copy-Item ".\.ssh\id_ed25519" -Destination "$($_.FullName)\hyperv\private_key"
#TODO must change file permissions!!! as key file is too open
}
# import configuration in local kubectl
Copy-Item ".\.tmp\config" -Destination "$HOME\.kube\config" -Force
# install argo cd
cmd /c "kubectl create namespace argocd"
cmd /c "kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml"
$secret = ./kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}"
[Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($secret)) > .\.tmp\argocd-secret.txt
# install dapr
# Add the official Dapr Helm chart.
cmd /c "helm repo add dapr https://dapr.github.io/helm-charts/"
cmd /c "helm repo update"
# See which chart versions are available
# cmd /c "helm search repo dapr --devel --versions"
# Install in developer mode
cmd /c "helm upgrade --install dapr dapr/dapr --version=1.11 --namespace dapr-system --create-namespace --wait"
cmd /c "helm upgrade --install dapr-dashboard dapr/dapr-dashboard --namespace dapr-dashboard --create-namespace --wait"