3.4. Camel K 통합 실행


kamel run 명령을 사용하여 명령줄에서 OpenShift 클러스터의 클라우드에서 Camel K 통합을 실행할 수 있습니다.

사전 요구 사항

절차

  1. oc 클라이언트 툴을 사용하여 OpenShift 클러스터에 로그인합니다. 예를 들면 다음과 같습니다.

    $ oc login --token=my-token --server=https://my-cluster.example.com:6443
    Copy to Clipboard Toggle word wrap
  2. Camel K Operator가 실행 중인지 확인합니다. 예를 들면 다음과 같습니다.

    $ oc get pod
    NAME                               READY   STATUS    RESTARTS   AGE
    camel-k-operator-86b8d94b4-pk7d6   1/1     Running   0          6m28s
    Copy to Clipboard Toggle word wrap
  3. kamel run 명령을 입력하여 OpenShift의 클라우드에서 통합을 실행합니다. 예를 들면 다음과 같습니다.

    Java 예

    $ kamel run HelloCamelK.java
    integration "hello-camel-k" created
    Copy to Clipboard Toggle word wrap

    YAML 예

    $ kamel run hello.camelk.yaml
    integration "hello" created
    Copy to Clipboard Toggle word wrap

  4. kamel get 명령을 입력하여 통합 상태를 확인합니다.

    $ kamel get
    NAME       PHASE           KIT
    hello      Building Kit    myproject/kit-bq666mjej725sk8sn12g
    Copy to Clipboard Toggle word wrap

    Camel K는 통합이 처음 실행되면 필요한 모든 Camel 모듈을 다운로드하여 이미지 클래스 경로에 추가하는 컨테이너 이미지의 통합 키트를 빌드합니다.

  5. kamel get 를 다시 입력하여 통합이 실행 중인지 확인합니다.

    $ kamel get
    NAME       PHASE   KIT
    hello      Running myproject/kit-bq666mjej725sk8sn12g
    Copy to Clipboard Toggle word wrap
  6. kamel log 명령을 입력하여 로그를 stdout 에 출력합니다.

    $ kamel log hello
    [1] 2021-08-11 17:58:40,573 INFO  [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 1.7.1.fuse-800025-redhat-00001
    [1] 2021-08-11 17:58:40,653 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
    [1] 2021-08-11 17:58:40,844 INFO  [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='camel-k-embedded-flow', language='yaml', location='file:/etc/camel/sources/camel-k-embedded-flow.yaml', }
    [1] 2021-08-11 17:58:41,216 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup summary (total:1 started:1)
    [1] 2021-08-11 17:58:41,217 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (timer://yaml)
    [1] 2021-08-11 17:58:41,217 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.10.0.fuse-800010-redhat-00001 (camel-1) started in 136ms (build:0ms init:100ms start:36ms)
    [1] 2021-08-11 17:58:41,268 INFO  [io.quarkus] (main) camel-k-integration 1.6.6 on JVM (powered by Quarkus 1.11.7.Final-redhat-00009) started in 2.064s.
    [1] 2021-08-11 17:58:41,269 INFO  [io.quarkus] (main) Profile prod activated.
    [1] 2021-08-11 17:58:41,269 INFO  [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-k-core, camel-k-runtime, camel-log, camel-support-common, camel-timer, camel-yaml-dsl, cdi]
    [1] 2021-08-11 17:58:42,423 INFO  [info] (Camel (camel-1) thread #0 - timer://yaml) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K from yaml]
    ...
    Copy to Clipboard Toggle word wrap
  7. Ctrl-C 를 눌러 터미널에서 로깅을 종료합니다.

추가 리소스

CLI 없이 통합 실행

CLI(Command Line Interface) 없이 통합을 실행하고 구성과 함께 Integration Custom Resource 를 만들어 애플리케이션을 실행할 수 있습니다.

예를 들어 다음 샘플 경로를 실행합니다.

kamel run Sample.java -o yaml
Copy to Clipboard Toggle word wrap

예상 통합 사용자 지정 리소스를 반환합니다.

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  creationTimestamp: null
  name: my-integration
  namespace: default
spec:
  sources:
  - content: "
    import org.apache.camel.builder.RouteBuilder;
    public class Sample extends RouteBuilder {
      @Override
      public void configure()
      throws Exception {
        from(\"timer:tick\")
        .log(\"Hello Integration!\");
       }
      }"
    name: Sample.java
status: {}
Copy to Clipboard Toggle word wrap

이 사용자 지정 리소스를 yaml 파일 my-integration.yaml 에 저장합니다. 이제 oc 명령줄, UI 또는 OpenShift 클러스터를 호출할 API를 사용하여 Integration Custom Resource가 포함된 통합을 실행합니다. 다음 예에서는 명령줄에서 oc CLI를 사용합니다.

oc apply -f my-integration.yaml
...
integration.camel.apache.org/my-integration created
Copy to Clipboard Toggle word wrap

Operator는 통합을 실행합니다.

참고

사용자 정의 리소스의 스키마 변경

강력한 형식의 Trait API는 다음 CustomResourceDefinitions에 변경 사항을 적용합니다. 통합, 통합kits', 'integrationplatforms).

spec.traits.<trait-id>.configuration 아래의 특성 속성은 이제 spec.traits.<trait-id>에서 직접 정의됩니다.

traits:
  container:
    configuration:
      enabled: true
      name: my-integration
Copy to Clipboard Toggle word wrap

↓↓↓

traits:
  container:
    enabled: true
    name: my-integration
Copy to Clipboard Toggle word wrap

이 구현에서는 이전 버전과의 호환성이 가능합니다. 이전 버전과의 호환성을 위해 기존 통합 및 리소스를 새 Camel K 버전에서 읽을 수 있도록 각 특성 유형에 대해 RawMessage 유형의 Configuration 필드가 제공됩니다.

이전 통합 및 리소스를 읽을 때 각 특성(있는 경우)의 레거시 구성이 새 Trait API 필드로 마이그레이션됩니다. 새 API 필드에 값이 사전 정의된 경우 기존 API보다 우선합니다.

type Trait struct {
    // Can be used to enable or disable a trait. All traits share this common property.
    Enabled *bool `property:"enabled" json:"enabled,omitempty"`

    // Legacy trait configuration parameters.
    // Deprecated: for backward compatibility.
    Configuration *Configuration `json:"configuration,omitempty"`
}

// Deprecated: for backward compatibility.
type Configuration struct {
    RawMessage `json:",inline"`
}
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat