|
|
|
@ -1,4 +1,8 @@
|
|
|
|
|
#Requires -Modules powershell-yaml
|
|
|
|
|
param (
|
|
|
|
|
[string]$Chain = $env:CHAIN,
|
|
|
|
|
[string]$Stacks = $env:STACKS
|
|
|
|
|
)
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
|
|
|
|
|
function Start-IptablesProcess {
|
|
|
|
@ -92,16 +96,15 @@ function Get-DockerIngressAddress {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# setup SWARM-NAT chain
|
|
|
|
|
$chain = 'SWARM-NAT'
|
|
|
|
|
Write-Output ('Create chain {0}' -f $chain)
|
|
|
|
|
Add-IptablesChain -Chain $chain
|
|
|
|
|
Add-IptablesRule -Chain 'PREROUTING' -Rule '-m','addrtype','--dst-type','LOCAL','-j',$chain
|
|
|
|
|
Write-Output ('Create chain {0}' -f $Chain)
|
|
|
|
|
Add-IptablesChain -Chain $Chain
|
|
|
|
|
Add-IptablesRule -Chain 'PREROUTING' -Rule '-m','addrtype','--dst-type','LOCAL','-j',$Chain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ingress_address = Get-DockerIngressAddress
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($yaml in (Get-ChildItem -Filter '*.yml')) {
|
|
|
|
|
foreach($yaml in (Get-ChildItem -Path $Stacks -Include '*.yml','*.yaml' -Recurse)) {
|
|
|
|
|
Write-Output ('Processing {0}' -f $yaml)
|
|
|
|
|
$definition = Get-Content -Path $yaml -Raw | ConvertFrom-Yaml
|
|
|
|
|
|
|
|
|
@ -156,7 +159,7 @@ foreach($yaml in (Get-ChildItem -Filter '*.yml')) {
|
|
|
|
|
'-j','DNAT'
|
|
|
|
|
'--to-destination','"{0}:{1}"' -f $ingress_address,$nat.port
|
|
|
|
|
)
|
|
|
|
|
Add-IptablesRule -Chain $chain -Rule $rule
|
|
|
|
|
Add-IptablesRule -Chain $Chain -Rule $rule
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|