7.4. 동적 플러그인 예
예제를 수행하기 전에 동적 플러그인 개발의 단계에 따라 플러그인이작동하는지 확인합니다.
7.4.1. 포드 페이지에 탭 추가
OpenShift Container Platform 웹 콘솔에 다양한 사용자 지정이 있습니다. 다음 절차에서는 플러그인의 확장 예제로 Pod 세부 정보 페이지에 탭을 추가합니다.
OpenShift Container Platform 웹 콘솔은 로그인한 클러스터에 연결된 컨테이너에서 실행됩니다. 자체 만들기 전에 플러그인을 테스트하는 정보는 "Dynamic plugin development"를 참조하십시오.
절차
새 탭에서 플러그인을 생성하는 템플릿이 포함된
console-plugin-template
리포지터리를 방문하십시오.중요Red Hat에서는 사용자 정의 플러그인 코드를 지원하지 않습니다. 해당 플러그인에 대해 협업 커뮤니티 지원 만 사용할 수 있습니다.
- Use this template 드롭다운 버튼을 선택하고 드롭다운 목록에서 Create new repository 를 선택하여 GitHub 리포지토리를 생성합니다.
- 새 리포지토리의 이름을 플러그인 이름으로 다시 지정합니다.
- 복사한 리포지토리를 로컬 시스템에 복제하여 코드를 편집할 수 있습니다.
package.json
의consolePlugin
선언에서 플러그인 메타데이터를 편집합니다."consolePlugin": { "name": "my-plugin", 1 "version": "0.0.1", 2 "displayName": "My Plugin", 3 "description": "Enjoy this shiny, new console plugin!", 4 "exposedModules": { "ExamplePage": "./components/ExamplePage" }, "dependencies": { "@console/pluginAPI": "/*" } }
console-extensions.json
파일에 다음을 추가합니다.{ "type": "console.tab/horizontalNav", "properties": { "page": { "name": "Example Tab", "href": "example" }, "model": { "group": "core", "version": "v1", "kind": "Pod" }, "component": { "$codeRef": "ExampleTab" } } }
package.json
파일을 편집하여 다음 변경 사항을 포함합니다."exposedModules": { "ExamplePage": "./components/ExamplePage", "ExampleTab": "./components/ExampleTab" }
새 파일
src/components/ExampleTab.tsx
를 생성하고 다음 스크립트를 추가하여 Pod 페이지의 새 사용자 지정 탭에 표시할 메시지를 작성합니다.import * as React from 'react'; export default function ExampleTab() { return ( <p>This is a custom tab added to a resource using a dynamic plugin.</p> ); }
검증
- Pod 페이지를 방문하여 추가된 탭을 확인합니다.