View README.adoc @ 17:a0d0419a8055

Added comments
author unexist
date Thu, 16 Sep 2021 17:54:22 +0200
parents 6b84781f3f5a
children 6f95fb92b770
line wrap: on
line source
                    
= Showcase for knative eventing based on camel and quarkus

This project holds a showcase knative eventing with camel and quarkus.

== Create Minikube cluster

```shell
minikube start --driver=virtualbox --cpus=4 --memory=8192m
minikube addons enable metrics-server
minikube addons enable registry
minikube addons enable istio-provisioner
minikube addons enable istio
minikube tunnel & #< Asks for sudo password!
```

== Install Knative

```shell
kubectl apply -f https://github.com/knative/operator/releases/download/v0.25.0/operator.yaml
```

```shell
kubectl apply -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
    name: knative-eventing
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
    name: knative-eventing
    namespace: knative-eventing
---
apiVersion: v1
kind: Namespace
metadata:
    name: knative-serving
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
    name: knative-serving
    namespace: knative-serving
EOF
```

```shell
kubectl apply -f https://github.com/knative/serving/releases/download/v0.25.0/serving-default-domain.yaml
```

== Install Kourier and configure DNS

```shell
kubectl apply -f https://github.com/knative/net-kourier/releases/download/v0.25.0/kourier.yaml

EXTERNAL_IP=$(kubectl -n kourier-system get service kourier -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo EXTERNAL_IP=$EXTERNAL_IP

KNATIVE_DOMAIN="$EXTERNAL_IP.nip.io"
echo KNATIVE_DOMAIN=$KNATIVE_DOMAIN

kubectl patch configmap -n knative-serving config-domain -p "{\"data\": {\"$KNATIVE_DOMAIN\": \"\"}}"

kubectl patch configmap/config-network \
  --namespace knative-serving \
  --type merge \
  --patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'
```

== Install Knative CLI

```shell
brew install knative/client/kn
```

== Verify installation

=== Check knative-eventing

```shell
kubectl get KnativeEventing knative-eventing -n knative-eventing

NAME               VERSION   READY   REASON
knative-eventing   0.25.0    True

kubectl get deployment -n knative-eventing
```

=== Check knative-serving

```shell
kubectl get KnativeServing knative-serving -n knative-serving

NAME              VERSION   READY   REASON
knative-serving   0.25.0    True

kubectl get deployment -n knative-serving
```

=== Check logs of the operator

```shell
kubectl logs -f deploy/knative-operator
```

== Install Kamel

```shell
brew install kamel
kamel install --olm=false
```

== Install Kafka

```shell
kubectl create namespace kafka
kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka
kubectl apply -f https://strimzi.io/examples/latest/kafka/kafka-persistent-single.yaml -n kafka
```

== Install Redpanda

```shell
kubectl apply -f - <<EOF

EOF
```

```shell
kubectl apply -f https://github.com/knative-sandbox/eventing-kafka-broker/releases/download/v0.25.0/eventing-kafka-controller.yaml
kubectl apply -f https://github.com/knative-sandbox/eventing-kafka-broker/releases/download/v0.25.0/eventing-kafka-broker.yaml
kubectl apply -f https://storage.googleapis.com/knative-releases/eventing-contrib/latest/kafka-source.yaml
```

```shell
kubectl apply -f - <<EOF
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
    annotations:
        eventing.knative.dev/broker.class: Kafka
    name: default
    namespace: default
spec:
    config:
        apiVersion: v1
        kind: ConfigMap
        name: kafka-broker-config
        namespace: knative-eventing
EOF
```

```shell
kubectl apply -f - <<EOF
apiVersion: sources.knative.dev/v1beta1
kind: KafkaSource
metadata:
  name: kafka-source-todo
spec:
  bootstrapServers:
    - redpanda:9092
  topics:
    - todo-created
  sink:
    ref:
      apiVersion: eventing.knative.dev/v1
      kind: Broker
      name: default
---
apiVersion: bindings.knative.dev/v1beta1
kind: KafkaBinding
metadata:
  name: kafka-binding-todo
spec:
  subject:
    apiVersion: serving.knative.dev/v1
    kind: Service
    name: todo
  bootstrapServers:
    - redpanda:9092
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: todo-trigger
spec:
  broker: default
  filter:
    attributes:
      type: dev.knative.kafka.event
      source: /apis/v1/namespaces/default/kafkasources/kafka-source-todo#todo-created
  subscriber:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: todo
    uri: /todo/create
EOF
```

== Problems

=== Broker cannot be reached from Camel

```Log
 [Producer clientId=producer-1] Connection to node 1 (/0.0.0.0:9092) could not be established. Broker may not be available.
```

=== External IP pending

kubectl -n kourier-system get service kourier

> minikube tunnel asks for a password which I wasn't aware of.

=== Knative-serving is not ready

```
kubectl get KnativeServing knative-serving -n knative-serving

NAME              VERSION   READY   REASON
knative-serving             False   Error
```

> Istio is missing, check the operator logs.

=== Subject missing in kafka binding

```shell
kubectl get kafkabindings.bindings.knative.dev

NAME                 BOOTSTRAPSERVERS    READY   REASON           AGE
kafka-binding-todo   ["redpanda:9092"]   False   SubjectMissing   3h58m
```

== Links

=== Knative

- https://piotrminkowski.com/2021/06/14/knative-eventing-with-quarkus-kafka-and-camel/
- https://knative.dev/docs/admin/install/knative-with-operators/
- https://docs.openshift.com/container-platform/4.6/serverless/event_sources/serverless-kafka-source.html

=== Minikube

- https://github.com/csantanapr/knative-minikube

=== Kafka

- https://vectorized.io/docs/quick-start-kubernetes/
- https://github.com/piomin/sample-quarkus-serverless-kafka

=== Apache Camel

- https://camel.apache.org/docs/
- https://www.awstutorials.cloud/post/tutorials/camel-k-on-minikube/
- https://piotrminkowski.com/2020/12/08/apache-camel-k-and-quarkus-on-kubernetes/