Knative Tutorial

Prerequisite CLI tools

Apart from the tools you have installed, you might need few more for camelk sections of the tutorial.

Tool macOS Fedora Remarks

AWS CLI

install-macos

install-linux

Demo Sources

All the demo sources that will be used in the chapters of this module are available under $TUTORIAL_HOME/advanced/camel-k folder.

cp $TUTORIAL_HOME/advanced/camel-k

Install Applications

Navigate to the apps folder:

cd $TUTORIAL_HOME/apps

Install minio s3 Object Storage Server

We will use s3 Object storage for all File Transfer integration style exercises and demos. The following section shows how to setup minio a light weight AWS s3 compatible object storage server.

  • kubectl

  • oc

kubectl apply --namespace knativetutorial \
 --filename minio-s3-server/skaffold.yaml

oc apply --namespace knativetutorial \
 --filename minio-s3-server/skaffold.yaml

It may take few minutes for pods to come up, you can watch the status of the pods as shown below. You can use CTRL+c to terminate the watch

  • kubectl

  • oc

kubectl -n knativetutorial get pods -w

oc -n  knativetutorial get pods -w

A successful deployment of the minio server will show the following pods:

# kubectl -n knativetutorial get pods
NAME                            READY   STATUS    RESTARTS   AGE
minio-server-66449f64bf-dtkch   1/1     Running   0          1m

The mino server exposes a web interface for managing the storage objects. To know the url of the web interface, run the following command:

  • minikube

  • minishift

minikube service list -n {tutorial-namespace}

minishift openshift service list -n knativetutorial

Executing the command above shows an output like:

|-----------------|--------------|----------------------------|
|    NAMESPACE    |     NAME     |            URL             |
|-----------------|--------------|----------------------------|
| knativetutorial | minio-server | http://192.168.64.44:31565 |
|-----------------|--------------|----------------------------|
  • The actual port and ip in the URL might change in your setup

  • The default username and password is demoaccesskey/demosecretkey

Opening the url on your browser will show minio Object storage browser as shown below:

minio server browser

The official minio documentation is available here.

Configure s3 aws cli for minio

aws configure
# AWS Access Key ID [None]: demoaccesskey (1)
# AWS Secret Access Key [None]: demosecretkey (2)
# Default region name [None]:
# Default output format [None]:

aws configure set default.s3.signature_version s3v4 (3)

aws configure list (4)
1 Using default user access key demoaccesskey
2 Using default user secret key demosecretkey
3 Enable AWS Signature Version '4' for minio server
4 List the configuration

Install Camel-k

Download the latest camel-k release from here. Extract the content and add the binary kamel to the PATH.

As of building this tutorial the latest kamel version was 0.3.3

Run the following commands to install the camel-k operator in the Kubernetes/OpenShift cluster:

kamel install -n knativetutorial

includepartial$wait-for-pods.adoc[tag=wait-with-kubectl]

The camel-k install will take some time, please wait for the successful installation before proceeding to the further sections of this tutorial.

A successful camel-k setup will have the following pods running/completed in knativetutorial namespace:

# kubectl -n knativetutorial get pods | grep camel
camel-k-cache                                              0/1     Completed   0          10h
camel-k-ctx-bhq1ddi92mi5b779io60                           0/1     Completed   0          10h
camel-k-groovy                                             0/1     Completed   0          10h
camel-k-jvm                                                0/1     Completed   0          10h
camel-k-knative                                            0/1     Completed   0          10h
camel-k-kotlin                                             0/1     Completed   0          10h
camel-k-operator-789b988bd9-9gzjn                          1/1     Running     0          10h
camel-k-spring-boot                                        0/1     Completed   0          10h

If you have a local nexus or artifactory repository managers, then you cane set them as part of the camel-k install. This will make all the camel-k runtime and integration maven builds to use the repository manager.

e.g. assuming you have nexus repository manager and is available at http://192.168.64.1:8081/nexus/content/groups/public

kamel install -n knativetutorial \
  --repository="http://192.168.64.1:8081/nexus/content/groups/public@id=public@snapshots"

Check here for more details on using maven repositories with camel-k.

Configure Local Container Registry

When camel-k builds the images, it pushes built container image to the local registry of the kubernetes cluster. Knative by default resolves all the tags of the container image to digests(SHA256), to be able to do this we need to have images pushed to real time container registry and repository, for these demos we will be using the local container registry that will be part of the minikube or minishift setup. Run the following commands to make Knative skip tag to digest resolution for local images from local registry.

  • kubectl

  • oc

K8S_LOCAL_REGISTRY=`kubectl get svc -n kube-system registry -ojsonpath='{.spec.clusterIP}'` && \
val="${K8S_LOCAL_REGISTRY}" && \
kubectl -n knative-serving get cm config-controller -oyaml \
  | yq w - data.registriesSkippingTagResolving $val \
  | kubectl apply -f -

K8S_LOCAL_REGISTRY=`oc get svc -n kube-system registry -ojsonpath='{.spec.clusterIP}'` && \
val="${K8S_LOCAL_REGISTRY}" && \
oc -n knative-serving get cm config-controller -oyaml \
  | yq w - data.registriesSkippingTagResolving $val \
  | oc apply -f -