<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Suji Matts</title>
    <description>The latest articles on DEV Community by Suji Matts (@sujimatts).</description>
    <link>https://dev.to/sujimatts</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2196744%2Fc2f8b073-11de-4def-a533-b60982c8d88a.JPG</url>
      <title>DEV Community: Suji Matts</title>
      <link>https://dev.to/sujimatts</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sujimatts"/>
    <language>en</language>
    <item>
      <title>Analyze Images with the GCP Cloud Vision API</title>
      <dc:creator>Suji Matts</dc:creator>
      <pubDate>Thu, 17 Oct 2024 12:29:56 +0000</pubDate>
      <link>https://dev.to/sujimatts/analyze-images-with-the-gcp-cloud-vision-api-374f</link>
      <guid>https://dev.to/sujimatts/analyze-images-with-the-gcp-cloud-vision-api-374f</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;This article explores usage of multiple Google Cloud ML APIs, including the Cloud Vision API, Translation API, and Natural Language API. You’ll start by using Optical Character Recognition (OCR) to extract text from an image, then translate that text, and finally analyze it for deeper insights.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Steps
&lt;/h2&gt;

&lt;p&gt;Creating an API Key: Begin by generating an API key to authenticate your requests to the Vision API.&lt;/p&gt;

&lt;p&gt;Uploading an Image: You will create a Cloud Storage bucket to store your images and upload a sample image for text extraction.&lt;/p&gt;

&lt;p&gt;Making a Vision API Request: Using curl, you'll construct a request to the Vision API to perform text detection on the uploaded image.&lt;/p&gt;

&lt;p&gt;Translating the Text: With the extracted text, you’ll use the Translation API to convert it from French to English.&lt;/p&gt;

&lt;p&gt;Analyzing the Text: Finally, leverage the Natural Language API to extract entities and analyze the translated text for additional insights.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Creating an API Key
&lt;/h2&gt;

&lt;p&gt;To get started, you need an API key to authenticate your requests to the Vision API. Here’s how you do it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Navigate to the API Credentials Sectio&lt;br&gt;
n: In the Google Cloud Console, go to APIs &amp;amp; Services and then Credentials.&lt;/p&gt;

&lt;p&gt;Generate an API Key&lt;br&gt;
: Click on Create Credentials and select API Key from the dropdown menu. This key will allow you to make secure requests to the Vision API.&lt;/p&gt;

&lt;p&gt;Store the API Key&lt;br&gt;
: After generating the key, copy it and store it as an environment variable in your Cloud Shell. This simplifies the process of including the key in your requests, making it easier to manage.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Uploading an Image
&lt;/h2&gt;

&lt;p&gt;To process an image with the Vision API, you need to upload it to a Cloud Storage bucket:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a Cloud Storage Bucket&lt;br&gt;
Navigate to the Cloud Storage browser in the Google Cloud Console and click Create Bucket. Choose a unique name for your bucket and configure access settings.&lt;/p&gt;

&lt;p&gt;Set Access Permissions&lt;br&gt;
Uncheck the box for Enforce public access prevention and select Fine-grained access control. &lt;/p&gt;

