자동 업그레이드

자동 업그레이드 (Automated Upgrades)

서버가 실행 중인 Consul 버전을 업그레이드하는 데 도움이 되는 Consul Enterprise 기능인 자동 업그레이드에 대해 설명해요.

출처: 문서

본문

이 페이지는 서버가 실행 중인 Consul 버전을 업그레이드하는 데 도움이 되는 Consul Enterprise 기능인 자동 업그레이드를 설명합니다.

Enterprise

이 기능은 Consul Enterprise가 필요합니다.

자세한 내용은 엔터프라이즈 기능 매트릭스를 참조하세요.

소개 (Introduction)

모든 프로덕션 환경에서 수행해야 하는 기본 작업 중 하나는 다운타임 없이 Consul 서버를 새 버전으로 업그레이드하면서 향후 중단으로 이어질 수 있는 위험 요소를 최소화하는 것입니다.

Consul autopilot은 클러스터의 서버 수를 모니터링합니다. 충분한 수의 새 서버 노드가 조인하면 Consul은 이를 투표자(voter)로 승격하고 새 서버 중에서 새 리더를 선출한 다음, 이전 버전을 실행하는 서버를 비투표자(non-voter)로 강등합니다. 이 강등이 발생하면 이전 서버를 클러스터에서 안전하게 제거할 수 있습니다.

자동 업그레이드는 다음 시나리오에서 도움이 될 수 있습니다.

  • 새 Consul 버전으로 업그레이드 : 다운타임 없이 Consul 서버를 최신 버전으로 업그레이드하려는 경우.
  • 다른 서버 노드로 마이그레이션 : 보안 패치가 있는 새 Consul 서버 이미지가 있고 다운타임 없이 실행 중인 Consul 서버 인스턴스를 자동으로 교체하려는 경우.

전제 조건 (Prerequisites)

이 자습서에서 설명하는 자동 업그레이드 기능을 테스트하려면 다음이 필요합니다.

  • Consul Enterprise를 실행하는 세 개의 서버가 있는 Consul Enterprise 데이터센터.
  • 이전 서버를 교체하기 위해 최신 Consul Enterprise 바이너리가 설치된 세 개의 추가 노드.

직접 업그레이드가 가능하려면 서로 다른 Consul 버전이 호환되어야 합니다. 프로토콜 호환성 보증(Protocol Compatibility Promise)과 업그레이드 지침(Upgrade instructions)을 확인해 사용 중인 버전이 호환되는지 확인하세요.

새 Consul 버전으로 업그레이드 (Upgrade to a new Consul version)

자동 업그레이드로 Consul 서버를 최신 버전으로 업그레이드하는 프로세스는 다음 단계로 구성됩니다.

  • 자동 업그레이드가 활성화되어 있는지 확인
  • 새 Consul 서버 추가
  • 업그레이드 확인
  • 이전 서버 중지

자동 업그레이드가 활성화되어 있는지 확인 (Verify that automated upgrades is enabled)

자동 업그레이드 기능은 Consul Enterprise에서 기본적으로 활성화되어 있습니다.

데이터센터의 구성이 활성화되어 있는지 확인하려면 consul operator autopilot 명령을 사용하세요.

$ consul operator autopilot get-config

이 명령은 전체 autopilot 구성을 반환합니다. 자동 업그레이드가 활성화되면 DisableUpgradeMigration이 false로 설정됩니다.

consul operator autopilot get-config
CleanupDeadServers = true
LastContactThreshold = 200ms
MaxTrailingLogs = 250
MinQuorum = 0
ServerStabilizationTime = 10s
RedundancyZoneTag = ""
DisableUpgradeMigration = false
UpgradeVersionTag = ""

데이터센터에서 기능이 비활성화되어 있다면 consul operator autopilot set-config -disable-upgrade-migration=false 명령으로 활성화하세요.

새 Consul 서버 추가 (Add new Consul servers)

다음 예시는 세 개의 서버와 bootstrap_expect = 3이 있는 기존 Consul Enterprise 1.21.7 데이터센터를 사용합니다.

consul members를 사용해 클러스터의 초기 상태를 확인하세요.

$ consul members
Node             Address           Status  Type    Build       Protocol  DC   Partition  Segment
consul-server-1  172.18.0.12:8301  alive   server  1.21.7+ent  2         dc1  default    <all>
consul-server-2  172.18.0.8:8301   alive   server  1.21.7+ent  2         dc1  default    <all>
consul-server-3  172.18.0.6:8301   alive   server  1.21.7+ent  2         dc1  default    <all>

명확성을 위해 이전 서버 노드는 consul-server-<number> 체계로 명명됩니다. 새 서버 노드는 대신 consul-server-<number-letter>를 사용합니다.

