在Octopus Deploy中如何从监听的触角切换到轮询的触角?

问题描述 投票:0回答:1

[设置云混合似乎是许多公司的发展方向。常见配置是Octopus Deploy在本地VM上运行。 Octopus Deploy部署到本地VM以及在Azure中运行的VM。 Octopus Deploy实例将迁移到Azure中运行的VM。这是我们将更多本地VM迁移到Azure的总体策略的一部分。

这里是关键,公司防火墙已配置为仅允许连接到Azure。本地VM可以毫无问题地连接到Azure。但是Azure VM无法连接到本地VM。所有本地VM都使用listening tentacles。是否可以切换到polling tentacles。可以自动化吗?

octopus-deploy
1个回答
0
投票

一旦创建触手实例,就无法更改通信模式(侦听或轮询)。您需要做的是创建一个新实例。这是一个新的Runbooks功能派上用场的用例。

请注意:这假定您已经将Octopus Deploy实例移至Azure。

您将有两个Runbook。第一个运行手册将:

  1. 在现有触手上使用运行脚本步骤来创建新的轮询触手实例。

第二本运行手册将:

  1. 在新的轮询触手上使用运行脚本步骤来禁用较早的监听触手的注册。
  2. 在测试到新触手实例的某些部署时,暂停手动干预。
  3. 在新的轮询触手上使用运行脚本步骤来删除较旧的侦听触手实例。

首先,让我们使用脚本控制台来创建轮询触角。一些注意事项:-当您使用Octopus Deploy注册新的触手时,将需要提供一个名称。我建议您使用一些容易记住的东西。如果您当前的监听触角已注册为[MachineName],请使用[MachineName] -Polling。-除了提供部署角色外,还添加“ PollingTentacle”作为角色,以便将来通过脚本控制台轻松运行。

$OldMachineName = $OctopusParameters["Octopus.Machine.Name"]
$Environment = $OctopusParameters["Octopus.Environment.Name"]
$Roles = $OctopusParameters["Octopus.Machine.Roles"]
$APIKey = #Your API Key
$Server = #Your Server
$NewMachineName = "$OldMachineName-Polling"

Set-Location "C:\Program Files\Octopus Deploy\Tentacle"

$baseArgs = @("register-with","--instance=Polling","--Name=$NewMachineName","--server=$Server","--apiKey=$octopusApiKey","--comms-style=TentacleActive","--server-comms-port=10943","--environment=$Environment")

$roleList = $roles -split ","
foreach ($role in $roleList) {
    $baseArgs += "--role=$role"
}

$baseArgs += "--console"

& .\Tentacle.exe create-instance --instance "Polling" --config "C:\Octopus\Tentacle.config" --console
& .\Tentacle.exe new-certificate --instance "Polling" --if-blank --console
& .\Tentacle.exe configure --instance "Polling" --reset-trust --console
& .\Tentacle.exe configure --instance "Polling" --home "C:\Octopus\Polling" --app "C:\Octopus\Applications\Polling" --noListen "True" --console
& .\Tentacle.exe $baseArgs 
& .\Tentacle.exe service --instance "Polling" --install --start --console

[下一步,使用API​​,禁用旧计算机。在这里,角色为“ PollingTentacles”,并且将机器注册设置为[MachineName] -Polling即可轻松实现。该脚本将禁用较早的目标。

###CONFIG###
$OctopusURL = #Octopus Server root URL
$APIKey = #Octopus API Key
$NewMachineName = $OctopusParameters["Octopus.Machine.Name"]

$machineName = $NewMachineName -replace "-Polling", ""

###PROCESS###
$header = @{ "X-Octopus-ApiKey" = $APIKey }

#Getting all machines
$allmachines = Invoke-RestMethod $OctopusURL/api/machines/all -Headers $header

#Filtering machine by name
$machine = $allmachines | ?{$_.name -eq $machineName}

#Setting the "IsDisabled" property
$machine.IsDisabled = $true #Set to $false to disable the machine

#Converting $machine into a JSON blob to PUT is back to the server
$body = $machine | ConvertTo-Json -Depth 4

#Pushing the modified machine to the userver
Invoke-RestMethod ($OctopusURL + $machine.Links.Self) -Method Put -Body $body -Headers $header

现在轮询触手正在运行,而较旧的触手已禁用,请运行一些测试部署。一切都应继续按原样进行。

最后,您将需要利用脚本控制台注销并删除旧触手。

cd "C:\Program Files\Octopus Deploy\Tentacle"

Tentacle.exe deregister-from --instance "Tentacle" --server "http://YOUR_OCTOPUS" --apiKey "API-YOUR_API_KEY" --multiple
Tentacle.exe delete-instance --instance "Tentacle"

有关命令行的更多信息,请参考our documentation

如果这使您超出许可限制,请联系[email protected],解释您要做什么,我们将为您提供临时许可。

© www.soinside.com 2019 - 2024. All rights reserved.