Skip to content

Testing Pravega cluster on Kubernetes with Pravega Samples

Adrián Moreno edited this page Oct 23, 2018 · 3 revisions

Assuming you have a working Pravega cluster deployed using the operator, we are going to use a code sample from the Pravega samples repository to write and read from our Pravega cluster.

First, let's take note of our controller IP.

$ kubectl get svc | grep pravega
pravega-bookie-headless                ClusterIP   None            <none>        3181/TCP                                 20m
pravega-pravega-controller             ClusterIP   10.31.247.134   <none>        10080/TCP,9090/TCP                       20m

Our Pravega controller is running on 10.31.247.134.

Let's create a simple Java container that will run an infinite loop to avoid its termination. This will allow us to ssh into the container and run our samples.

Create a container.yaml with the following content.

apiVersion: v1
kind: Pod
metadata:
  name: pravega-samples
spec:
  containers:
  - name: pravega-samples
    image: openjdk:8
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]

Create the pravega-samples Pod.

$ kubectl create -f container.yaml

Wait until the Pod is running.

$ kubectl get pod pravega-samples
NAME              READY     STATUS    RESTARTS   AGE
pravega-samples   1/1       Running   0          9m

SSH into the container.

$ kubectl exec -it pravega-samples -- /bin/bash
root@pravega-samples:/#

Inside the container, clone the Pravega samples repository.

$ git clone https://github.com/pravega/pravega-samples.git

CD into the pravega-samples directory and build the samples using Gradle.

$ cd pravega-samples/
$ ./gradlew clean installDist

You can run any of the samples. As an example, we are going to run the HelloWorld sample.

CD into the bin directory, where all the sample binaries are placed.

$ cd pravega-client-examples/build/install/pravega-client-examples/bin/

Write a message into a stream.

Remember to replace the IP with your controller's IP.

$ ./helloWorldWriter -u tcp://10.31.247.134:9090

Writing message: 'hello world' with routing-key: 'helloRoutingKey' to stream 'examples / helloStream'

And now we are going to read it back.

$ ./helloWorldReader -u tcp://10.31.247.134:9090

Reading all the events from examples/helloStream
Read event 'hello world'
No more events from examples/helloStream
Clone this wiki locally