avatarIvan Franchin

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

8083

Abstract

matchLabels:</span> <span class="hljs-attr">app:</span> <span class="hljs-string">news-producer</span> <span class="hljs-attr">template:</span> <span class="hljs-attr">metadata:</span> <span class="hljs-attr">labels:</span> <span class="hljs-attr">app:</span> <span class="hljs-string">news-producer</span> <span class="hljs-attr">spec:</span> <span class="hljs-attr">containers:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">news-producer</span> <span class="hljs-attr">image:</span> <span class="hljs-string">news-producer:0.0.1-SNAPSHOT</span> <span class="hljs-attr">imagePullPolicy:</span> <span class="hljs-string">Never</span> <span class="hljs-attr">ports:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">http</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">8080</span> <span class="hljs-attr">env:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">KAFKA_HOST</span> <span class="hljs-attr">value:</span> <span class="hljs-string">kafka.dev.svc.cluster.local</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">KAFKA_PORT</span> <span class="hljs-attr">value:</span> <span class="hljs-string">"9092"</span> <span class="hljs-attr">livenessProbe:</span> <span class="hljs-attr">httpGet:</span> <span class="hljs-attr">path:</span> <span class="hljs-string">/actuator/health/liveness</span> <span class="hljs-attr">port:</span> <span class="hljs-string">http</span> <span class="hljs-attr">readinessProbe:</span> <span class="hljs-attr">httpGet:</span> <span class="hljs-attr">path:</span> <span class="hljs-string">/actuator/health/readiness</span> <span class="hljs-attr">port:</span> <span class="hljs-string">http</span></pre></div><p id="18ed">This YAML file sets up a News Producer service and deployment. The service is a <code>LoadBalancer</code>, exposing the port <code>8080</code> for external access. The deployment creates a single pod with the <code>news-producer:0.0.1-SNAPSHOT</code> image and configuration, connecting to a Kafka message broker. The configuration includes liveness and readiness probes.</p><h2 id="ec25">Create News Consumer YAML Deployment file</h2><p id="174c">Inside the <code>k8s</code> folder, let’s create a file named <code>news-consumer.yaml</code> and include the content below:</p><div id="e408"><pre><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span> <span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span> <span class="hljs-attr">metadata:</span> <span class="hljs-attr">name:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-attr">labels:</span> <span class="hljs-attr">app:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-attr">spec:</span> <span class="hljs-attr">type:</span> <span class="hljs-string">ClusterIP</span> <span class="hljs-attr">ports:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">port:</span> <span class="hljs-number">9080</span> <span class="hljs-attr">selector:</span> <span class="hljs-attr">app:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-meta">---</span> <span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span> <span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span> <span class="hljs-attr">metadata:</span> <span class="hljs-attr">name:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-attr">spec:</span> <span class="hljs-attr">replicas:</span> <span class="hljs-number">3</span> <span class="hljs-attr">selector:</span> <span class="hljs-attr">matchLabels:</span> <span class="hljs-attr">app:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-attr">template:</span> <span class="hljs-attr">metadata:</span> <span class="hljs-attr">labels:</span> <span class="hljs-attr">app:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-attr">spec:</span> <span class="hljs-attr">containers:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">news-consumer</span> <span class="hljs-attr">image:</span> <span class="hljs-string">news-consumer:0.0.1-SNAPSHOT</span> <span class="hljs-attr">imagePullPolicy:</span> <span class="hljs-string">Never</span> <span class="hljs-attr">ports:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">http</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">9080</span> <span class="hljs-attr">env:</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">KAFKA_HOST</span> <span class="hljs-attr">value:</span> <span class="hljs-string">kafka.dev.svc.cluster.local</span> <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">KAFKA_PORT</span> <span class="hljs-attr">value:</span> <span class="hljs-string">"9092"</span> <span class="hljs-attr">livenessProbe:</span> <span class="hljs-attr">httpGet:</span> <span class="hljs-attr">path:</span> <span class="hljs-string">/actuator/health/liveness</span> <span class="hljs-attr">port:</span> <span class="hljs-string">http</span> <span class="hljs-attr">readinessProbe:</span> <span class="hljs-attr">httpGet:</span> <span class="hljs-attr">path:</span> <span class="hljs-string">/actuator/health/readiness</span> <span class="hljs-attr">port:</span> <span class="hljs-string">http</span></pre></div><p id="7c80">This YAML file sets up a News Consumer service and deployment. The service makes the application accessible within the cluster via <code>ClusterIP</code>. The deployment creates three pods with the <code>news-consumer:0.0.1-SNAPSHOT</code> image and configuration, connecting to a Kafka message broker. The configuration includes liveness and readiness probes.</p><h1 id="26e4">Installing Bitnami Helm Repo</h1><p id="b430">In order to run Kafka, we will use the <a href="https://github.com/bitnami"><b>Bitnami Helm Charts</b></a>. So, in a terminal, let’s add the <code>bitnami</code> repo by running the following command:</p><div id="eda8"><pre>helm repo add bitnami https://charts.bitnami.com/bitnami</pre></div><blockquote id="0a59"><p>To delete the <code>bitnami</code> repo, run: <code>helm repo remove bitnami</code></p></blockquote><p id="9087">In order to check the repo list, run:</p><div id="1d43"><pre>helm repo list</pre></div><p id="fb54">Finally, run the command below to get the latest information about charts from the chart repositories:</p><div id="c1a8"><pre>helm repo update</pre></div><h1 id="697a">Start Environment</h1><p id="2bcc">In a terminal, make sure you are in the <code>news-app</code> root folder.</p><h2 id="05de">Start Minikube</h2><p id="57d1">Run the following command to start Minikube:</p><div id="59f1"><pre>minikube start --memory=8192 --cpus=2 --vm-driver=virtualbox</pre></div><h2 id="f446">Create dev namespace</h2><p id="6814">Once Minikube is up and running, let’s create a namespace called <code>dev</code>. For it, run the command below:</p><div id="94d7"><pre>kubectl create namespace dev</pre></div><blockquote id="4c52"><p>To delete the <code>dev</code> namespace, run: <code>kubectl delete namespace dev</code></p></blockquote><h2 id="96d9">Deploy Kafka</h2><p

