This example demonstrates how to get started with Camel based Knative sources by showing you some of the most important features that you should know before trying to develop more complex examples.
You can find more information about Apache Camel and Apache Camel K on the official Camel website.
Read the general instructions in the root README.md file for setting up your environment and the Kubernetes cluster before looking at this example.
Make sure you've read the installation instructions for your specific cluster before starting the example.
You should open this file with Didact if available on your IDE.
Validate all Requirements at Once!
Kubectl CLI
The Kubernetes kubectl
CLI tool will be used to interact with the Kubernetes cluster.
Check if the Kubectl CLI is installed{.didact}
Status: unknown{#kubectl-requirements-status}
Connection to a Kubernetes cluster
You need to connect to a Kubernetes cluster in order to run the example.
Check if you're connected to a Kubernetes cluster{.didact}
Status: unknown{#cluster-requirements-status}
Apache Camel K CLI ("kamel")
You need the Apache Camel K CLI ("kamel") in order to access all Camel K features.
Check if the Apache Camel K CLI ("kamel") is installed{.didact}
Status: unknown{#kamel-requirements-status}
Knative installed on the cluster
The cluster also needs to have Knative installed and working. Refer to the official Knative documentation for information on how to install it in your cluster.
Check if the Knative Serving is installed{.didact}
Status: unknown{#kserving-project-check}
Check if the Knative Eventing is installed{.didact}
Status: unknown{#keventing-project-check}
Knative Camel Source installed on the cluster
The cluster also needs to have installed the Knative Camel Source from the camel.yaml in the Eventing Sources release page
Check if the Knative Camel Source is installed{.didact}
Status: unknown{#kservice-project-check}
The following requirements are optional. They don't prevent the execution of the demo, but may make it easier to follow.
VS Code Extension Pack for Apache Camel
The VS Code Extension Pack for Apache Camel provides a collection of useful tools for Apache Camel K developers, such as code completion and integrated lifecycle management. They are recommended for the tutorial, but they are not required.
You can install it from the VS Code Extensions marketplace.
Check if the VS Code Extension Pack for Apache Camel by Red Hat is installed{.didact}
Status: unknown{#extension-requirement-status}
Let's open a terminal and go to the example directory:
cd 05-knative-source-jira
(^ execute{.didact})
We're going to create a namespace named camel-jira-source
for running the example. To create it, execute the following command:
kubectl create namespace camel-jira-source
(^ execute{.didact})
Now we can set the camel-jira-source
namespace as default namespace for the following commands:
kubectl config set-context --current --namespace=camel-jira-source
(^ execute{.didact})
You need to install Camel K in the camel-jira-source
namespace (or globally in the whole cluster).
In many settings (e.g. OpenShift, CRC), it's sufficient to execute the following command to install Camel K:
kamel install --maven-repository https://maven.atlassian.com/repository/public
(^ execute{.didact})
NOTE: The kamel install
command requires some prerequisites to be successful in some situations, e.g. you need to enable the registry addon on Minikube. Refer to the Camel K install guide for cluster-specific instructions.
We need also add atlassian repository so jira client can be sucessfully downloaded.
To check that Camel K is installed we'll retrieve the IntegrationPlatform object from the namespace:
kubectl get integrationplatform
(^ execute{.didact})
You should find an IntegrationPlatform in status Ready
.
You can now proceed to the next section.
This repository contains a simple jira.properties{.didact} that contains basic configuration properties for the jira component:
jira.url
URL to jira instancejira.username
Username for jirajira.password
- password/access token *jira.jql
- JQL that contains at least PROJECT (PROJECT=CAMEL
)
NOTE: For atlassian cloud jira password can't be used so it's necessary to create an API token and use it instead of user password. https://confluence.atlassian.com/cloud/api-tokens-938839638.html
kubectl create secret generic jira --from-file=jira.properties
(^ execute{.didact})
As the example levareges Knative Eventing channels, we need to create the one that the example will use:
kubectl apply -f jira-channel.yaml
(^ execute{.didact})
This repository contains a simple Camel Source based on the Jira component that sends new comments/issues created in certain jira project. To forward new comments change uri defined in source definiton from uri: jira:newIssues
to uri: jira:newComments
.
Use the following command to deploy the Camel Source:
kubectl apply -f jira-new-issues.yaml
(^ execute{.didact})
kamel run jira-consumer.groovy --dev
(^ execute{.didact})
If everything is ok, after the build phase finishes, you should see the Camel integration running and printing the mesage you have sent to tour Telegram Bot.
To cleanup everything, execute the following command:
kubectl delete namespace camel-jira-source
(^ execute{.didact})