$consul operator raft list-peers
Node              ID                                    Address           State     Voter  RaftProtocol  Commit Index  Trails Leader By
consul-server-1   630ffcac-8f68-e9e0-5cca-54c3fa5f7290  172.18.0.12:8300  leader    true   3             85            -
consul-server-2   bffdeec5-27f0-2116-99b1-68714679c2a0  172.18.0.8:8300   follower  true   3             85            0 commits
consul-server-3   4aedd7d4-d5e4-109e-33dc-f6c2a2fd98c9  172.18.0.6:8300   follower  true   3             85            0 commits
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  follower  false  3             85            0 commits
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  false  3             85            0 commits

Consul은 새 Consul 버전을 실행하는 충분한 수의 서버가 데이터센터의 일부가 될 때까지 추가된 서버를 비투표자 구성원으로 유지합니다. 새 서버 수가 쿼럼을 형성하고 새 리더를 선출하기에 충분해지면 autopilot은 새 서버를 투표자로 승격하고 새 리더 선거를 트리거한 다음 최종적으로 이전 서버를 강등합니다.

업그레이드 확인 (Verify upgrade)

새 버전을 실행하는 충분한 수의 서버가 데이터센터에 조인한 후 Consul autopilot이 업그레이드 프로세스를 시작합니다.

먼저 새 노드가 투표자 상태로 승격됩니다.

$ consul operator raft list-peers
Node              ID                                    Address           State     Voter  RaftProtocol  Commit Index  Trails Leader By
consul-server-1   630ffcac-8f68-e9e0-5cca-54c3fa5f7290  172.18.0.12:8300  leader    true   3             106           -
consul-server-2   bffdeec5-27f0-2116-99b1-68714679c2a0  172.18.0.8:8300   follower  true   3             106           0 commits
consul-server-3   4aedd7d4-d5e4-109e-33dc-f6c2a2fd98c9  172.18.0.6:8300   follower  true   3             106           0 commits
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  follower  true   3             106           0 commits
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  true   3             106           0 commits
consul-server-3a  626faa96-91af-53b1-da97-21435d4c5f62  172.18.0.15:8300  follower  true   3             106           0 commits

그런 다음, 이전 Consul 버전의 팔로워 노드가 비투표자로 강등되고 새 리더 선거가 트리거됩니다.

$ consul operator raft list-peers
Node              ID                                    Address           State     Voter   RaftProtocol  Commit Index  Trails Leader By
consul-server-1   630ffcac-8f68-e9e0-5cca-54c3fa5f7290  172.18.0.12:8300  leader    true    3             106           -
consul-server-2   bffdeec5-27f0-2116-99b1-68714679c2a0  172.18.0.8:8300   follower  false   3             106           0 commits
consul-server-3   4aedd7d4-d5e4-109e-33dc-f6c2a2fd98c9  172.18.0.6:8300   follower  false   3             106           0 commits
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  follower  true    3             106           0 commits
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  true    3             106           0 commits
consul-server-3a  626faa96-91af-53b1-da97-21435d4c5f62  172.18.0.15:8300  follower  true    3             106           0 commits

새 Consul 서버가 리더를 선출한 후 autopilot은 이전 리더를 non-voter로 강등합니다.

$ consul operator raft list-peersrs
Node              ID                                    Address           State     Voter  RaftProtocol  Commit Index  Trails Leader By
consul-server-1   630ffcac-8f68-e9e0-5cca-54c3fa5f7290  172.18.0.12:8300  follower  false  3             117           0 commits
consul-server-2   bffdeec5-27f0-2116-99b1-68714679c2a0  172.18.0.8:8300   follower  false  3             117           0 commits
consul-server-3   4aedd7d4-d5e4-109e-33dc-f6c2a2fd98c9  172.18.0.6:8300   follower  false  3             117           0 commits
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  leader    true   3             117           -
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  true   3             117           0 commits
consul-server-3a  626faa96-91af-53b1-da97-21435d4c5f62  172.18.0.15:8300  follower  true   3             117           0 commits

이 프로세스는 리더의 로그에서도 관찰할 수 있습니다.

## ...
[INFO]  agent.server.autopilot: Promoting server: id=16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc address=172.18.0.17:8300 name=consul-server-1a
## ...
[INFO]  agent.server.autopilot: Promoting server: id=73e267e5-f817-0577-bbe5-2f843adff357 address=172.18.0.4:8300 name=consul-server-2a
## ...
[INFO]  agent.server.autopilot: Promoting server: id=626faa96-91af-53b1-da97-21435d4c5f62 address=172.18.0.15:8300 name=consul-server-3a
## ...
[INFO]  agent.server.autopilot: Demoting server: id=4aedd7d4-d5e4-109e-33dc-f6c2a2fd98c9 address=172.18.0.6:8300 name=consul-server-3
## ...
[INFO]  agent.server.autopilot: Demoting server: id=bffdeec5-27f0-2116-99b1-68714679c2a0 address=172.18.0.8:8300 name=consul-server-2
## ...
[INFO]  agent.server.autopilot: Transferring leadership to new server: id=16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc address=172.18.0.17:8300
## ...
[INFO]  agent.server.raft: entering follower state: follower="Node at 172.18.0.12:8300 [Follower]" leader-address= leader-id=
## ...
[INFO]  agent.server: cluster leadership lost
## ...
[INFO]  agent.server: New leader elected: payload=consul-server-1a