Options

id="86a2">Let’s deploy Kafka. For it, make sure you are in <code>news-app</code> root folder. The, run the following command:</p><div id="d6b2"><pre>helm -n dev install kafka bitnami/kafka --<span class="hljs-built_in">set</span> listeners.client.protocol=PLAINTEXT</pre></div><blockquote id="97bf"><p>To delete the Kafka installation, run: <code>helm uninstall -n dev kafka</code></p></blockquote><h2 id="3ba5">Watch Kafka Deployment</h2><p id="33e5">We can watch the deployment by running the following command:</p><div id="7e4e"><pre>kubectl -n dev get pods -w</pre></div><blockquote id="5a30"><p>To stop watching, press: <code>Ctrl+C</code></p></blockquote><p id="1a60">Please be patient as Kafka Docker image will be pulled before we can proceed further. After a few seconds, the Kafka instances should be up and running. To confirm this, you can use the following command:</p><div id="f0f1"><pre>kubectl -n dev get pods</pre></div><p id="37c6">You should see something like:</p><div id="ace2"><pre>NAME READY STATUS RESTARTS AGE kafka-controller-0 1/1 Running 0 4m34s kafka-controller-1 1/1 Running 0 4m34s kafka-controller-2 1/1 Running 0 4m34s</pre></div><h1 id="4f3a">Building News App Docker images</h1><p id="a7d6">In a terminal, let’s execute the following command to sets up our local Docker environment to use Minikube’s Docker daemon:</p><div id="1978"><pre><span class="hljs-built_in">eval</span> (minikube docker-env)</pre></div><p id="3d38">Navigate to the <code>news-procucer</code> folder. Run the command below to build the News Producer Docker image:</p><div id="918a"><pre>./mvnw clean spring-boot:build-image -DskipTests</pre></div><p id="3784">Let’s build the News Consumer Docker image. For it, navigate to <code>news-consumer</code> folder. Once there, run the following command:</p><div id="0a56"><pre>./mvnw clean spring-boot:build-image -DskipTests</pre></div><p id="709b">After the completion of the commands above, the News Producer and Consumer Docker images will be available within Minikube. You can verify this by executing the following command:</p><div id="a93a"><pre>docker images</pre></div><p id="05ee">Let’s switch back to our local host Docker daemon by running the command below:</p><div id="6e36"><pre><span class="hljs-built_in">eval</span> (minikube docker-env -u)</pre></div><h1 id="a508">Deploying News Apps</h1><p id="a217">In a terminal, ensure that you are in the <code>news-app</code> root folder. Then, execute the following command to deploy the News Producer:</p><div id="4a33"><pre>kubectl -n dev apply -f k8s/news-producer.yaml</pre></div><blockquote id="3457"><p>To delete the <code>news-producer</code> deployment, run: <code>kubectl -n dev delete -f k8s/news-producer.yaml</code></p></blockquote><p id="cbb5">Now, let’s deploy the News Consumer by running the command below:</p><div id="f881"><pre>kubectl -n dev apply -f k8s/news-consumer.yaml</pre></div><blockquote id="4c0e"><p>To delete the <code><i>news-consumer</i></code> deployment, run: <code><i>kubectl -n dev delete -f k8s/news-consumer.yaml</i></code></p></blockquote><p id="6698">After a few seconds, the single News Producer instance and three News Consumer instances should be up and running. To confirm this, you can use the following command:</p><div id="394c"><pre>kubectl -n dev get pods</pre></div><p id="b3ec">You should see something like:</p><div id="34db"><pre>NAME READY STATUS RESTARTS AGE kafka-controller-0 1/1 Running 0 13m kafka-controller-1 1/1 Running 0 13m kafka-controller-2 1/1 Running 0 13m news-consumer-69cd94fb64-4p2pk 1/1 Running 0 15s news-consumer-69cd94fb64-k6nd4 1/1 Running 0 15s news-consumer-69cd94fb64-rm8v7 1/1 Running 0 15s news-producer-5bc75c69c9-88vfs 1/1 Running 0 23s</pre></div><h1 id="dc4d">Sending News</h1><p id="e1e5">In a terminal, let’s start monitoring the logs of the three News Consumer instances:</p><div id="92ce"><pre>kubectl -n dev logs -l app=news-consumer -f</pre></div><p id="e056">In another terminal, run the following command to get the <code>NEWS_PRODUCER_HOST_PORT</code>:</p><div id="48fa"><pre>NEWS_PRODUCER_HOST_PORT=<span class="hljs-string">"<span class="hljs-subst">(minikube ip)</span>:<span class="hljs-subst">(kubectl get services -n dev news-producer -o go-template='{{(index .spec.ports 0)</span>.nodePort}}')"</span> <span class="hljs-built_in">echo</span> <span class="hljs-variable">NEWS_PRODUCER_HOST_PORT</span></pre></div><p id="a129">In the same terminal where <code>NEWS_PRODUCER_HOST_PORT</code> was obtained, let’s send one news by executing the command below:</p><div id="7cfa"><pre>curl -i -X POST <span class="hljs-variable">NEWS_PRODUCER_HOST_PORT</span>/api/news
-H <span class="hljs-string">'Content-Type: application/json'</span>
-d <span class="hljs-string">'{"title":"Article about Spring Cloud Stream and Kafka"}'</span></pre></div><p id="d35e">One of the News Consumer instances should listen to the message sent and log it. Here is what was logged during my execution:</p><div id="785f"><pre>INFO 1 --- [container-0-C-1] c.e.newsconsumer.listener.NewsListener : Received News! <span class="hljs-string">"Article about Spring Cloud Stream and Kafka"</span> created on <span class="hljs-string">'2023-10-28T21:11:05.605584947Z'</span></pre></div><h1 id="bbf1">Shutdown</h1><p id="256d">In a terminal, run the following command to delete completely Minikube:</p><div id="8037"><pre>minikube delete</pre></div><h1 id="d1f2">Conclusion</h1><p id="2213">In this article, we configured Minikube for local Kubernetes development. Before deploying the News Apps, we added the Actuator dependency and enabled their liveness and readiness probes.</p><p id="ee6e">In Minikube, we have deployed Kafka, one instance of News Producer and three instance of News Consumer. At the end, we sent a news using the News Producer endpoints, and checked whether the message was successfully consumed by News Consumer application.</p><h1 id="5aa0">Additional Readings</h1><div id="9301" class="link-block"> <a href="https://medium.com/@ivangfr/list/54af9301b07d"> <div> <div> <h2>Alert Producer and Consumer Tutorial</h2> <div><h3>Edit description</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*e53dc549b02d68b38503862fef89fe8223e70938.jpeg)"></div> </div> </div> </a> </div><div id="fd70" class="link-block"> <a href="https://medium.com/@ivangfr/list/e90bdf33edb5"> <div> <div> <h2>Solace PubSub+</h2> <div><h3>Edit description</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*1cae45a1b49ae949b74daf76f618a47e2aad2a65.jpeg)"></div> </div> </div> </a> </div><h1 id="e8bf">Support and Engagement</h1><p id="b5af">If you enjoyed this article and would like to show your support, please consider taking the following actions:</p><ul><li>👏 Engage by clapping, highlighting, and replying to my story. I’ll be happy to answer any of your questions;</li><li>🌐 Share my story on Social Media;</li><li>🔔 Follow me on: <a href="https://medium.com/@ivangfr">Medium</a> | <a href="https://www.linkedin.com/in/ivanfranchin/">LinkedIn</a> | <a href="https://twitter.com/ivangfr">Twitter</a> | <a href="https://github.com/ivangfr">GitHub</a>;</li><li>✉️ <a href="https://medium.com/@ivangfr/subscribe">Subscribe to my newsletter</a>, so you don’t miss out on my latest posts.</li></ul></article></body>

