5.2. API 서비스 주석 값 사용자 정의
Maven Fabric8 플러그인은 기본적으로 Fabric8 Service Discovery Enricher를 실행합니다. Red Hat 3scale API Management 관리 포털 가이드 가이드 의 Service Discovery 사용에 설명된 대로 Fuse Rest DSL 프로젝트의 API 서비스에 주석을 추가하여 API 서비스를 3scale에서 검색할 수 있습니다.
강화자는 일부 주석에 기본값을 사용하고 프로젝트의 camel-context.xml 파일에서 다른 주석의 값을 가져옵니다.
Fuse 프로젝트 pom.xml 파일 또는 service.yml 파일에서 값을 정의하여 camel-context.xml 파일에 정의된 기본값과 값을 재정의할 수 있습니다. (두 파일에 값을 정의하면 보강자는 service.yml 파일의 값을 사용합니다.) Fabric8 Service Discovery Enricher 에서 Fabric8 Service Discovery Enricher에 지정할 수 있는 요소에 대한 설명은 Fabric8 Service Discovery Enricher 요소를 참조하십시오.
절차
Fuse 프로젝트 pom.xml 파일에 주석 값을 지정하려면 다음을 수행합니다.
-
선택한 편집기에서 Fuse 프로젝트의
pom.xml파일을 엽니다. 다음 예와 같이
openshift-maven-plugin종속성을 찾습니다.<plugin> <groupId>org.jboss.redhat-fuse</groupId> <artifactId>openshift-maven-plugin</artifactId> <version>${fuse.version}</version> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions> </plugin>다음 예와 같이 Fabric8 Service Discovery Enricher를 openshift-maven 플러그인에 종속성으로 추가합니다.
<plugin> <groupId>org.jboss.redhat-fuse</groupId> <artifactId>openshift-maven-plugin</artifactId> <version>${fuse.version}</version> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>io.acme</groupId> <artifactId>myenricher</artifactId> <version>1.0</version> <configuration> <enricher> <config> <f8-service-discovery> <scheme>https</scheme> <path>/api</path> <descriptionPath>/api/openapi.json</descriptionPath> </f8-service-discovery> </config> </enricher> </configuration> </dependency> </dependencies> </plugin>- 변경 사항을 저장하십시오.
또는 다음 예와 같이 src/main/fabric8/service.yml 조각을 사용하여 주석 값을 덮어쓸 수 있습니다.
kind: Service
name:
metadata:
labels:
discovery.3scale.net/discoverable : "true"
annotations:
discovery.3scale.net/discovery-version : "v1"
discovery.3scale.net/scheme : "https"
discovery.3scale.net/path : "/api"
discovery.3scale.net/port : "443"
discovery.3scale.net/description-path : "/api/openapi.json"
spec:
type: LoadBalancer