This blog shows, how to install postgres, kafka and redis on a Kubernetes cluster here SAP® KYMA.
Enable SAP BTP, Kyma Runtime | SAP Tutorials
Got to the SAP BTP site: https://account.hanatrial.ondemand.com/
Install local tools
Install Ubuntu on WSL2 and get started with graphical applications Install kubectl
Installing prerequisite tools
- Postgres DB
kubectl apply -f ./Step1_Setup/k8s/postgres
- Test Postgres
- kubectl exec -it <postgres_pod> -- psql -U postgres
Find useful commands for postgres here
-
Kafka, Zookeeper, AKQH
Before deployment, update the HOSTNAME in the /k8s/kafka/akhq-api-rule.yaml file.
Get the hostname as in the screenshot:
kubectl get gateway kyma-gateway -n kyma-system -o=jsonpath='{.spec.servers[0].hosts[0]}'
Then apply the .yaml files.
kubectl apply -f ./Step1_Setup/k8s/kafka
- Redis
kubectl apply -f ./Step1_Setup/k8s/redis
Update the config in .kube environment
-
Copy the kubeconfig URL from the BTP Site, download the file
-
Rename the file to config and put it in the .kube directory (in your home directory)
Copy the kubeconfig URL and
Test the Kafka Connection
-Deploy testclient
kubectl apply -f testclient.yaml
-Create Topic
kubectl exec -ti testclient -- ./bin/kafka-topics.sh --zookeeper zookeeper:32181 --topic messages --create --partitions 1 --replication-factor 1
-Check Topic
kubectl exec -ti testclient -- ./bin/kafka-topics.sh --zookeeper zookeeper:32181 --list
-Create a listener for the topic ( open a new terminal session for this)
kubectl exec -ti testclient -- ./bin/kafka-console-consumer.sh --bootstrap-server kafka:29092 --topic messages --from-beginning
-Create a producer for the topic ( open a new terminal session for this)
kubectl exec -ti testclient -- ./bin/kafka-console-producer.sh --broker-list kafka:29092 --topic messages
Enter a message in the producer terminal session, this should be shown in the listener session.
Test the AKHQ Website
The AKQH website shows the topics created. You have to forward the local port, here to 9090 local
kubectl port-forward <akhq-pod> localport:8080
Open your browser and enter the URL
localhost:9090/akhq
Code is available from Github Repository: Github