Spring Boot | Spring Cloud Stream | Minikube | Kubernetes

Running in Minikube (Kubernetes) a Kafka Producer and Consumer that uses Spring Cloud Stream

Step-by-step guide on how to run News Producer and Consumer in Minikube (Kubernetes)

Photo by Mario Calvo on Unsplash

In this article, we will demonstrate how to locally set up Minikube (Kubernetes) on our machines and deploy, within it, instances of two Spring Boot Kafka applications, News Producer and News Consumer. Additionally, we’ll show you how to deploy Kafka in Minikube, which both News Producer and Consumer depends on.

You can find the complete code and implementation in the article linked below. Feel free to follow the steps explained in the article and get started.

This is one article of a series of articles where we are using the News Producer and News Consumer as base applications. Throughout these articles, we’ll cover topics such as implementing unit tests, implementing end-to-end tests and deployment to Kubernetes.

So, let’s get started!

Prerequisites

To follow along with this guide, beside Java 17+ and Docker, please ensure that you have the Minikube, Kubectl, Helm and VirtualBox installed on your machine.

Updating News Producer and Consumer Apps

When we use Kubernetes to control our apps, it takes care of keeping the pods healthy. For example, it makes sure our apps only start handling requests when they’re ready. If a pod’s main process stops working, Kubernetes restarts the container.

