• <legend id='bbW5a'><style id='bbW5a'><dir id='bbW5a'><q id='bbW5a'></q></dir></style></legend>
      <bdo id='bbW5a'></bdo><ul id='bbW5a'></ul>

      <tfoot id='bbW5a'></tfoot>
    1. <small id='bbW5a'></small><noframes id='bbW5a'>

    2. <i id='bbW5a'><tr id='bbW5a'><dt id='bbW5a'><q id='bbW5a'><span id='bbW5a'><b id='bbW5a'><form id='bbW5a'><ins id='bbW5a'></ins><ul id='bbW5a'></ul><sub id='bbW5a'></sub></form><legend id='bbW5a'></legend><bdo id='bbW5a'><pre id='bbW5a'><center id='bbW5a'></center></pre></bdo></b><th id='bbW5a'></th></span></q></dt></tr></i><div id='bbW5a'><tfoot id='bbW5a'></tfoot><dl id='bbW5a'><fieldset id='bbW5a'></fieldset></dl></div>

        自动部署到 F5 负载平衡环境

        Automated Deployment to an F5 Load Balanced Environment(自动部署到 F5 负载平衡环境)

          <tfoot id='v4NTR'></tfoot>

          <small id='v4NTR'></small><noframes id='v4NTR'>

          • <i id='v4NTR'><tr id='v4NTR'><dt id='v4NTR'><q id='v4NTR'><span id='v4NTR'><b id='v4NTR'><form id='v4NTR'><ins id='v4NTR'></ins><ul id='v4NTR'></ul><sub id='v4NTR'></sub></form><legend id='v4NTR'></legend><bdo id='v4NTR'><pre id='v4NTR'><center id='v4NTR'></center></pre></bdo></b><th id='v4NTR'></th></span></q></dt></tr></i><div id='v4NTR'><tfoot id='v4NTR'></tfoot><dl id='v4NTR'><fieldset id='v4NTR'></fieldset></dl></div>
          • <legend id='v4NTR'><style id='v4NTR'><dir id='v4NTR'><q id='v4NTR'></q></dir></style></legend>
                <bdo id='v4NTR'></bdo><ul id='v4NTR'></ul>
                  <tbody id='v4NTR'></tbody>
                1. 本文介绍了自动部署到 F5 负载平衡环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我们目前正在使用 TeamCity 进行 CI 构建,并且我们也在尝试设置自动化部署.

                  We are currently using TeamCity for CI builds and we are trying to set up automated deployments as well.

                  我目前尝试部署的项目是位于 F5 负载平衡器下的 Windows 服务.将来,我们还希望自动部署同样位于 F5 下的 IIS 网站.

                  The project I'm currently trying to deploy is a Windows service that sits under an F5 load balancer. In the future we would also like to automate the deployment of our IIS websites which also sit under the F5.

                  从 TeamCity,我们可以执行 PowerShell 脚本以在所需服务器上卸载 Windows 服务,将我们的文件推送到它,然后重新安装该服务.

                  From TeamCity we can execute PowerShell scripts to unistall the windows service on the desired server, push our files to it, then reinstall the service.

                  但是,我无法弄清楚如何处理负载平衡器.我们希望一次禁用 1 个节点,观察所有连接断开,然后部署我们的代码并重新启动节点.

                  However, I'm having trouble figuring out how to deal with the load balancer. We would want to disable 1 node at a time, watch for all the connections to drop, then deploy our code and bring the node back up.

                  这似乎是一个非常普遍的问题,但我发现关于如何做到这一点的信息非常少.

                  This seems like it would be a very common issue, but I'm finding surprisingly little information about how to do it.

                  谢谢!

                  已回答

                  感谢 Jonathon Rossi 提供 iControl Powershell cmdlet!

                  Thanks Jonathon Rossi for the iControl Powershell cmdlets!

                  为了其他用户的利益,这里是一个关闭、监控连接断开、推送代码,然后通过 powershell 脚本重新打开 F5 负载均衡器的示例

                  For other users' sakes, here is a sample of shutting down, monitoring for connections to drop, pushing code, and then turning back on the F5 load balancer through a powershell script

                  要使这些脚本正常工作,您首先必须通过以下答案中提供的链接安装 F5 iControl cmdlet

                  For these scripts to work you will first have to install the F5 iControl cmdlets from the links provided in the Answer below

                  #PULL IN OUR F5 UTILITY FUNCTIONS
                  . .F5Functions.ps1
                  
                  
                  #DEFINE LOGIC TO DEPLOY CODE TO A NODE THAT HAS ALREADY BEEN REMOVED FROM THE LOAD BALANCER
                  function Deploy(
                      [F5Node]$Node
                  )
                  {
                      Write-Host "Deploying To: "$Node.Name
                      #TODO: Remotely shut down services, push code, start back up services
                  }
                  
                  
                  #DEFINE NODES
                  $nodes = @()
                  $nodes += New-Object F5Node -ArgumentList @("TestNode1", "1.1.1.1")
                  $nodes += New-Object F5Node -ArgumentList @("TestNode2", "1.1.1.2")
                  
                  #DEPLOY
                  DeployToNodes -Nodes $nodes -F5Host $F5Host -F5UserName $F5UserName -F5Password $F5Password
                  

                  这是可重复使用的 F5Functions 脚本

                  And here is the reusable F5Functions script

                  #Load the F5 powershell iControl snapin
                  Add-PSSnapin iControlSnapin;
                  
                  Write-Host "Imported F5 function!!!"
                  
                  Add-Type @'
                      public class F5Node
                      {
                          public F5Node(string name, string address){
                              Address = address;
                              Name = name;
                          }
                          public string Address {get;set;}
                          public string Name {get;set;}
                          public string QualifiedName {get{return "/Common/" + Name;}}
                      }
                  '@
                  
                  function DeployToNodes(
                      [string]$F5Host = $(throw "Missing Required Parameter"),
                      [string]$F5UserName = $(throw "Missing Required Parameter"),
                      [string]$F5Password = $(throw "Missing Required Parameter"),
                      [F5Node[]]$Nodes = $(throw "Missing Required Parameter"),    
                      [int]$MaxWaitTime = 300 #seconds... defaults to 5 minutes
                  ){
                      Authenticate -F5Host $F5Host -F5UserName $F5UserName -F5Password $F5Password
                  
                      foreach($node in $Nodes){
                          DisableNode -Node $node
                  
                          WaitForConnectionsToDrop -Node $node -MaxWaitTime $MaxWaitTime
                  
                          #Assume the Script that included this script defined a Deploy Method with a Node param
                          Deploy -Node $node    
                  
                          EnableNode -Node $node
                      }
                  }
                  
                  function Authenticate(
                      [string]$F5Host = $(throw "Missing Required Parameter"),
                      [string]$F5UserName = $(throw "Missing Required Parameter"),
                      [string]$F5Password = $(throw "Missing Required Parameter")
                  )
                  {
                      Write-Host "Authenticating to F5..."
                      Initialize-F5.iControl -HostName $F5Host -Username $F5UserName -Password $F5Password
                      Write-Host "Authentication Success!!!"
                  }
                  
                  function ParseStatistic(
                          [iControl.CommonStatistic[]]$StatsCollection = $(throw "Missing Required Parameter"),
                          [string]$StatName = $(throw "Missing Required Parameter")
                      )
                  {
                      for($i=0; $i -lt $StatsCollection.Count; $i++){   
                          if($StatsCollection[$i].type.ToString() -eq $StatName){
                              return $StatsCollection[$i].value.low  
                              break
                          }                      
                      }
                  }
                  
                  function GetStats(
                          [F5Node]$Node = $(throw "Missing Required Parameter")
                      )
                  {
                      $arr = @($Node.QualifiedName)
                      $nodeStats = (Get-F5.iControl).LocalLBNodeAddressV2.get_statistics($arr)
                      return $nodeStats.statistics.statistics
                  
                      #foreach($memberStats in $poolStats.statistics){
                      #    if($memberStats.member.address.ToString() -eq $Node -and $memberStats.member.port -eq $Port){
                      #        return $memberStats.statistics
                      #    }  
                      #}
                  }
                  
                  function GetStatistic(
                          [F5Node]$Node = $(throw "Missing Required Parameter"),
                          [string]$StatName = $(throw "Missing Required Parameter")
                      )
                  {
                      $stats = GetStats -Node $Node
                      $stat = ParseStatistic -StatsCollection $stats -StatName $StatName
                  
                      return $stat
                  }
                  
                  function DisableNode(
                      [F5Node]$Node = $(throw "Missing Required Parameter")
                  )
                  {    
                      Disable-F5.LTMNodeAddress -Node $Node.Address
                      Write-Host "Disabled Node '$Node'"
                  }
                  
                  function EnableNode(
                      [F5Node]$Node = $(throw "Missing Required Parameter")
                  )
                  {
                      Enable-F5.LTMNodeAddress -Node $Node.Address
                      Write-Host "Enabled Node '$Node'"
                  }
                  
                  function WaitForConnectionsToDrop(
                      [F5Node]$Node = $(throw "Missing Required Parameter"),
                      [int]$MaxWaitTime = 300
                  )
                  {
                      $connections = GetCurrentConnections -Node $Node
                  
                      $elapsed = [System.Diagnostics.Stopwatch]::StartNew();
                      while($connections -gt 0 -and $elapsed.ElapsedMilliseconds -lt ($MaxWaitTime * 1000)){        
                  
                          Start-Sleep -Seconds 10
                  
                          $connections = GetCurrentConnections -Node $Node
                      }
                  }
                  
                  function GetCurrentConnections(
                      [F5Node]$Node = $(throw "Missing Required Parameter")
                  )
                  {
                      $connections = GetStatistic -Node $Node -StatName "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS"
                      $name = $Node.Name + ":" + $Node.Address
                      Write-Host "$connections connections remaining on '$name'"
                      return $connections
                  }
                  

                  推荐答案

                  没用过,你看过F5 iControl Web 服务 API 和 F5 iControl PowerShell cmdlet 由 F5 提供.PowerShell cmdlet 自 2007 以来一直存在,可以从 2007 下载a href="https://devcentral.f5.com/community/group/aft/1172127/asg/3" rel="noreferrer">F5 DevCentral.

                  I haven't used it, but have you looked at the F5 iControl web service API and the F5 iControl PowerShell cmdlets provided by F5. The PowerShell cmdlets have been around since 2007 and can be downloaded from F5 DevCentral.

                  您可以使用 Enable-MemberDisable-Member cmdlet.

                  It looks like there are Enable-Member and Disable-Member cmdlets that you'll be able to use.

                  这篇关于自动部署到 F5 负载平衡环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                2. <legend id='3y3x8'><style id='3y3x8'><dir id='3y3x8'><q id='3y3x8'></q></dir></style></legend>
                        <tbody id='3y3x8'></tbody>

                      <small id='3y3x8'></small><noframes id='3y3x8'>

                          <bdo id='3y3x8'></bdo><ul id='3y3x8'></ul>

                        • <tfoot id='3y3x8'></tfoot>

                            <i id='3y3x8'><tr id='3y3x8'><dt id='3y3x8'><q id='3y3x8'><span id='3y3x8'><b id='3y3x8'><form id='3y3x8'><ins id='3y3x8'></ins><ul id='3y3x8'></ul><sub id='3y3x8'></sub></form><legend id='3y3x8'></legend><bdo id='3y3x8'><pre id='3y3x8'><center id='3y3x8'></center></pre></bdo></b><th id='3y3x8'></th></span></q></dt></tr></i><div id='3y3x8'><tfoot id='3y3x8'></tfoot><dl id='3y3x8'><fieldset id='3y3x8'></fieldset></dl></div>