Skip to content

Commit

Permalink
feat: add Powershell script for egress determination
Browse files Browse the repository at this point in the history
  • Loading branch information
lechnerc77 authored and abbi-gaurav committed Aug 2, 2023
1 parent 6482bc9 commit 66b3db2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
12 changes: 9 additions & 3 deletions get-egress-ips/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ The script intelligently runs the curl pod in each of the different availability

- On MacOS or Linux, run the following command

```shell
./get-egress-ips.sh
```
```shell
./get-egress-ips.sh
```

- On Windows (or MacOS or Linux if you have PowerShell installed), run the following command:

```pwsh
./get-egress-ips.ps1
```
38 changes: 38 additions & 0 deletions get-egress-ips/get-egress-ips.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/pwsh
$ErrorActionPreference = 'silentlycontinue'

$ZONES = $(kubectl get nodes -o jsonpath='{.items[*].metadata.labels.topology\.kubernetes\.io/zone}').Split(" ")
$ZONES = $ZONES | Select-Object -Unique

Write-Output "Detected zones:"
Write-Output "---------------"
foreach ($zone in $ZONES) {
Write-Output $zone
}

foreach ($zone in $ZONES) {
$overrides = @{
"apiVersion" = "v1"
"metadata" = @{
"labels" = @{
"sidecar.istio.io/inject" = "false"
}
"spec" = @{
"nodeSelector" = @{
"topology.kubernetes.io/zone" = $zone
}
}
}
} | ConvertTo-Json -EscapeHandling EscapeHtml -Depth 5

kubectl run -i --tty busybox --image=curlimages/curl --restart=Never --overrides=$overrides --rm --command -- curl 'http://ifconfig.me/ip' | Out-File -FilePath $env:TEMP/cluster_ips -Append
}

(Get-Content $env:TEMP/cluster_ips) -replace 'pod "busybox" deleted', '' | Set-Content $env:TEMP/cluster_ips

Write-Host
Write-Output "Detected IPs:"
Write-Output "-------------"
Get-Content $env:TEMP/cluster_ips

Remove-Item $env:TEMP/cluster_ips

0 comments on commit 66b3db2

Please sign in to comment.