To do this job, Kubernetes uses two probes: readiness and liveness. The readiness probe checks if an app is ready to get requests. The liveness probe checks if a pod is still going. This helps decide when to restart a container.

Now, let’s add the Actuator tool and enable the liveness and readiness probes.

Add the Actuator Dependency

In the pom.xml file of both News Producer and News Consumer, let’s include the Actuator dependency by adding the following code (highlighted in bold):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        ...
    </dependencies>
    ...
</project>

It was added because it provides built-in endpoints for checking the application’s health, including specific ones for liveness and readiness probes.

Enable the Liveness and Readiness Probes

In the application.properties of both News Producer and Consumer, let’s enable the liveness and readiness probes by adding the following line:

management.endpoint.health.probes.enabled=true  

Creating YAML Deployment files

Create k8s folder

Inside the news-app root folder, let’s create a folder called k8s.

Create News Producer YAML Deployment file

Inside the k8s folder, let’s create a file named news-producer.yaml and include the following content:

apiVersion: v1
kind: Service
metadata:
  name: news-producer
  labels:
    app: news-producer
spec:
  type: LoadBalancer
  ports:
    - name: http
      port: 8080
      targetPort: 8080
  selector:
    app: news-producer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: news-producer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: news-producer
  template:
    metadata:
      labels:
        app: news-producer
    spec:
      containers:
        - name: news-producer
          image: news-producer:0.0.1-SNAPSHOT
          imagePullPolicy: Never
          ports:
            - name: http
              containerPort: 8080
          env:
            - name: KAFKA_HOST
              value: kafka.dev.svc.cluster.local
            - name: KAFKA_PORT
              value: "9092"
          livenessProbe:
            httpGet:
              path: /actuator/health/liveness
              port: http
          readinessProbe:
            httpGet:
              path: /actuator/health/readiness
              port: http

