Kubernetes에 Consul Enterprise 설치

Kubernetes에 Consul Enterprise 설치 (Consul Enterprise on Kubernetes)

이 문서는 Helm 차트를 사용해 Kubernetes에 Consul Enterprise를 설치하는 방법을 설명해요. 라이선스를 Kubernetes 시크릿으로 저장한다고 가정하고, 시크릿 생성부터 Helm 차트 구성과 설치, 검증까지 단계별로 안내할게요.

출처: 문서

본문

이 문서는 Helm 차트를 사용해 Kubernetes에 Consul Enterprise를 설치하는 방법을 설명합니다. 라이선스를 Kubernetes 시크릿으로 저장한다고 가정합니다. Enterprise 라이선스를 Vault에 저장하려면 Vault에 Enterprise 라이선스 저장을 참조하세요.

요구 사항 (Requirements)

환영 이메일에서 받은 라이선스 파일을 찾으세요. 이 파일은 .hclic 확장자를 가져야 합니다. Helm 차트를 설치하기 전에 이 파일의 내용으로 Kubernetes 시크릿을 만들게 됩니다.

참고

.hclic 파일을 찾을 수 없다면 영업팀이나 기술 계정 관리자(TAM)에게 문의하세요.

Kubernetes 시크릿 생성 (Create Kubernetes secret)

Enterprise 라이선스 파일의 내용으로 secret이라는 환경 변수를 내보냅니다(export).

$ secret=$(cat 1931d1f4-bdfd-6881-f3f5-19349374841f.hclic)

라이선스 파일의 값을 값으로 하여 consul-ent-license라는 이름과 key라는 키의 Kubernetes 시크릿을 생성합니다.

$ kubectl create secret generic consul-ent-license --from-literal="key=${secret}"

Helm 차트 구성 (Configure Helm chart)

values.yaml에서 global.image 값을 엔터프라이즈 릴리즈 태그 중 하나로 변경합니다. Enterprise 이미지는 -ent로 끝납니다.

values.yaml:

global:
  image: 'hashicorp/consul-enterprise:1.20.0-ent'

Consul Enterprise 시크릿을 정의합니다.

Consul v1.10+

Consul v1.10 미만

Consul v1.10+를 사용한다면 방금 만든 시크릿의 이름과 키를 server.enterpriseLicense에 추가합니다.

values.yaml:

global:
  image: 'hashicorp/consul-enterprise:1.20.0-ent'
  enterpriseLicense:
    secretName: 'consul-ent-license'
    secretKey: 'key'

Consul v1.10 미만 버전을 사용한다면 방금 만든 시크릿의 이름과 키로 다음 구성을 사용하세요. 이 값들은 일반 구성에 추가로 필요합니다.

server.enterpriseLicense.enableLicenseAutoload를 false로 설정해야 합니다.

values.yaml:

global:
  image: 'hashicorp/consul-enterprise:1.8.3-ent'
  enterpriseLicense:
    secretName: 'consul-ent-license'
    secretKey: 'key'
    enableLicenseAutoload: false

Consul Enterprise 설치 (Install Consul Enterprise)

이제 업데이트된 Helm 차트를 사용해 Kubernetes 클러스터에 Consul Enterprise를 설치합니다.

$ helm install --wait hashicorp hashicorp/consul --values values.yaml

참고

기본 consul 네임스페이스가 아닌 다른 K8s 네임스페이스에서 Consul을 배포하거나 업그레이드할 때 오류가 발생하면 다음 기술적 제약 목록을 참조하세요.

  • Consul은 자신의 대상 K8s 네임스페이스를 자동으로 감지할 수 없으므로, Helm 또는 consul-k8s 도구 파라미터의 -namespace에 명시적으로 나열해야 합니다.
  • Consul은 대상 K8s 네임스페이스를 connectInjector.k8sAllowNamspaces Helm 차트 값에 추가해야 합니다. 자세한 내용은 Consul Helm 차트 참조의 이 특정 설정을 참조하세요.

설치 검증 (Verify installation)

클러스터가 가동되면 consul license get 명령으로 노드가 Consul Enterprise를 실행 중인지 확인할 수 있습니다.

먼저 로컬 포트 8500을 Consul 서버로 포워딩해서 Kubernetes 안의 Consul 서버를 대상으로 로컬에서 consul 명령을 실행할 수 있게 합니다.

$ kubectl port-forward service/hashicorp-consul-server 8500:8500

별도 탭에서 consul license get 명령을 실행합니다.

$ consul license get
License is valid
License ID: 1931d1f4-bdfd-6881-f3f5-19349374841f
Customer ID: b2025a4a-8fdd-f268-95ce-1704723b9996
Expires At: 2020-03-09 03:59:59.999 +0000 UTC
Datacenter: *
Package: premium
Licensed Features:
        Automated Backups
        Automated Upgrades
        Enhanced Read Scalability
        Network Segments
        Redundancy Zone
        Advanced Network Federation

Consul 서버를 나열합니다. Build 열의 +ent에 주목하세요. 이는 서버가 Consul Enterprise를 실행 중임을 나타냅니다.

$ consul members
Node                                       Address           Status  Type    Build      Protocol  DC   Segment
hashicorp-consul-server-0                  10.60.0.187:8301  alive   server  1.10.0+ent  2         dc1  <all>
hashicorp-consul-server-1                  10.60.1.229:8301  alive   server  1.10.0+ent  2         dc1  <all>
hashicorp-consul-server-2                  10.60.2.197:8301  alive   server  1.10.0+ent  2         dc1  <all>

ACL 활성화 (ACLs enabled)

명령이 다음 오류 메시지를 반환하면 Consul 배포에 ACL이 활성화되어 있을 가능성이 높습니다.

Error getting license: invalid character 'r' looking for beginning of value

license get 명령을 실행할 때 ACL 토큰을 지정해야 합니다. 먼저 CONSUL_HTTP_TOKEN 환경 변수에 ACL 토큰을 할당합니다:

$ export CONSUL_HTTP_TOKEN=$(kubectl get secrets/hashicorp-consul-bootstrap-acl-token --template='{{.data.token | base64decode }}')

이제 Consul 명령을 실행할 때 토큰이 사용됩니다.

$ consul license get
License is valid
License ID: 1931d1f4-bdfd-6881-f3f5-19349374841f
Customer ID: b2025a4a-8fdd-f268-95ce-1704723b9996
Expires At: 2020-03-09 03:59:59.999 +0000 UTC
Datacenter: *
Package: premium
Licensed Features:
        Automated Backups
        Automated Upgrades
        Enhanced Read Scalability
        Network Segments
        Redundancy Zone
        Advanced Network Federation

더 알아보기 (Learn more)