이전 서버 중지 (Stop old servers)

업그레이드가 완료되면 consul leave 명령을 사용해 이전 서버를 데이터센터에서 제거하세요.

다른 서버 노드로 마이그레이션 (Migrate to different server nodes)

일부 환경에서 Consul은 노드의 보안 또는 안정성을 보장하기 위해 업그레이드해야 하는 유일한 구성 요소가 아닙니다. 예를 들어 OS 패치를 적용하거나 새 구성 설정을 적용하려면 노드 업데이트를 롤아웃해야 할 수 있습니다.

Consul autopilot에는 자동 업그레이드에 Consul이 사용하는 매개변수를 재정의하는 UpgradeVersionTag 매개변수가 포함되어 있습니다. Consul은 Consul 버전을 업그레이드하지 않을 때도 이러한 태그를 사용해 데이터센터를 업데이트할 수 있습니다.

UpgradeVersionTag가 구성되면 Consul은 그 값을 사용해 각 서버의 지정된 node_meta 태그에서 버전을 찾습니다.

예를 들어 UpgradeVersionTag가 build로 설정되고 서버 구성에서 node-meta.build가 0.0.2로 설정되면 autopilot이 마이그레이션을 고려할 때 해당 서버의 버전은 0.0.2입니다. 업그레이드 로직은 시맨틱 버전 관리를 따르며 버전 문자열은 X, X.Y 또는 X.Y.Z 형식 중 하나여야 합니다.

UpgradeVersionTag를 사용해 Consul 서버를 업그레이드하려면 다음 단계를 완료하세요.

  • 기존 서버에 대해 autopilot 구성
  • 새 Consul 서버 추가
  • 업그레이드 확인
  • 이전 서버 중지

기존 서버에 대해 autopilot 구성 (Configure autopilot for existing servers)

다음 예시는 server-1a, server-2a, server-3a의 세 서버로 시작합니다. server-1b, server-2b, server-3b 이름의 세 개의 추가 서버가 사용됩니다.

$ consul members
Node              Address            Status  Type    Build       Protocol  DC   Partition  Segment
consul-server-1a  172.18.0.17:8301   alive   server  1.22.1+ent  2         dc1  default    <all>
consul-server-2a  172.18.0.4:8301    alive   server  1.22.1+ent  2         dc1  default    <all>
consul-server-3a  172.18.0.15:8301   alive   server  1.22.1+ent  2         dc1  default    <all>

기존 서버 에이전트 구성에 node_meta 옵션을 추가하세요.

서버 에이전트 구성

## ...
node_meta {
  build = "0.0.1"
}
## ...
## ...
"node_meta": {
    "build": "0.0.1"
  },
## ...

서버 구성을 다시 로드하세요.

$ consul reload
Configuration reload triggered

node_meta 구성을 추적하도록 Consul autopilot 구성을 수정하세요.

$ consul operator autopilot set-config -upgrade-version-tag=build
Configuration updated!

autopilot 구성이 성공적으로 업데이트되었는지 확인하세요.

$ consul operator autopilot get-config

UpgradeVersionTag가 build로 설정되어 있는지 확인하세요.

CleanupDeadServers = true
LastContactThreshold = 200ms
MaxTrailingLogs = 250
MinQuorum = 0
ServerStabilizationTime = 10s
RedundancyZoneTag = ""
DisableUpgradeMigration = false
UpgradeVersionTag = "build"

새 Consul 서버 추가 (Add new Consul servers)

새 서버의 경우 UpgradeVersionTag를 구성에 직접 정의하세요.

## ...
node_meta {
  build = "0.0.2"
}
autopilot {
  upgrade_version_tag = "build"
}
## ...
# ...
    "node_meta": {
        "build": "0.0.2"
    },
    "autopilot":{
        "upgrade_version_tag":"build"
    },
# ...

업그레이드 확인 (Verify upgrade)

세 번째 새 서버가 시작되면 autopilot이 새 서버 간의 쿼럼 가능성을 감지하고 이를 투표자로 승격합니다.

새 노드는 먼저 투표자 상태로 승격됩니다.