This YAML file sets up a News Producer service and deployment. The service is a LoadBalancer, exposing the port 8080 for external access. The deployment creates a single pod with the news-producer:0.0.1-SNAPSHOT image and configuration, connecting to a Kafka message broker. The configuration includes liveness and readiness probes.

Create News Consumer YAML Deployment file

Inside the k8s folder, let’s create a file named news-consumer.yaml and include the content below:

apiVersion: v1
kind: Service
metadata:
  name: news-consumer
  labels:
    app: news-consumer
spec:
  type: ClusterIP
  ports:
    - port: 9080
  selector:
    app: news-consumer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: news-consumer
spec:
  replicas: 3
  selector:
    matchLabels:
      app: news-consumer
  template:
    metadata:
      labels:
        app: news-consumer
    spec:
      containers:
        - name: news-consumer
          image: news-consumer:0.0.1-SNAPSHOT
          imagePullPolicy: Never
          ports:
            - name: http
              containerPort: 9080
          env:
            - name: KAFKA_HOST
              value: kafka.dev.svc.cluster.local
            - name: KAFKA_PORT
              value: "9092"
          livenessProbe:
            httpGet:
              path: /actuator/health/liveness
              port: http
          readinessProbe:
            httpGet:
              path: /actuator/health/readiness
              port: http

This YAML file sets up a News Consumer service and deployment. The service makes the application accessible within the cluster via ClusterIP. The deployment creates three pods with the news-consumer:0.0.1-SNAPSHOT image and configuration, connecting to a Kafka message broker. The configuration includes liveness and readiness probes.

Installing Bitnami Helm Repo

In order to run Kafka, we will use the Bitnami Helm Charts. So, in a terminal, let’s add the bitnami repo by running the following command:

helm repo add bitnami https://charts.bitnami.com/bitnami

To delete the bitnami repo, run: helm repo remove bitnami

In order to check the repo list, run:

helm repo list

Finally, run the command below to get the latest information about charts from the chart repositories:

helm repo update

Start Environment

In a terminal, make sure you are in the news-app root folder.

Start Minikube

Run the following command to start Minikube:

minikube start --memory=8192 --cpus=2 --vm-driver=virtualbox

Create dev namespace

Once Minikube is up and running, let’s create a namespace called dev. For it, run the command below:

kubectl create namespace dev

To delete the dev namespace, run: kubectl delete namespace dev

Deploy Kafka

Let’s deploy Kafka. For it, make sure you are in news-app root folder. The, run the following command:

helm -n dev install kafka bitnami/kafka --set listeners.client.protocol=PLAINTEXT

To delete the Kafka installation, run: helm uninstall -n dev kafka

Watch Kafka Deployment

We can watch the deployment by running the following command:

kubectl -n dev get pods -w

To stop watching, press: Ctrl+C

Please be patient as Kafka Docker image will be pulled before we can proceed further. After a few seconds, the Kafka instances should be up and running. To confirm this, you can use the following command:

kubectl -n dev get pods

You should see something like:

NAME                 READY   STATUS    RESTARTS   AGE
kafka-controller-0   1/1     Running   0          4m34s
kafka-controller-1   1/1     Running   0          4m34s
kafka-controller-2   1/1     Running   0          4m34s

Building News App Docker images

In a terminal, let’s execute the following command to sets up our local Docker environment to use Minikube’s Docker daemon:

eval $(minikube docker-env)

Navigate to the news-procucer folder. Run the command below to build the News Producer Docker image:

./mvnw clean spring-boot:build-image -DskipTests

Let’s build the News Consumer Docker image. For it, navigate to news-consumer folder. Once there, run the following command:

./mvnw clean spring-boot:build-image -DskipTests

After the completion of the commands above, the News Producer and Consumer Docker images will be available within Minikube. You can verify this by executing the following command:

docker images

Let’s switch back to our local host Docker daemon by running the command below:

eval $(minikube docker-env -u)

Deploying News Apps

In a terminal, ensure that you are in the news-app root folder. Then, execute the following command to deploy the News Producer:

kubectl -n dev apply -f k8s/news-producer.yaml

To delete the news-producer deployment, run: kubectl -n dev delete -f k8s/news-producer.yaml

Now, let’s deploy the News Consumer by running the command below:

kubectl -n dev apply -f k8s/news-consumer.yaml

To delete the news-consumer deployment, run: kubectl -n dev delete -f k8s/news-consumer.yaml

After a few seconds, the single News Producer instance and three News Consumer instances should be up and running. To confirm this, you can use the following command:

kubectl -n dev get pods

You should see something like:

NAME                             READY   STATUS    RESTARTS   AGE
kafka-controller-0               1/1     Running   0          13m
kafka-controller-1               1/1     Running   0          13m
kafka-controller-2               1/1     Running   0          13m
news-consumer-69cd94fb64-4p2pk   1/1     Running   0          15s
news-consumer-69cd94fb64-k6nd4   1/1     Running   0          15s
news-consumer-69cd94fb64-rm8v7   1/1     Running   0          15s
news-producer-5bc75c69c9-88vfs   1/1     Running   0          23s

Sending News

In a terminal, let’s start monitoring the logs of the three News Consumer instances:

kubectl -n dev logs -l app=news-consumer -f

In another terminal, run the following command to get the NEWS_PRODUCER_HOST_PORT:

NEWS_PRODUCER_HOST_PORT="$(minikube ip):$(kubectl get services -n dev news-producer -o go-template='{{(index .spec.ports 0).nodePort}}')"
echo $NEWS_PRODUCER_HOST_PORT

In the same terminal where NEWS_PRODUCER_HOST_PORT was obtained, let’s send one news by executing the command below:

curl -i -X POST $NEWS_PRODUCER_HOST_PORT/api/news \
  -H 'Content-Type: application/json' \
  -d '{"title":"Article about Spring Cloud Stream and Kafka"}'

One of the News Consumer instances should listen to the message sent and log it. Here is what was logged during my execution:

INFO 1 --- [container-0-C-1] c.e.newsconsumer.listener.NewsListener   : Received News! "Article about Spring Cloud Stream and Kafka" created on '2023-10-28T21:11:05.605584947Z'

Shutdown

In a terminal, run the following command to delete completely Minikube:

minikube delete

Conclusion

In this article, we configured Minikube for local Kubernetes development. Before deploying the News Apps, we added the Actuator dependency and enabled their liveness and readiness probes.

In Minikube, we have deployed Kafka, one instance of News Producer and three instance of News Consumer. At the end, we sent a news using the News Producer endpoints, and checked whether the message was successfully consumed by News Consumer application.

Additional Readings

Support and Engagement

If you enjoyed this article and would like to show your support, please consider taking the following actions:

  • 👏 Engage by clapping, highlighting, and replying to my story. I’ll be happy to answer any of your questions;
  • 🌐 Share my story on Social Media;
  • 🔔 Follow me on: Medium | LinkedIn | Twitter | GitHub;
  • ✉️ Subscribe to my newsletter, so you don’t miss out on my latest posts.
Kubernetes
Spring Boot
Technology
Software Development
Apache Kafka
Recommended from ReadMedium