&lt;p&gt;Upload the Image&lt;br&gt;
After creating the bucket, you can upload your sample image (e.g.&lt;a href="https://cdn.qwiklabs.com/cBoI5P4dZ6k%2FAr5Mv7eME%2F0fCb4G6nIGB0odCXzpEa4%3D" rel="noopener noreferrer"&gt;https://cdn.qwiklabs.com/cBoI5P4dZ6k%2FAr5Mv7eME%2F0fCb4G6nIGB0odCXzpEa4%3D&lt;/a&gt;). Ensure that the image has public access so the Vision API can retrieve it for processing.&lt;br&gt;
Save this image as sign.jpg &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3. Create your Cloud Vision API request
&lt;/h2&gt;

&lt;p&gt;create a file with &lt;code&gt;ocr-request.json&lt;/code&gt; below content&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "requests": [
      {
        "image": {
          "source": {
              "gcsImageUri": "gs://my-bucket-name/sign.jpg"
          }
        },
        "features": [
          {
            "type": "TEXT_DETECTION",
            "maxResults": 10
          }
        ]
      }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You're going to use the &lt;a href="https://cloud.google.com/vision/docs/ocr" rel="noopener noreferrer"&gt;TEXT_DETECTION&lt;/a&gt; feature of the Cloud Vision API. This will run optical character recognition (OCR) on the image to extract text.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Call the text detection method
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s -X POST -H "Content-Type: application/json" --data-binary @ocr-request.json  https://vision.googleapis.com/v1/images:annotate?key=${API_KEY}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first part of your response should look like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "responses": [
    {
      "textAnnotations": [
        {
          "locale": "fr",
          "description": "LE BIEN PUBLIC\nles dépêches\nPour Obama,\nla moutarde\nest\nde Dijon\n",
          "boundingPoly": {
            "vertices": [
              {
                "x": 138,
                "y": 40
              },
              {
                "x": 622,
                "y": 40
              },
              {
                "x": 622,
                "y": 795
              },
              {
                "x": 138,
                "y": 795
              }
            ]
          }
        },
        {
          "description": "LE",
          "boundingPoly": {
            "vertices": [
              {
                "x": 138,
                "y": 99
              },
              {
                "x": 274,
                "y": 82
              },
              {
                "x": 283,
                "y": 157
              },
              {
                "x": 147,
                "y": 173
              }
            ]
          }
        },
        {
          "description": "BIEN",
          "boundingPoly": {
            "vertices": [
              {
                "x": 291,
                "y": 79
              },
              {
                "x": 413,
                "y": 64
              },
              {
                "x": 422,
                "y": 139
              },
              {
                "x": 300,
                "y": 154
              }
            ]
          }
            ...
      ]
}]
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The OCR method is able to extract lots of text from the image.&lt;/p&gt;

&lt;p&gt;The first piece of data you get back from textAnnotations is the entire block of text the API found in the image. This includes:&lt;/p&gt;

&lt;p&gt;the language code (in this case fr for French)&lt;br&gt;
a string of the text&lt;br&gt;
a bounding box indicating where the text was found in the image&lt;br&gt;
Then you get an object for each word found in the text with a bounding box for that specific word.&lt;/p&gt;

&lt;p&gt;Run the following curl command to save the response to an ocr-response.json file so it can be referenced later:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s -X POST -H "Content-Type: application/json" --data-binary @ocr-request.json  https://vision.googleapis.com/v1/images:annotate?key=${API_KEY} -o ocr-response.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Send text from the image to the Translation API
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/translate/docs/reference/translate" rel="noopener noreferrer"&gt;The Translation API&lt;/a&gt; can translate text into 100+ languages. It can also detect the language of the input text. To translate the French text into English, pass the text and the language code for the target language (en-US) to the Translation API.&lt;/p&gt;

&lt;p&gt;First, create a &lt;code&gt;translation-request.json&lt;/code&gt; file and add the following to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "q": "your_text_here",
  "target": "en"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this Bash command in Cloud Shell to extract the image text from the previous step and copy it into a new translation-request.json (all in one command):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STR=$(jq .responses[0].textAnnotations[0].description ocr-response.json) &amp;amp;&amp;amp; STR="${STR//\"}" &amp;amp;&amp;amp; sed -i "s|your_text_here|$STR|g" translation-request.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you're ready to call the Translation API. This command will also copy the response into a translation-response.json file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s -X POST -H "Content-Type: application/json" --data-binary @translation-request.json https://translation.googleapis.com/language/translate/v2?key=${API_KEY} -o translation-response.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this command to inspect the file with the Translation API response&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat translation-response.json

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can understand more of what the sign said!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "data": {
    "translations": [
      {
        "translatedText": "TO THE PUBLIC GOOD the dispatches For Obama, the mustard is from Dijon",
        "detectedSourceLanguage": "fr"
      }
    ]
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Analyzing the image's text with the Natural Language API
&lt;/h2&gt;

&lt;p&gt;The Natural Language API helps you understand text by extracting entities, analyzing sentiment and syntax, and classifying text into categories. Use the analyzeEntities method to see what entities the Natural Language API can find in the text from your image.&lt;/p&gt;

&lt;p&gt;To set up the API request, create a &lt;code&gt;nl-request.json&lt;/code&gt; file with the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "document":{
    "type":"PLAIN_TEXT",
    "content":"your_text_here"
  },
  "encodingType":"UTF8"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STR=$(jq .data.translations[0].translatedText  translation-response.json) &amp;amp;&amp;amp; STR="${STR//\"}" &amp;amp;&amp;amp; sed -i "s|your_text_here|$STR|g" nl-request.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Call the `analyzeEntities `endpoint of the Natural Language API with this curl request:
curl "https://language.googleapis.com/v1/documents:analyzeEntities?key=${API_KEY}" \
  -s -X POST -H "Content-Type: application/json" --data-binary @nl-request.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you scroll through the response you can see the entities the Natural Language API found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "entities": [
    {
      "name": "dispatches",
      "type": "OTHER",
      "metadata": {},
      "salience": 0.3560996,
      "mentions": [
        {
          "text": {
            "content": "dispatches",
            "beginOffset": 23
          },
          "type": "COMMON"
        }
      ]
    },
    {
      "name": "mustard",
      "type": "OTHER",
      "metadata": {},
      "salience": 0.2878307,
      "mentions": [
        {
          "text": {
            "content": "mustard",
            "beginOffset": 38
          },
          "type": "COMMON"
        }
      ]
    },
    {
      "name": "Obama",
      "type": "PERSON",
      "metadata": {
        "mid": "/m/02mjmr",
        "wikipedia_url": "https://en.wikipedia.org/wiki/Barack_Obama"
      },
      "salience": 0.16260329,
      "mentions": [
        {
          "text": {
            "content": "Obama",
            "beginOffset": 31
          },
          "type": "PROPER"
        }
      ]
    },
    {
      "name": "Dijon",
      "type": "LOCATION",
      "metadata": {
        "mid": "/m/0pbhz",
        "wikipedia_url": "https://en.wikipedia.org/wiki/Dijon"
      },
      "salience": 0.08129317,
      "mentions": [
        {
          "text": {
            "content": "Dijon",
            "beginOffset": 54
          },
          "type": "PROPER"
        }
      ]
    }
  ],
  "language": "en"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For entities that have a wikipedia page, the API provides metadata including the URL of that page along with the entity's mid. The mid is an ID that maps to this entity in Google's &lt;a href="https://developers.google.com/knowledge-graph/" rel="noopener noreferrer"&gt;Knowledge Graph&lt;/a&gt;. To get more information on it, you could call the Knowledge Graph API, passing it this ID. For all entities, the Natural Language API tells us the places it appeared in the text (mentions), the type of entity, and salience (a [0,1] range indicating how important the entity is to the text as a whole). In addition to English, the Natural Language API also supports the languages listed in the &lt;a href="https://cloud.google.com/natural-language/docs/languages" rel="noopener noreferrer"&gt;Language Support reference&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Configure Google Cloud Speech-to-Text API</title>
      <dc:creator>Suji Matts</dc:creator>
      <pubDate>Mon, 14 Oct 2024 12:19:32 +0000</pubDate>
      <link>https://dev.to/sujimatts/configure-google-cloud-speech-to-text-api-3p16</link>
      <guid>https://dev.to/sujimatts/configure-google-cloud-speech-to-text-api-3p16</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The Speech-to-Text API enables easy integration of Google speech recognition technologies into developer applications. It allows you to send audio and receive a text transcription from the service.&lt;/p&gt;

&lt;p&gt;What we'll cover&lt;br&gt;
In this lab, you will learn how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an API key&lt;/li&gt;
&lt;li&gt;Create a Speech-to-Text API request&lt;/li&gt;
&lt;li&gt;Call the Speech-to-Text API&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Step 1: Create an API Key
&lt;/h2&gt;

&lt;p&gt;In the Google Cloud Console, navigate to Navigation menu &amp;gt; APIs &amp;amp; services &amp;gt; Credentials.&lt;br&gt;
Click on Create credentials and select API key.&lt;br&gt;
Copy the generated key and click Close.&lt;/p&gt;

&lt;p&gt;Save API Key as Environment Variable&lt;/p&gt;

&lt;p&gt;Connect to your VM instance via SSH.&lt;br&gt;
In the command line, set the environment variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export API_KEY=&amp;lt;YOUR_API_KEY&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create Your Speech-to-Text API Request
&lt;/h2&gt;

&lt;p&gt;Create a new file named &lt;code&gt;request.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch request.json

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the file in a text editor and add the following JSON configuration, specifying the audio file’s URI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "config": {
    "encoding": "FLAC",
    "languageCode": "en-US"
  },
  "audio": {
    "uri": "gs://cloud-samples-tests/speech/brooklyn.flac"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Call the Speech-to-Text API
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json "https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response will include the transcript and a confidence score.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Save Response to a File&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json "&lt;a href="https://speech.googleapis.com/v1/speech:recognize?key=$%7BAPI_KEY%7D" rel="noopener noreferrer"&gt;https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}&lt;/a&gt;" &amp;gt; result.json&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! You have successfully used the Speech-to-Text API to transcribe an audio file. This hands-on lab demonstrated how to create an API key, construct a request, and call the Speech-to-Text service.&lt;/p&gt;

&lt;p&gt;Read More: &lt;a href="https://codelabs.developers.google.com/codelabs/cloud-speech-text-python3#0" rel="noopener noreferrer"&gt;https://codelabs.developers.google.com/codelabs/cloud-speech-text-python3#0&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gcp</category>
      <category>speechtotextapi</category>
      <category>gcpapi</category>
    </item>
    <item>
      <title>Building a Spring Boot Application with Maven and Deploying on Kind K8s Cluster Using Helm</title>
      <dc:creator>Suji Matts</dc:creator>
      <pubDate>Fri, 11 Oct 2024 05:59:52 +0000</pubDate>
      <link>https://dev.to/sujimatts/building-a-spring-boot-application-with-maven-and-deploying-on-kind-k8s-cluster-using-helm-40eh</link>
      <guid>https://dev.to/sujimatts/building-a-spring-boot-application-with-maven-and-deploying-on-kind-k8s-cluster-using-helm-40eh</guid>
      <description>&lt;p&gt;In this article, we will walk through the process of setting up a Kubernetes environment using Kind, building a simple Java Hello World application, and deploying it using Docker and Helm. This guide is perfect for developers looking to streamline their Kubernetes development workflow.&lt;/p&gt;

&lt;p&gt;We will go through two phases here: the first phase focuses on setting up a local Kubernetes environment and deploying a Java Hello World application, while the second phase covers modifying the application and redeploying it to reflect those changes.&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;/p&gt;

&lt;p&gt;Before you begin, ensure you have the following installed on your machine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;Kind&lt;/li&gt;
&lt;li&gt;kubectl&lt;/li&gt;
&lt;li&gt;Helm&lt;/li&gt;
&lt;li&gt;Maven&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Create a Kind Cluster
&lt;/h2&gt;

&lt;p&gt;Kind (Kubernetes IN Docker) allows you to run Kubernetes clusters in Docker containers. To create a Kind cluster, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kind create cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that your cluster is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl cluster-info --context kind-kind
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl cluster-info --context kind-kind
Kubernetes control plane is running at https://127.0.0.1:42723
CoreDNS is running at https://127.0.0.1:42723/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create a Java Hello World Application
&lt;/h2&gt;

&lt;p&gt;Create a folder structure like below and create two files as mentioned&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;└── src
    └── main
        ├── java
        │   └── com
        │       └── example
        │           └── HelloWorldApplication.java
        └── resources
            └── application.properties 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;HelloWorldApplication.java *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class HelloWorldApplication {

    public static void main(String[] args) {
        SpringApplication.run(HelloWorldApplication.class, args);
    }

    @GetMapping("/")
    public String hello() {
        return "Hello, World!";
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;application.properties&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server.port=8081
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a pom.xml file in the root folder&lt;/strong&gt; [same folder of src]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

    &amp;lt;groupId&amp;gt;com.example&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;hello-world-app&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

    &amp;lt;properties&amp;gt;
        &amp;lt;java.version&amp;gt;11&amp;lt;/java.version&amp;gt;
        &amp;lt;spring.version&amp;gt;2.6.3&amp;lt;/spring.version&amp;gt;
    &amp;lt;/properties&amp;gt;

    &amp;lt;dependencies&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${spring.version}&amp;lt;/version&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;

    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;spring-boot-maven-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${spring.version}&amp;lt;/version&amp;gt;
                &amp;lt;executions&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;repackage&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                    &amp;lt;/execution&amp;gt;
                &amp;lt;/executions&amp;gt;
            &amp;lt;/plugin&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;3.8.1&amp;lt;/version&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;source&amp;gt;${java.version}&amp;lt;/source&amp;gt;
                    &amp;lt;target&amp;gt;${java.version}&amp;lt;/target&amp;gt;
                &amp;lt;/configuration&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Build your application using maven
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mvn clean package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a jar file inside the target folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ls
pom.xml  src  target
$ls target/
classes  generated-sources  hello-world-app-1.0-SNAPSHOT.jar  hello-world-app-1.0-SNAPSHOT.jar.original  maven-archiver  maven-status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Build the Docker Image
&lt;/h2&gt;

&lt;p&gt;Create a &lt;strong&gt;Dockerfile&lt;/strong&gt; in the root directory [same dir of src]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use the official OpenJDK image as the base image
FROM openjdk:11-jre-slim

# Set the working directory
WORKDIR /app

# Copy the JAR file into the container
COPY target/hello-world-app-1.0-SNAPSHOT.jar app.jar

# Expose the port the app runs on
EXPOSE 8081

# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build your application and create the Docker image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t &amp;lt;your-dockerhub-username&amp;gt;/hello-world-app:latest .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Push the Docker Image to Docker Hub
&lt;/h2&gt;

&lt;p&gt;Log in to your Docker Hub account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push your image to Docker Hub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker push &amp;lt;your-dockerhub-username&amp;gt;/hello-world-app:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Create Helm Charts
&lt;/h2&gt;

&lt;p&gt;Generate a new Helm chart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm create hello-world-java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create below structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├── hello-world-java
│   ├── charts
│   ├── Chart.yaml
│   ├── templates
│   │   ├── deployment.yaml
│   │   ├── _helpers.tpl
│   │   ├── hpa.yaml
│   │   ├── ingress.yaml
│   │   ├── NOTES.txt
│   │   ├── serviceaccount.yaml
│   │   ├── service.yaml
│   │   └── tests
│   │       └── test-connection.yaml
│   └── values.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need only two files from these. Those are&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chart.yaml
values.yaml
templates/deployment.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit the &lt;code&gt;values.yaml&lt;/code&gt; file to specify your Docker image and Service&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;image:
  repository: &amp;lt;your-dockerhub-username&amp;gt;/hello-world-app
  tag: latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service:
  type: NodePort
  port: 8081
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the &lt;code&gt;deployment.yaml&lt;/code&gt; file under &lt;code&gt;templates&lt;/code&gt; is configured correctly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: {{ .Values.service.port }}
              protocol: TCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 7: Deploy the Application Using Helm
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm install hello-world-java ./hello-world-java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that your application is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME                               READY   STATUS    RESTARTS   AGE
hello-world-java-54fb55948-597hk   1/1     Running   0          144m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 8: Access Your Application
&lt;/h2&gt;

&lt;p&gt;To access your application, you can use port forwarding since you're running in a Kind cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl port-forward svc/hello-world-java 8081:8081
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see output indicating that the connection is being forwarded. Open your browser and go to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8081
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can successfully access the Hello World page from your browser. Let’s explore how to make a change and redeploy it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 9: Modify Application
&lt;/h2&gt;

&lt;p&gt;First, navigate to the &lt;code&gt;HelloWorldApplication.java&lt;/code&gt;file and change "Hello World" to "Hi World."&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 10: Rebuild your application using Maven
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mvn clean package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 11: Re-build your Docker image
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t &amp;lt;your-dockerhub-username&amp;gt;/hello-world-app:latest .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 12: Push the updated image to Docker Hub
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker push &amp;lt;your-dockerhub-username&amp;gt;/hello-world-app:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before deploying it with Helm, ensure the image pull policy is set to Always in &lt;code&gt;values.yaml&lt;/code&gt;; otherwise, it wont download the latest image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;image:
  repository: your-docker-hub-username/hello-world-java
  pullPolicy: Always
  tag: "latest"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 13: Helm Upgrade
&lt;/h2&gt;

&lt;p&gt;Now you can upgrade your Helm release:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm upgrade hello-world-java ./hello-world-java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, set up port forwarding to access your application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl port-forward svc/hello-world-java 8081:8081
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 14:Access Your Application
&lt;/h2&gt;

&lt;p&gt;Now you can navigate to &lt;code&gt;http://localhost:8081&lt;/code&gt; in your browser and see your changes reflected.You will now see the "Hi World" page instead of "Hello World."&lt;/p&gt;

</description>
      <category>helm</category>
      <category>k8s</category>
      <category>helmupgrade</category>
      <category>mvn</category>
    </item>
  </channel>
</rss>
