Introduction

Gathering debugging information from the OpenShift cluster can easily be done with a must-gather feature. A shared must-gather functionality within the oc command line tool and customizable images for each project can extract information via this feature.

Running must-gather has been possible from CLI for some time. A must-gather operator was later introduced to help Red Hat Customer Experience & Engagement by submitting gathered data directly to customer tickets.

Most of the customer-facing projects we implemented have a web UI, so it would be awkward to ask users to leave the UI, switch to console, and run oc adm must-gather commands manually. To provide the must-gather functionality from UI, a backend was needed. Let’s call it a must-gather API. This post is going to introduce the newly implemented must-gather-api backend service.

The API design

The must-gather API necessary to provide backend service to the UI needs to be consumable by existing JavaScript frameworks (like react components), and it should be able to use cURL for easier testing, debugging, and other more expert debugging use cases.

The main function of the API is to accept a request from the UI, run oc adm must-gather, and provide the result archive link to be downloaded by the user. The must-gather execution could take longer, so the execution runs asynchronously, and API consumer (UI) can poll for updates on the must-gather execution.

The list of needed API calls is pretty short, just trigger must-gather, get must-gather execution status, and download the result archive. See the example below.

Start the must-gather execution:

$ curl https://<must-gather-api-endpoint>/must-gather \
  --request POST \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer <token>" \
  --data '
{
  "image": "quay.io/konveyor/forklift-must-gather",
  "timeout": "15m"
}'

Get the must-gather execution status and progress information:

$ curl https://<must-gather-api-endpoint>/must-gather/15 \
  --header "Authorization: Bearer <token>"

And finally download the result must-gather archive (available only if must-gather execution status == "completed"):

$ curl https://<must-gather-api-endpoint>/must-gather/15/data \

    --header "Authorization: Bearer <token>" \

    --remote-name --remote-header-name

The full specification is available in the project README at https://github.com/konveyor/forklift-must-gather-api#README.

Targeted must-gather support

This API service can take advantage of targeted must-gather implemented in Forklift, introduced in my previous blog post. This allows the user to pass a “custom-command” as an addition to the must-gather, so because it is based on the image used for must-gather, only relevant resources will be gathered:

$ curl https://<must-gather-api-endpoint>/must-gather \
  --request POST \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer <token>" \
  --data '
{
  "image": "quay.io/konveyor/forklift-must-gather",
  "timeout": "15m",
  "custom-command": "PLAN=<forklift-migration-plan> /usr/bin/targeted",
}'

This is a key feature behind the Forklift/MTV UI “Get logs” button, which allows users to gather relevant debugging data for VM or migration Plan:

Authentication

The must-gather itself needs to be executed by the cluster-admin, which could be tricky for a component deployed by the Operator. To avoid bringing any additional vulnerability to the product, the only secret token used by the must-gather-api service is the one passed in parameters with API request. The token is validated against OpenShift authentication service and used with the oc adm must-gather execution.

Demo

An example of CLI interaction with the must-gather-api:

 

Video description: Gathering debugging information from the OpenShift cluster can easily be done with a must-gather feature. A shared must-gather functionality within the oc command line tool and customizable images for each project can extract information via this feature.This example shows Forklift must-gather API service command line usage with curl.

Conclusion

The feature described above is part of Migration Toolkit for Virtualization 2.2.0 release. It allows users to get a must-gather archive directly from the UI (click a “Get logs” button), and the backend service is ready to be re-used in other projects that use OpenShift must-gather functionality.

For further information check the project repository here.


저자 소개

UI_Icon-Red_Hat-Close-A-Black-RGB

채널별 검색

automation icon

오토메이션

기술, 팀, 인프라를 위한 IT 자동화 최신 동향

AI icon

인공지능

고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트

open hybrid cloud icon

오픈 하이브리드 클라우드

하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요

security icon

보안

환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보

edge icon

엣지 컴퓨팅

엣지에서의 운영을 단순화하는 플랫폼 업데이트

Infrastructure icon

인프라

세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보

application development icon

애플리케이션

복잡한 애플리케이션에 대한 솔루션 더 보기

Virtualization icon

가상화

온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래