서비스 맵 & Hubble UI

서비스 맵 & Hubble UI (Service Map & Hubble UI)

이 튜토리얼은 그래픽 서비스 맵에 접근하기 위해 Hubble UI를 활성화하는 방법을 안내해요. cilium hubble ui 한 줄로 클러스터 안 서비스 간의 의존성·연결 맵을 브라우저에서 볼 수 있습니다.

출처: Service Map & Hubble UI

본문

../../../_images/hubble_sw_service_map.png

Note

이 가이드는 Cilium과 Hubble이 Kubernetes 클러스터에 올바르게 설치되어 있다고 가정해요. 자세한 내용은 Cilium 빠른 설치와 Hubble 관측성 설정을 참고하세요. 확실하지 않다면 cilium status를 실행해 Cilium과 Hubble이 설치되어 있는지 확인하세요.

Hubble UI 활성화

다음 명령을 실행해 Hubble UI를 활성화하세요:

Cilium CLI

cilium hubble enable --ui
🔑 Found existing CA in secret cilium-ca
✨ Patching ConfigMap cilium-config to enable Hubble...
♻️ Restarted Cilium pods
✅ Relay is already deployed
✅ Hubble UI is already deployed

Helm

Helm Repository

helm upgrade cilium cilium/cilium --version 1.20.2 \
   --namespace $CILIUM_NAMESPACE \
   --reuse-values \
   --set hubble.relay.enabled=true \
   --set hubble.ui.enabled=true

OCI Registry

helm upgrade cilium oci://quay.io/cilium/charts/cilium 1.20.2 \
   --namespace $CILIUM_NAMESPACE \
   --reuse-values \
   --set hubble.relay.enabled=true \
   --set hubble.ui.enabled=true

일부 클러스터에는 Cilium, Hubble, Hubble relay가 이미 설치되어 있는 경우가 있어요. 그런 경우에도 Helm을 사용해 사전 설치된 컴포넌트 위에 Hubble UI만 설치할 수 있습니다.

hubble.ui.standalone.enabled를 true로 설정해야 하며, Hubble Relay 서버 측에서 TLS가 활성화되어 있다면 선택적으로 Hubble UI 클라이언트 인증서를 마운트할 볼륨을 제공할 수 있어요.

아래는 my-hubble-ui-client-certs secret에서 클라이언트 인증서를 마운트하면서 Hubble UI를 standalone으로 배포하는 예제예요:

Helm Repository

helm upgrade cilium cilium/cilium --version 1.20.2 \
   --namespace $CILIUM_NAMESPACE \
   --reuse-values \
   --set hubble.relay.enabled=true \
   --set hubble.ui.enabledd=true \
   --values - <<EOF
   agent: false
   operator:
     enabled: false
   cni:
     install: false
   hubble:
     enabled: false
     relay:
       # set this to false as Hubble relay is already installed
       enabled: false
       tls:
         server:
           # set this to true if tls is enabled on Hubble relay server side
           enabled: true
     ui:
       # enable Hubble UI
       enabled: true
       standalone:
         # enable Hubble UI standalone deployment
         enabled: true
         # provide a volume containing Hubble relay client certificates to mount in Hubble UI pod
         tls:
           certsVolume:
             projected:
               defaultMode: 0400
               sources:
                 - secret:
                     name: my-hubble-ui-client-certs
                     items:
                       - key: tls.crt
                         path: client.crt
                       - key: tls.key
                         path: client.key
                       - key: ca.crt
                         path: hubble-relay-ca.crt
   EOF

OCI Registry

helm upgrade cilium oci://quay.io/cilium/charts/cilium 1.20.2 \
   --namespace $CILIUM_NAMESPACE \
   --reuse-values \
   --set hubble.relay.enabled=true \
   --set hubble.ui.enabledd=true \
   --values - <<EOF
   agent: false
   operator:
     enabled: false
   cni:
     install: false
   hubble:
     enabled: false
     relay:
       # set this to false as Hubble relay is already installed
       enabled: false
       tls:
         server:
           # set this to true if tls is enabled on Hubble relay server side
           enabled: true
     ui:
       # enable Hubble UI
       enabled: true
       standalone:
         # enable Hubble UI standalone deployment
         enabled: true
         # provide a volume containing Hubble relay client certificates to mount in Hubble UI pod
         tls:
           certsVolume:
             projected:
               defaultMode: 0400
               sources:
                 - secret:
                     name: my-hubble-ui-client-certs
                     items:
                       - key: tls.crt
                         path: client.crt
                       - key: tls.key
                         path: client.key
                       - key: ca.crt
                         path: hubble-relay-ca.crt
   EOF

Hubble UI는 인증서 파일이 다음 경로에서 사용 가능하기를 기대한다는 점을 기억하세요:

- name: TLS_RELAY_CA_CERT_FILES
  value: /var/lib/hubble-ui/certs/hubble-relay-ca.crt
- name: TLS_RELAY_CLIENT_CERT_FILE
  value: /var/lib/hubble-ui/certs/client.crt
- name: TLS_RELAY_CLIENT_KEY_FILE
  value: /var/lib/hubble-ui/certs/client.key

인증서를 담은 볼륨을 제공할 때 이 점을 유의하세요.

Hubble UI 열기

cilium hubble ui를 실행해 브라우저에서 Hubble UI를 여세요. 이 명령은 Kubernetes 클러스터의 hubble-ui 서비스로 포트 포워드를 자동으로 설정하고 로컬 머신의 포트에서 사용할 수 있게 해줘요.

cilium hubble ui
Forwarding from 0.0.0.0:12000 -> 8081
Forwarding from [::]:12000 -> 8081

Tip

위 명령은 포트 포워드가 활성화된 동안 블록되어 계속 실행돼요. 명령을 중단하면 포트 포워드가 중단되고, 다시 실행하면 UI에 다시 접근할 수 있습니다.

브라우저가 UI를 자동으로 열지 않았다면 http://localhost:12000을 여세요. 네임스페이스를 선택하라는 화면이 보일 텐데, 왼쪽 상단의 네임스페이스 선택 드롭다운을 사용해 네임스페이스를 선택하세요:

../../../_images/hubble_service_map_namespace_selector.png

이 예제에서는 Identity-Aware 및 HTTP-Aware 정책 적용 가이드의 Star Wars 데모를 배포하고 있어요. 하지만 같은 기법을 자신의 네임스페이스와 어떤 유형의 애플리케이션 클러스터에도 적용해서 애플리케이션 연결 의존성을 관찰할 수 있습니다.

배포가 준비되면 두 우주선에서 요청을 보내 트래픽을 만들어 보세요.

$ kubectl exec xwing -- curl -s -XPOST deathstar.default.svc.cluster.local/v1/request-landing
Ship landed
$ kubectl exec tiefighter -- curl -s -XPOST deathstar.default.svc.cluster.local/v1/request-landing
Ship landed

그러면 이 요청들이 UI에서 서로 다른 파드 사이의 서비스 의존성으로 표시돼요:

../../../_images/hubble_sw_service_map.png

인터페이스 하단에서는 현재 네임스페이스의 최근 Hubble 흐름 이벤트를 개별적으로 확인할 수도 있어요.

다양한 네트워크 트래픽 살펴보기

네트워크 트래픽을 생성하려면 커넥티비티 테스트를 반복 실행하세요:

while true; do cilium connectivity test; done

트래픽을 Hubble에서 보려면 브라우저로 http://localhost:12000/cilium-test를 여세요.

더 알아보기 (Learn more)