Tutorial: Deploy Camel-K on Openshift 4 using Tekton

Erfin Feluzy
3 min readJul 12, 2020

--

Tekton is an open source project that provides a framework to create cloud-native CI/CD pipelines quickly. As a Kubernetes-native framework, Tekton makes it easier to deploy across multiple cloud providers or hybrid environments. By leveraging the Custom Resource Definitions (CRDs) in Kubernetes, Tekton uses the Kubernetes control plane to run pipeline tasks. By using standard industry specifications, Tekton will work well with existing CI/CD tools such as Jenkins, Jenkins X, Skaffold, and Knative.[1]

Apache Camel K is a lightweight cloud-integration platform that runs natively on Kubernetes and, in particular, lets you automate your cloud configurations. Based on the famous Apache Camel, Camel K is designed and optimized for serverless and microservices architectures.[2]

This article will guide you to deploy sample camel-K application, written in groovy, to Red Hat OpenShift 4 using OpenShift Pipeline based on Tekton.

Prerequisite

This tutorial assumes the following requirements are met:

  • OpenShift 4+ cluster and oc binary tool. See docs here.
  • Openshift Pipeline Operator. See docs here.
  • Camel K Client Tools — Kamel. See docs here.
  • Optional: Tekton CLI. See docs here.

Login to OpenShift

oc login $OCP_CONSOLE

Step 1: Cluster setup

This step will install camel operator on your ocp cluster

kamel install --cluster-setup

Step 2: Create namespace

$ oc new-project camel-pipelines

Step 3: Create permission for serviceaccounts

Use this file on assets/camel-k-pipeline-permissions.yaml

$ oc apply -f camel-k-pipeline-permissions.yaml

Step 4: Create tekton pipeline

Use this file on assets/camel-k-pipeline-task-definition.yaml

$ oc apply -f camel-k-pipeline-task-definition.yaml

pipeline result below:

source code for camel-k groovy here:

from(‘timer:groovy?period=1000’)
.log(‘Hello Camel K from Tekton pipelines’)

Step 5: Triggering a Pipeline execution

Use this file on assets/pipeline-task-run.yaml

oc apply -f camel-k-pipeline-task-run.yaml

This files contains:

apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: camel-k-pipeline-run-1
spec:
pipelineRef:
name: camel-k-pipeline
serviceAccountName: 'camel-k-pipeline'
resources:
- name: source-repo
resourceRef:
name: camel-k-examples-git

Notes: originally it used field serviceAccount, changed to serviceAccountName due to error on tekton parsing the field serviceAccount

After successfully build and deploy, you can find deployed apps on Topology

Step 6 (Optional) : see your deployment using Tekton cli

$ tkn pipeline ls

result will be something like this

NAME               AGE          LAST RUN                  STARTED      DURATION    STATUS
camel-k-pipeline 1 hour ago camel-k-pipeline-d4vyhr 1 hour ago 3 minutes Succeeded

Source

--

--

Erfin Feluzy
Erfin Feluzy

Written by Erfin Feluzy

Kuli Ketik dan AppDev Solution Architect at Red Hat. Eat, Code, Sleep — repeat.