$ consul operator raft list-peers
Node              ID                                    Address           State     Voter  RaftProtocol  Commit Index   Trails Leader By
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  leader    true   3             157            0 commits
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  true   3             157            0 commits
consul-server-3a  626faa96-91af-53b1-da97-21435d4c5f62  172.18.0.15:8300  follower  true   3             157            0 commits
consul-server-1b  c04510f4-4d6d-9b54-3ac8-8843b848b24a  172.18.0.9:8300   follower  true   3             157            0 commits
consul-server-2b  7ba9deda-fd46-cb10-6341-b32eb2db87de  172.18.0.6:8300   follower  true   3             157            0 commits
consul-server-3b  3908d249-3da3-2262-7405-da5b80337716  172.18.0.11:8300  follower  true   3             157            0 commits

그런 다음, 이전 Consul 빌드 값의 팔로워 노드가 비투표자로 강등되고 새 리더 선거가 트리거됩니다.

$ consul operator raft list-peers
Node              ID                                    Address           State     Voter  RaftProtocol  Commit Index   Trails Leader By
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  leader    true   3             157            0 commits
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  false  3             157            0 commits
consul-server-3a  626faa96-91af-53b1-da97-21435d4c5f62  172.18.0.15:8300  follower  false  3             157            0 commits
consul-server-1b  c04510f4-4d6d-9b54-3ac8-8843b848b24a  172.18.0.9:8300   follower  true   3             157            0 commits
consul-server-2b  7ba9deda-fd46-cb10-6341-b32eb2db87de  172.18.0.6:8300   follower  true   3             157            0 commits
consul-server-3b  3908d249-3da3-2262-7405-da5b80337716  172.18.0.11:8300  follower  true   3             157            0 commits

마지막으로, 새 Consul 서버 중에서 새 리더가 선출되면 이전 리더가 non-voter로 강등됩니다.

$ consul operator raft list-peersrs
Node              ID                                    Address           State     Voter  RaftProtocol  Commit Index   Trails Leader By
consul-server-1a  16a4ffeb-a8d4-b42d-edf1-cdec993fdcdc  172.18.0.17:8300  follower  false  3             157            0 commits
consul-server-2a  73e267e5-f817-0577-bbe5-2f843adff357  172.18.0.4:8300   follower  false  3             157            0 commits
consul-server-3a  626faa96-91af-53b1-da97-21435d4c5f62  172.18.0.15:8300  follower  false  3             157            0 commits
consul-server-1b  c04510f4-4d6d-9b54-3ac8-8843b848b24a  172.18.0.9:8300   leader    true   3             157            0 commits
consul-server-2b  7ba9deda-fd46-cb10-6341-b32eb2db87de  172.18.0.6:8300   follower  true   3             157            0 commits
consul-server-3b  3908d249-3da3-2262-7405-da5b80337716  172.18.0.11:8300  follower  true   3             157            0 commits

이 프로세스는 리더의 로그에서도 관찰할 수 있습니다.

## ...
[INFO]  agent.server.autopilot: Promoting server: id=c04510f4-4d6d-9b54-3ac8-8843b848b24a address=172.18.0.9:8300 name=consul-server-1b
## ...
[INFO]  agent.server.autopilot: Promoting server: id=7ba9deda-fd46-cb10-6341-b32eb2db87de address=172.18.0.6:8300 name=consul-server-2b
## ...
[INFO]  agent.server.autopilot: Promoting server: id=3908d249-3da3-2262-7405-da5b80337716 address=172.18.0.11:8300 name=consul-server-3b
## ...
[INFO]  agent.server.autopilot: Demoting server: id=626faa96-91af-53b1-da97-21435d4c5f62 address=172.18.0.15:8300 name=consul-server-3a
## ...
[INFO]  agent.server.autopilot: Demoting server: id=73e267e5-f817-0577-bbe5-2f843adff357 address=172.18.0.4:8300 name=consul-server-2a
## ...
[INFO]  agent.server.autopilot: Transferring leadership to new server: id=c04510f4-4d6d-9b54-3ac8-8843b848b24a address=172.18.0.9:8300
## ...
[INFO]  agent.server.raft: entering follower state: follower="Node at 172.18.0.17:8300 [Follower]" leader-address= leader-id=
## ...
[INFO]  agent.server: cluster leadership lost
## ...
[INFO]  agent.server: New leader elected: payload=consul-server-1b

이전 서버 중지 (Stop old servers)

업그레이드가 완료되면 consul leave 명령을 사용해 이전 서버를 데이터센터에서 제거하세요.

다음 단계 (Next steps)

Consul 업그레이드를 계획하기 전에 다음에서 제공하는 버전별 지침을 검토하세요.

다른 Consul autopilot 기능에 대해 자세히 알아보려면 Consul autopilot을 참조하세요.

더 알아보기 (Learn more)