<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammed Eren Demir on Medium]]></title>
        <description><![CDATA[Stories by Muhammed Eren Demir on Medium]]></description>
        <link>https://medium.com/@muhammederendemir?source=rss-16a8f880408b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dJxVAMcqSOZhfiOKfsV_jQ.jpeg</url>
            <title>Stories by Muhammed Eren Demir on Medium</title>
            <link>https://medium.com/@muhammederendemir?source=rss-16a8f880408b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 10:34:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhammederendemir/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[KrakenD API Gateway with Microservices Architecture: Comprehensive Guide]]></title>
            <link>https://muhammederendemir.medium.com/krakend-api-gateway-with-microservices-architecture-comprehensive-guide-006f021bf029?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/006f021bf029</guid>
            <category><![CDATA[krakend]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 06:22:37 GMT</pubDate>
            <atom:updated>2025-08-13T06:22:37.643Z</atom:updated>
            <content:encoded><![CDATA[<h3>📖 Introduction</h3><p>In the modern software development world, microservices architecture is widely used to break down large and complex applications into smaller, independent, and manageable parts. However, one of the biggest challenges of microservices architecture is how these services will be exposed to the outside world. This is where <strong>API Gateway</strong> comes into play.</p><p>In this article, we will examine in detail how to use KrakenD API Gateway and how to implement it effectively in microservices architecture, using the <a href="https://github.com/Muhammederendemir/spring-boot-krakend-api-gateway">Spring Boot + KrakenD API Gateway</a> project as an example.</p><h3><strong>🎯 What is API Gateway and Why is it Necessary?</strong></h3><h4><strong>Definition of API Gateway</strong></h4><p>API Gateway is a component in microservices architecture that provides a single entry point between external clients and backend services. All requests first come to the API Gateway, are processed here, and then routed to the appropriate microservice.</p><h4>Benefits of API Gateway</h4><ul><li><strong>Single Entry Point</strong>: All APIs are accessible through a single URL</li><li><strong>Security</strong>: Centralized authentication and authorization</li><li><strong>Load Balancing</strong>: Distributing requests among multiple service instances</li><li><strong>Rate Limiting</strong>: Limiting API usage</li><li><strong>Caching</strong>: Caching frequently requested data</li><li><strong>Monitoring</strong>: Centralized logging and monitoring</li></ul><h3>🚀 KrakenD: Powerful API Gateway Written in Go</h3><h4>Advantages of KrakenD</h4><ul><li><strong>High Performance</strong>: Written in Go, low memory usage</li><li><strong>Open Source</strong>: Free and community-supported</li><li><strong>Flexible Configuration</strong>: JSON-based configuration</li><li><strong>Rich Features</strong>: Aggregation, transformation, caching, etc.</li><li><strong>Docker Support</strong>: Easy deployment</li></ul><h3>🏗️ Example Project: Spring Boot + KrakenD API Gateway</h3><p>In our <a href="https://github.com/Muhammederendemir/spring-boot-krakend-api-gateway">GitHub Repository</a> project, we use the following structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAG1M3bRSKy2EY2zoULjSQ.png" /></figure><h4>Project Components</h4><h4><strong>1. User Service (Port: 8080)</strong></h4><p>Spring Boot microservice developed for user management.</p><p><strong>Entity:</strong></p><pre>@Entity<br>@Table(name = &quot;users&quot;)<br>public class User {<br>    @Id<br>    @GeneratedValue(strategy = GenerationType.IDENTITY)<br>    private int id;<br>    <br>    @Column(nullable = false, unique = true)<br>    private String username;<br>    <br>    @Column(nullable = false, unique = true)<br>    private String email;<br>    <br>    private String password;<br>    <br>    // Getter and Setter methods...<br>}</pre><p><strong>Controller:</strong></p><pre>@RestController<br>@RequestMapping(&quot;/api/users&quot;)<br>public class UserController {<br>    private final UserService userService;<br><br>    public UserController(UserService userService) {<br>        this.userService = userService;<br>    }<br><br>    @PostMapping<br>    public User createNewUser(@RequestBody User user) {<br>        return userService.createUser(user);<br>    }<br><br>    @GetMapping<br>    public List&lt;User&gt; getAllUsers() {<br>        return userService.getAllUsers();<br>    }<br>}</pre><h4>2. Product Service (Port: 8081)</h4><p>Spring Boot microservice developed for product management.</p><p><strong>Entity:</strong></p><pre>@Entity<br>@Table(name = &quot;products&quot;)<br>public class Product {<br>    @Id<br>    @GeneratedValue(strategy = GenerationType.IDENTITY)<br>    private Long id;<br><br>    @Column(nullable = false, unique = true)<br>    private String name;<br><br>    @Column(nullable = false)<br>    private String description;<br><br>    @Column(nullable = false)<br>    private BigDecimal price;<br><br>    private int stock;<br>    <br>    // Getter and Setter methods...<br>}</pre><p><strong>Controller:</strong></p><pre>@RestController<br>@RequestMapping(&quot;/api/products&quot;)<br>public class ProductController {<br>    private final ProductService productService;<br><br>    public ProductController(ProductService productService) {<br>        this.productService = productService;<br>    }<br><br>    @GetMapping<br>    public List&lt;Product&gt; getAllProducts() {<br>        return productService.getAllProducts();<br>    }<br><br>    @GetMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;Product&gt; getProductById(@PathVariable Long id) {<br>        return productService.getProductById(id)<br>                .map(ResponseEntity::ok)<br>                .orElse(ResponseEntity.notFound().build());<br>    }<br><br>    @PostMapping<br>    public Product createProduct(@RequestBody Product product) {<br>        return productService.createProduct(product);<br>    }<br><br>    @PutMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;Product&gt; updateProduct(@PathVariable Long id, @RequestBody Product product) {<br>        return productService.updateProduct(id, product)<br>                .map(ResponseEntity::ok)<br>                .orElse(ResponseEntity.notFound().build());<br>    }<br><br>    @DeleteMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;Void&gt; deleteProduct(@PathVariable Long id) {<br>        productService.deleteProduct(id);<br>        return ResponseEntity.noContent().build();<br>    }<br>}</pre><h3>🔧 KrakenD Configuration: Step by Step</h3><h4>1. Basic Routing Configuration</h4><p><strong>File:</strong> krakend-router.json</p><pre>{<br>  &quot;$schema&quot;: &quot;https://www.krakend.io/schema/v3.json&quot;,<br>  &quot;version&quot;: 3,<br>  &quot;name&quot;: &quot;Spring Boot API Gateway&quot;,<br>  &quot;port&quot;: 8000,<br>  &quot;endpoints&quot;: [<br>    {<br>      &quot;endpoint&quot;: &quot;/api/users&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/products&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ]<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p><strong>Configuration Explanation:</strong></p><ul><li>endpoint: URL accessible from the outside world</li><li>method: HTTP method (GET, POST, PUT, DELETE)</li><li>output_encoding: Response encoding format</li><li>backend: Backend services configuration</li><li>url_pattern: Endpoint path in the backend</li><li>host: Backend service address</li></ul><h4>2. API Aggregation Configuration</h4><p><strong>File:</strong> krakend-aggregation.json</p><pre>{<br>  &quot;$schema&quot;: &quot;https://www.krakend.io/schema/v3.json&quot;,<br>  &quot;version&quot;: 3,<br>  &quot;name&quot;: &quot;Spring Boot API Gateway&quot;,<br>  &quot;port&quot;: 8000,<br>  &quot;endpoints&quot;: [<br>    {<br>      &quot;endpoint&quot;: &quot;/api/users&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/products&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/dashboard&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ],<br>          &quot;group&quot;: &quot;users&quot;,<br>          &quot;is_collection&quot;: true<br>        },<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ],<br>          &quot;group&quot;: &quot;products&quot;,<br>          &quot;is_collection&quot;: true<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p><strong>Aggregation Features:</strong></p><ul><li>group: Used to group responses</li><li>is_collection: Indicates that the response is a collection</li></ul><p><strong>Aggregation Response Format:</strong></p><pre>{<br>  &quot;users&quot;: [<br>    {<br>      &quot;id&quot;: 1,<br>      &quot;username&quot;: &quot;john_doe&quot;,<br>      &quot;email&quot;: &quot;john@example.com&quot;<br>    }<br>  ],<br>  &quot;products&quot;: [<br>    {<br>      &quot;id&quot;: 1,<br>      &quot;name&quot;: &quot;Laptop&quot;,<br>      &quot;price&quot;: 999.99,<br>      &quot;stock&quot;: 10<br>    }<br>  ]<br>}</pre><h4>3. Rate Limiting Configuration</h4><p><strong>File:</strong> krakend-ratelimitter.json</p><pre>{<br>  &quot;$schema&quot;: &quot;https://www.krakend.io/schema/v3.json&quot;,<br>  &quot;version&quot;: 3,<br>  &quot;name&quot;: &quot;Spring Boot API Gateway&quot;,<br>  &quot;port&quot;: 8000,<br>  &quot;extra_config&quot;: {<br>    &quot;router&quot;: {<br>      &quot;logger_skip_paths&quot;: [<br>        &quot;/__health&quot;,<br>        &quot;/favicon.ico&quot;<br>      ]<br>    }<br>  },<br>  &quot;endpoints&quot;: [<br>    {<br>      &quot;endpoint&quot;: &quot;/api/users&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/products&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/dashboard&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;extra_config&quot;: {<br>        &quot;qos/ratelimit/router&quot;: {<br>          &quot;max_rate&quot;: 5,<br>          &quot;every&quot;: &quot;1m&quot;<br>        }<br>      },<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ],<br>          &quot;group&quot;: &quot;users&quot;,<br>          &quot;is_collection&quot;: true<br>        },<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ],<br>          &quot;group&quot;: &quot;products&quot;,<br>          &quot;is_collection&quot;: true<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p><strong>Rate Limiting Parameters:</strong></p><ul><li>max_rate: Maximum number of requests</li><li>every: Time interval (1m = 1 minute)</li></ul><h4>4. JWT Authentication Configuration</h4><p><strong>File:</strong> krakend.json (Main configuration)</p><pre>{<br>  &quot;$schema&quot;: &quot;https://www.krakend.io/schema/v3.json&quot;,<br>  &quot;version&quot;: 3,<br>  &quot;name&quot;: &quot;Spring Boot API Gateway&quot;,<br>  &quot;port&quot;: 8000,<br>  &quot;extra_config&quot;: {<br>    &quot;router&quot;: {<br>      &quot;logger_skip_paths&quot;: [<br>        &quot;/__health&quot;,<br>        &quot;/favicon.ico&quot;<br>      ]<br>    }<br>  },<br>  &quot;endpoints&quot;: [<br>    {<br>      &quot;endpoint&quot;: &quot;/api/users&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/products&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;output_encoding&quot;: &quot;no-op&quot;,<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ]<br>        }<br>      ]<br>    },<br>    {<br>      &quot;endpoint&quot;: &quot;/api/dashboard&quot;,<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;extra_config&quot;: {<br>        &quot;qos/ratelimit/router&quot;: {<br>          &quot;max_rate&quot;: 5,<br>          &quot;every&quot;: &quot;1m&quot;<br>        },<br>        &quot;auth/validator&quot;: {<br>          &quot;alg&quot;: &quot;HS256&quot;,<br>          &quot;kid&quot;: &quot;krakend-secret&quot;,<br>          &quot;jwk&quot;: {<br>            &quot;key&quot;: &quot;my-krakend-secret&quot;,<br>            &quot;kty&quot;: &quot;oct&quot;<br>          },<br>          &quot;cache_enabled&quot;: true,<br>          &quot;cookie_keys&quot;: [],<br>          &quot;query_string&quot;: &quot;access_token&quot;<br>        }<br>      },<br>      &quot;backend&quot;: [<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/users&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://users-service:8080&quot;<br>          ],<br>          &quot;group&quot;: &quot;users&quot;,<br>          &quot;is_collection&quot;: true<br>        },<br>        {<br>          &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>          &quot;host&quot;: [<br>            &quot;http://products-service:8081&quot;<br>          ],<br>          &quot;group&quot;: &quot;products&quot;,<br>          &quot;is_collection&quot;: true<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p><strong>JWT Configuration Parameters:</strong></p><ul><li>alg: JWT algorithm (HS256, RS256, etc.)</li><li>kid: Key ID</li><li>jwk: JSON Web Key</li><li>cache_enabled: Token caching</li><li>query_string: Token sent in query parameter</li></ul><h3>🐳 Deployment with Docker</h3><h4>Docker Compose Configuration</h4><pre>version: &#39;3.7&#39;<br><br>services:<br>  users-service:<br>    build: ./spring-boot-user-service<br>    ports:<br>      - &quot;8080:8080&quot;<br><br>  products-service:<br>    build: ./spring-boot-product-service<br>    ports:<br>      - &quot;8081:8081&quot;<br><br>  krakend:<br>    image: devopsfaith/krakend<br>    container_name: krakend<br>    ports:<br>      - &quot;8000:8000&quot;<br>    volumes:<br>      - ./krakend.json:/etc/krakend/krakend.json<br>    depends_on:<br>      - users-service<br>      - products-service</pre><h4>Dockerfile Examples</h4><p><strong>User Service Dockerfile:</strong></p><pre>FROM openjdk:21-jdk-slim<br><br>WORKDIR /app<br><br>COPY target/*.jar app.jar<br><br>EXPOSE 8080<br><br>ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;app.jar&quot;]</pre><p><strong>Product Service Dockerfile:</strong></p><pre>FROM openjdk:21-jdk-slim<br><br>WORKDIR /app<br><br>COPY target/*.jar app.jar<br><br>EXPOSE 8081<br><br>ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;app.jar&quot;]</pre><h3>🧪 Test Scenarios</h3><h4>1. Basic Routing Test</h4><pre># User Service test<br>curl -X GET http://localhost:8000/api/users<br>curl -X POST http://localhost:8000/api/users \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;username&quot;:&quot;test&quot;,&quot;email&quot;:&quot;test@example.com&quot;,&quot;password&quot;:&quot;123&quot;}&#39;<br><br># Product Service test<br>curl -X GET http://localhost:8000/api/products<br>curl -X POST http://localhost:8000/api/products \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;name&quot;:&quot;Test Product&quot;,&quot;description&quot;:&quot;Test&quot;,&quot;price&quot;:99.99,&quot;stock&quot;:10}&#39;</pre><h4>2. Aggregation Test</h4><pre># Dashboard endpoint (users + products)<br>curl http://localhost:8000/api/dashboard<br><br># Expected response:<br>{<br>  &quot;users&quot;: [<br>    {<br>      &quot;id&quot;: 1,<br>      &quot;username&quot;: &quot;test&quot;,<br>      &quot;email&quot;: &quot;test@example.com&quot;<br>    }<br>  ],<br>  &quot;products&quot;: [<br>    {<br>      &quot;id&quot;: 1,<br>      &quot;name&quot;: &quot;Test Product&quot;,<br>      &quot;description&quot;: &quot;Test&quot;,<br>      &quot;price&quot;: 99.99,<br>      &quot;stock&quot;: 10<br>    }<br>  ]<br>}</pre><h4>3. Rate Limiting Test</h4><pre>#!/bin/bash<br>echo &quot;Rate limiting test starting...&quot;<br>for i in {1..10}; do<br>  echo &quot;Request $i:&quot;<br>  response=$(curl -s -w &quot;%{http_code}&quot; http://localhost:8000/api/dashboard)<br>  status_code=&quot;${response: -3}&quot;<br>  echo &quot;Status Code: $status_code&quot;<br>  <br>  if [ &quot;$status_code&quot; = &quot;429&quot; ]; then<br>    echo &quot;Rate limit exceeded!&quot;<br>    break<br>  fi<br>  <br>  sleep 1<br>done</pre><h4>4. Authentication Test</h4><pre># Generate JWT token<br>TOKEN=$(node -e &quot;console.log(require(&#39;jsonwebtoken&#39;).sign({user:&#39;test&#39;}, &#39;my-krakend-secret&#39;, {algorithm:&#39;HS256&#39;}))&quot;)<br><br># Test with valid token<br>curl &quot;http://localhost:8000/api/dashboard?access_token=$TOKEN&quot;<br><br># Test with invalid token<br>curl &quot;http://localhost:8000/api/dashboard?access_token=invalid&quot;</pre><h3>📊 Monitoring and Debugging</h3><h4>Health Check</h4><pre># KrakenD health check<br>curl http://localhost:8000/__health<br><br># Expected response:<br>{<br>  &quot;status&quot;: &quot;ok&quot;,<br>  &quot;timestamp&quot;: &quot;2024-01-01T00:00:00Z&quot;<br>}</pre><h4>Log Monitoring</h4><pre># Monitor KrakenD logs<br>docker-compose logs -f krakend<br><br># Filter specific endpoint logs<br>docker-compose logs krakend | grep &quot;/api/dashboard&quot;</pre><h4>Performance Monitoring</h4><pre># Response time test<br>curl -w &quot;Total time: %{time_total}s\n&quot; http://localhost:8000/api/dashboard<br><br># Load test (with Apache Bench)<br>ab -n 100 -c 10 http://localhost:8000/api/dashboard</pre><h3>🚀 Advanced Features</h3><h4>1. Request/Response Transformation</h4><pre>{<br>  &quot;endpoint&quot;: &quot;/api/products/v2&quot;,<br>  &quot;method&quot;: &quot;GET&quot;,<br>  &quot;extra_config&quot;: {<br>    &quot;modifier/martian&quot;: {<br>      &quot;fifo.Group&quot;: {<br>        &quot;scope&quot;: [&quot;request&quot;, &quot;response&quot;],<br>        &quot;aggregateErrors&quot;: true,<br>        &quot;modifiers&quot;: [<br>          {<br>            &quot;header.Modifier&quot;: {<br>              &quot;scope&quot;: [&quot;request&quot;],<br>              &quot;name&quot;: &quot;X-API-Version&quot;,<br>              &quot;value&quot;: &quot;2.0&quot;<br>            }<br>          }<br>        ]<br>      }<br>    }<br>  },<br>  &quot;backend&quot;: [<br>    {<br>      &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>      &quot;host&quot;: [&quot;http://products-service:8081&quot;]<br>    }<br>  ]<br>}</pre><h4>2. Caching</h4><pre>{<br>  &quot;endpoint&quot;: &quot;/api/products/cached&quot;,<br>  &quot;method&quot;: &quot;GET&quot;,<br>  &quot;extra_config&quot;: {<br>    &quot;proxy/http&quot;: {<br>      &quot;cache_ttl&quot;: &quot;1h&quot;<br>    }<br>  },<br>  &quot;backend&quot;: [<br>    {<br>      &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>      &quot;host&quot;: [&quot;http://products-service:8081&quot;]<br>    }<br>  ]<br>}</pre><h4>3. Load Balancing</h4><pre>{<br>  &quot;endpoint&quot;: &quot;/api/products/balanced&quot;,<br>  &quot;method&quot;: &quot;GET&quot;,<br>  &quot;backend&quot;: [<br>    {<br>      &quot;url_pattern&quot;: &quot;/api/products&quot;,<br>      &quot;host&quot;: [<br>        &quot;http://products-service-1:8081&quot;,<br>        &quot;http://products-service-2:8081&quot;,<br>        &quot;http://products-service-3:8081&quot;<br>      ],<br>      &quot;disable_host_sanitize&quot;: false<br>    }<br>  ]<br>}</pre><h3>🔒 Security Best Practices</h3><h4>1. CORS Configuration</h4><pre>{<br>  &quot;extra_config&quot;: {<br>    &quot;security/cors&quot;: {<br>      &quot;allow_origins&quot;: [&quot;https://yourdomain.com&quot;],<br>      &quot;allow_methods&quot;: [&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELETE&quot;],<br>      &quot;allow_headers&quot;: [&quot;Content-Type&quot;, &quot;Authorization&quot;],<br>      &quot;expose_headers&quot;: [&quot;X-Total-Count&quot;],<br>      &quot;max_age&quot;: &quot;12h&quot;<br>    }<br>  }<br>}</pre><h4>2. Rate Limiting Strategies</h4><pre>{<br>  &quot;extra_config&quot;: {<br>    &quot;qos/ratelimit/router&quot;: {<br>      &quot;max_rate&quot;: 100,<br>      &quot;every&quot;: &quot;1m&quot;,<br>      &quot;client_max_rate&quot;: 10,<br>      &quot;strategy&quot;: &quot;ip&quot;<br>    }<br>  }<br>}</pre><h4>3. JWT Token Validation</h4><pre>{<br>  &quot;extra_config&quot;: {<br>    &quot;auth/validator&quot;: {<br>      &quot;alg&quot;: &quot;RS256&quot;,<br>      &quot;jwk_url&quot;: &quot;https://your-auth-server/.well-known/jwks.json&quot;,<br>      &quot;cache_ttl&quot;: &quot;1h&quot;,<br>      &quot;issuer&quot;: &quot;https://your-auth-server.com&quot;,<br>      &quot;audience&quot;: [&quot;your-api-audience&quot;]<br>    }<br>  }<br>}</pre><h3>📈 Performance Optimization</h3><h4>1. Connection Pooling</h4><pre>{<br>  &quot;extra_config&quot;: {<br>    &quot;proxy/http&quot;: {<br>      &quot;max_idle_conns&quot;: 100,<br>      &quot;max_idle_conns_per_host&quot;: 10,<br>      &quot;idle_conn_timeout&quot;: &quot;90s&quot;<br>    }<br>  }<br>}</pre><h4>2. Response Compression</h4><pre>{<br>  &quot;extra_config&quot;: {<br>    &quot;proxy/http&quot;: {<br>      &quot;gzip&quot;: true<br>    }<br>  }<br>}</pre><h4>3. Timeout Configuration</h4><pre>{<br>  &quot;extra_config&quot;: {<br>    &quot;proxy/http&quot;: {<br>      &quot;timeout&quot;: &quot;30s&quot;,<br>      &quot;dialer_timeout&quot;: &quot;10s&quot;<br>    }<br>  }<br>}</pre><h3>🐛 Troubleshooting</h3><h4>Common Errors and Solutions</h4><p><strong>1. Connection Refused</strong></p><pre># Check if backend services are running<br>docker-compose ps<br><br># Check service logs<br>docker-compose logs users-service<br>docker-compose logs products-service</pre><p><strong>2. JWT Token Errors</strong></p><pre># Check token format<br>echo &quot;your-token&quot; | cut -d&#39;.&#39; -f2 | base64 -d<br><br># Check if secret key is correct<br># The secret in KrakenD configuration must be the same as the secret used when creating the token</pre><p><strong>3. Rate Limiting Issues</strong></p><pre># Check rate limit status<br>curl -I http://localhost:8000/api/dashboard<br><br># Check X-RateLimit-* headers<br>curl -v http://localhost:8000/api/dashboard</pre><h3>📚 Learning Resources</h3><h4>Official Documentation</h4><ul><li><a href="https://www.krakend.io/docs/">KrakenD Official Documentation</a></li><li><a href="https://www.krakend.io/schema/v3.json">KrakenD Configuration Schema</a></li><li><a href="https://github.com/krakendio/krakend-ce">KrakenD GitHub Repository</a></li></ul><h4>Articles &amp; Video Tutorials</h4><ul><li><a href="https://siriusstar17.medium.com/krakend-mikro-servis-mimarisinde-kolayl%C4%B1k-49881c2f9208">KrakenD : Mikro Servis Mimarisinde Kolaylık</a></li><li><a href="https://www.youtube.com/c/KrakenDAPIGateway">KrakenD API Gateway</a> — Video Channel</li><li><a href="https://piotrminkowski.com/2021/02/23/microservices-with-micronaut-krakend-and-consul/">Microservices with Micronaut, KrakenD and Consul</a></li></ul><h4>Community</h4><ul><li><a href="https://community.krakend.io/">KrakenD Community Forum</a></li><li><a href="https://stackoverflow.com/questions/tagged/krakend">Stack Overflow — KrakenD</a></li></ul><h3>🎯 Conclusion</h3><p>In this article, we examined in detail how to use KrakenD API Gateway using the <a href="https://github.com/Muhammederendemir/spring-boot-krakend-api-gateway">Spring Boot + KrakenD API Gateway</a> project as an example.</p><h4>What We Learned:</h4><ul><li>✅ Basic routing configuration</li><li>✅ API aggregation techniques</li><li>✅ Rate limiting implementation</li><li>✅ JWT authentication integration</li><li>✅ Docker deployment</li><li>✅ Monitoring and debugging</li><li>✅ Performance optimization</li><li>✅ Security best practices</li></ul><h4>Next Steps:</h4><ol><li><strong>Load Balancing</strong> implementation</li><li><strong>Circuit Breaker</strong> pattern</li><li><strong>API Versioning</strong> strategies</li><li><strong>Distributed Tracing</strong> integration</li><li><strong>Metrics Collection</strong> (Prometheus/Grafana)</li></ol><p>You can create powerful, scalable, and secure API Gateways with KrakenD. You can take your microservices architecture to the next level by applying what you learned in this article to your own projects.</p><p><strong>Note:</strong> This article is continuously updated. The article will be updated as new features and best practices are added to KrakenD.</p><h3>📞 Contact and Contribution</h3><p>For questions or suggestions about this article:</p><ul><li><a href="https://github.com/Muhammederendemir/spring-boot-krakend-api-gateway/issues">GitHub Issues</a></li><li><a href="https://github.com/Muhammederendemir/spring-boot-krakend-api-gateway/discussions">GitHub Discussions</a></li></ul><p>Don’t forget to give a ⭐ star if you liked the project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=006f021bf029" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Efficient Embedding Service with Sentence-Transformers: A Comprehensive Tutorial]]></title>
            <link>https://muhammederendemir.medium.com/building-an-efficient-embedding-service-with-sentence-transformers-a-comprehensive-tutorial-e2f69000f5aa?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2f69000f5aa</guid>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[vector]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 10:58:52 GMT</pubDate>
            <atom:updated>2025-07-24T01:41:59.857Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/740/0*ubC5dt6dYk1c1ZSd" /><figcaption><a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.freepik.com%2Ffree-photos-vectors%2Fai-background&amp;psig=AOvVaw35U85Nn51i14X_69MAi9yP&amp;ust=1751194835794000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBQQjRxqFwoTCICmxaL7k44DFQAAAAAdAAAAABAE">img</a></figcaption></figure><p>In today’s advanced Natural Language Processing (NLP) applications, the process of transforming texts into numerical vectors that computers can understand, known as embedding, is an indispensable step. However, when working with high-volume text data or in a system with high demand, these embedding operations must be fast and resource-efficient. Leveraging the Sentence-Transformers library, you will learn step-by-step how to build your own efficient text embedding service suitable for multiprocessing environments.</p><h3>Why Do We Need Our Own Embedding Service?</h3><p>Consider a web application, a search engine, or a large-scale data analysis platform. In such systems, you might need to perform embedding operations for hundreds or thousands of texts simultaneously. Reloading a heavy model for every request significantly degrades performance and increases memory consumption. Furthermore, managing limited resources like GPUs efficiently can become complex. Our own optimized embedding service overcomes these challenges by:</p><ul><li><strong>Reducing Model Loading Cost:</strong> Instead of reloading the model for every request, it loads it only once (or once per process).</li><li><strong>Optimizing Resource Utilization:</strong> It effectively uses GPUs or other accelerators.</li><li><strong>Improving Response Time:</strong> Techniques like caching drastically reduce latency for recurring requests.</li><li><strong>Enabling Scalability:</strong> It allows for parallel processing in multiprocessing or server-based environments.</li></ul><h3>Project Cornerstones and Architectural Approach</h3><p>Let’s understand the core ideas and technical approaches to build our own solution:</p><ol><li><strong>Sentence-Transformers Library:</strong> This is a powerful and practical Python library developed for easily creating semantic embeddings of texts. The project utilizes the all-MiniLM-L6-v2 model, which is widely used and performs well.</li><li><strong>Multiprocessing:</strong> Python’s multiprocessing module allows for parallel operations by utilizing multiple CPU cores or GPUs. Since each process has its own memory space, it prevents conflicts between model copies, especially on GPUs.</li><li><strong>LRU (Least Recently Used) Caching:</strong> Instead of recomputing embeddings for frequently repeated or previously processed texts, this mechanism stores these results in a cache and serves them quickly when requested again. This significantly boosts performance, especially in scenarios with high data redundancy. It can be easily implemented in Python using functools.lru_cache.</li><li><strong>Automatic Hardware Detection:</strong> It automatically determines whether an NVIDIA GPU (CUDA), Apple Silicon GPU (MPS), or just a CPU is available on the system, and loads the model onto the most suitable hardware. This flexibility ensures the code runs with optimal performance in different deployment environments.</li><li><strong>Detailed Logging:</strong> Logging critical information such as process ID (PID), embedding requests, and model loading/unloading statuses is essential for troubleshooting, performance monitoring, and understanding system behavior, especially in a multiprocessing environment.</li></ol><h3>Step-by-Step: Building Your Own Efficient Embedding Service</h3><p>Now, let’s see how we can implement these principles in our own code.</p><h4>Step 1: Install Required Libraries</h4><p>First, you need to install the essential libraries for our project in your Python environment:</p><pre>pip install torch sentence-transformers<br>```torch` is the PyTorch deep learning framework, and the `sentence-transformers` model runs on top of it.</pre><pre>#### Step 2: Create the Core Embedding Service Class (`EmbeddingService`)<br>In this step, we will create our main class responsible for loading the model, handling hardware detection, and performing embedding operations. We will also implement a &quot;Singleton&quot; pattern to ensure the model is loaded only once per Python process.<br>```python<br>import torch<br>from sentence_transformers import SentenceTransformer<br>import logging<br>import os<br>from functools import lru_cache<br>import threading<br># --- Logging Configuration ---<br># Create logs directory<br>LOG_DIR = &quot;logs&quot;<br>os.makedirs(LOG_DIR, exist_ok=True)<br># Basic logging configuration<br># Each log message will contain time, process ID, level, and message.<br>logging.basicConfig(<br>    filename=os.path.join(LOG_DIR, &quot;embedding.log&quot;),<br>    level=logging.INFO, # Log messages at INFO level and above<br>    format=&#39;%(asctime)s - PID:%(process)d - %(levelname)s - %(message)s&#39;<br>)<br># --- EmbeddingService Class Definition ---<br>class EmbeddingService:<br>    # This variable will ensure there&#39;s only one instance of EmbeddingService per process.<br>    _instance_per_process = None<br>    _lock = threading.Lock() # For thread-safe instance creation in multi-threaded environments<br>    def __new__(cls, model_name: str = &#39;all-MiniLM-L6-v2&#39;):<br>        &quot;&quot;&quot;<br>        Implements the Singleton pattern to ensure only one instance of EmbeddingService<br>        exists per process, loading the model only once.<br>        &quot;&quot;&quot;<br>        with cls._lock: # Use a lock for thread safety<br>            if cls._instance_per_process is None:<br>                # If no instance has been created for this process yet, create a new one.<br>                cls._instance_per_process = super(EmbeddingService, cls).__new__(cls)<br>                cls._instance_per_process.model_name = model_name<br>                cls._instance_per_process._load_model() # Load the model<br>            return cls._instance_per_process<br>    def _load_model(self):<br>        &quot;&quot;&quot;<br>        Loads the Sentence-Transformers model and places it on the most suitable hardware (CUDA, MPS, CPU).<br>        &quot;&quot;&quot;<br>        # --- Hardware Detection ---<br>        if torch.cuda.is_available():<br>            device = &quot;cuda&quot;<br>            logging.info(f&quot;CUDA (GPU) available. Model will be loaded on &#39;{device}&#39;. PID: {os.getpid()}&quot;)<br>        elif torch.backends.mps.is_available() and torch.backends.mps.is_built():<br>            device = &quot;mps&quot;<br>            logging.info(f&quot;Apple Silicon (MPS) available. Model will be loaded on &#39;{device}&#39;. PID: {os.getpid()}&quot;)<br>        else:<br>            device = &quot;cpu&quot;<br>            logging.info(f&quot;GPU/MPS not found. Model will be loaded on &#39;{device}&#39;. PID: {os.getpid()}&quot;)<br>        logging.info(f&quot;Loading model &#39;{self.model_name}&#39; on &#39;{device}&#39;... PID: {os.getpid()}&quot;)<br>        try:<br>            self.model = SentenceTransformer(self.model_name, device=device)<br>            logging.info(f&quot;Model &#39;{self.model_name}&#39; successfully loaded. PID: {os.getpid()}&quot;)<br>        except Exception as e:<br>            logging.error(f&quot;Error loading model &#39;{self.model_name}&#39;: {e}. PID: {os.getpid()}&quot;)<br>            raise # Re-raise the exception<br>    @lru_cache(maxsize=512) # Cache up to 512 most recently used embeddings.<br>    def get_embedding(self, text: str):<br>        &quot;&quot;&quot;<br>        Generates an embedding for the given text.<br>        Thanks to LRU caching, it avoids recomputing for the same text.<br>        &quot;&quot;&quot;<br>        # Log the request<br>        logging.info(f&quot;Embedding request received for text: &#39;{text[:70]}{&#39;...&#39; if len(text) &gt; 70 else &#39;&#39;}&#39;. PID: {os.getpid()}&quot;)<br>        try:<br>            # Encode the text using the model to create embeddings<br>            embeddings = self.model.encode(text, convert_to_tensor=True)<br>            logging.info(f&quot;Embedding successfully created for text: &#39;{text[:70]}{&#39;...&#39; if len(text) &gt; 70 else &#39;&#39;}&#39;. PID: {os.getpid()}&quot;)<br>            # Convert PyTorch tensor to a list for JSON serialization and easy use<br>            return embeddings.tolist()<br>        except Exception as e:<br>            logging.error(f&quot;Error creating embedding for text: &#39;{text[:70]}{&#39;...&#39; if len(text) &gt; 70 else &#39;&#39;}&#39;: {e}. PID: {os.getpid()}&quot;)<br>            return None # Return None on error or provide an appropriate error signal.</pre><p><strong>Code Explanation:</strong></p><p><strong>Logging Configuration:</strong> We define the logging level, file path, and format using logging.basicConfig. The % (process)d format specifier ensures that the process ID (PID) is included in each log message, which is crucial for tracking in a multiprocessing environment.</p><p><strong>EmbeddingService Class:</strong></p><ul><li><strong>Singleton Pattern (</strong>__new__<strong> and </strong>_instance_per_process<strong>):</strong> This structure ensures that only one instance of the EmbeddingService class is created within each Python process when using the multiprocessing module. This guarantees that the model (e.g., all-MiniLM-L6-v2) is loaded into memory only once per worker process. This optimizes memory footprint and reduces model loading latency. The use of threading.Lock prevents race conditions that could occur if multiple threads within the same process try to call the __new__ method simultaneously.</li><li>_load_model()<strong>:</strong> This method automatically detects the most suitable hardware (CUDA GPU, Apple Silicon MPS, or CPU by default) using torch.cuda.is_available() and torch.backends.mps.is_available(). It loads the model onto the detected device and logs this status. If an error occurs during model loading, it logs the error and re-raises it.</li><li>@lru_cache(maxsize=512)<strong>:</strong> This Python decorator automatically caches the results of the get_embedding method. This means that if the get_embedding method is called again with the same text, the embedding process is not re-executed; instead, the previously computed result is quickly returned from the cache. The maxsize parameter determines the maximum number of distinct texts whose results will be stored in the cache (512 in this example). This dramatically improves performance, especially in applications where text repetitions are frequent.</li><li>get_embedding(self, text: str)<strong>:</strong> This method converts the given text into numerical embeddings using self.model.encode(). We set convert_to_tensor=True to get a PyTorch tensor, which is then converted to a Python list using tolist() for easy JSON serialization and use.</li></ul><h4>Step 2: Example Usage in a Multiprocessing Environment</h4><p>Now, let’s create a simple example demonstrating how multiple parallel processes can utilize this EmbeddingService class. This simulates a scenario similar to a web server with multiple worker processes.</p><pre>from multiprocessing import Process, current_process<br>import time<br>import random</pre><pre># Copy the EmbeddingService class and logging settings from above here<br># OR, save the above code to a separate Python file (e.g., `embedding_service_module.py`) and<br># import it as: `from embedding_service_module import EmbeddingService, logging, LOG_DIR`<br># For this tutorial, copying is simpler.<br># ... (EmbeddingService class and logging settings go here) ...<br>def worker_task(worker_id: int, texts_for_worker: list[str]):<br>    &quot;&quot;&quot;<br>    The task to be executed by each worker process.<br>    It creates its own EmbeddingService instance and embeds texts.<br>    &quot;&quot;&quot;<br>    process_name = current_process().name # Get the process name<br>    logging.info(f&quot;Worker {worker_id} (&#39;{process_name}&#39;) started. PID: {os.getpid()}&quot;)<br>    # Each process creates its own EmbeddingService instance.<br>    # Thanks to the Singleton pattern, the model will only be loaded once.<br>    service = EmbeddingService()<br>    for i, text in enumerate(texts_for_worker):<br>        try:<br>            embedding = service.get_embedding(text)<br>            if embedding:<br>                # print(f&quot;Worker {worker_id} - Text {i}: {text[:40]}... Embedding Size: {len(embedding)}&quot;)<br>                pass # Suppressed output to keep console clean, check logs<br>            else:<br>                logging.warning(f&quot;Worker {worker_id} - Failed to create embedding for text: &#39;{text[:40]}...&#39;.&quot;)<br>            time.sleep(random.uniform(0.05, 0.2)) # Random delay to simulate processing<br>        except Exception as e:<br>            logging.error(f&quot;Worker {worker_id} - General error for text: &#39;{text[:40]}...&#39;: {e}&quot;)<br>    logging.info(f&quot;Worker {worker_id} (&#39;{process_name}&#39;) completed. PID: {os.getpid()}&quot;)<br>if __name__ == &#39;__main__&#39;:<br>    # Sample texts (some are repeated to demonstrate cache effectiveness)<br>    sample_texts = [<br>        &quot;This is an example sentence.&quot;,<br>        &quot;The Python programming language is very powerful and used in many fields.&quot;,<br>        &quot;Natural Language Processing (NLP) is one of the technologies of the future.&quot;,<br>        &quot;This is an example sentence.&quot;, # Repeated text<br>        &quot;Machine learning projects are exciting and involve deep learning.&quot;,<br>        &quot;Sentence-Transformers is a great library for text embeddings.&quot;,<br>        &quot;The field of data science is growing rapidly.&quot;,<br>        &quot;The Python programming language is very powerful and used in many fields.&quot; # Repeated text<br>    ]<br>    num_workers = 4 # Number of parallel processes to run<br>    print(f&quot;\nStarting {num_workers} worker processes. Logs will be saved to &#39;logs/embedding.log&#39;.&quot;)<br>    print(&quot;Please monitor the &#39;logs/embedding.log&#39; file while the program runs.\n&quot;)<br>    processes = []<br>    # Distribute texts among workers (each worker can receive all texts,<br>    # or in a more realistic scenario, different subsets)<br>    texts_per_worker = sample_texts # For simplicity, each worker gets all texts<br>    for i in range(num_workers):<br>        # Each Process object acts like a separate Python interpreter.<br>        # target: the function the process will execute<br>        # args: arguments to be passed to the target function<br>        p = Process(target=worker_task, args=(i + 1, texts_per_worker))<br>        processes.append(p)<br>        p.start() # Start the process<br>    # The main process waits for all child processes to complete<br>    for p in processes:<br>        p.join()<br>    print(&quot;\nAll worker processes completed. Check &#39;logs/embedding.log&#39; for details.&quot;)<br>    print(&quot;You should observe cache hits and that the model is loaded only once per process.&quot;)</pre><p>if __name__ == &#39;__main__&#39;:<strong> Block Explanation:</strong></p><ul><li>sample_texts<strong>:</strong> Contains example texts for embedding. By repeating some texts, you can observe how the LRU cache works.</li><li>num_workers<strong>:</strong> Determines how many parallel worker processes will be started. Typically, choosing a value close to the number of CPU cores in your system is a good starting point.</li><li>Process(target=worker_task, args=(i + 1, texts_per_worker))<strong>:</strong> We create a Process object from Python&#39;s multiprocessing module. Each Process object will run the worker_task function in its own separate process.</li><li>p.start()<strong>:</strong> Starts each created child process. Child processes run their tasks independently of the main process.</li><li>p.join()<strong>:</strong> Ensures that the main process waits for all launched child processes to complete. This guarantees that the program does not exit before all work is finished.</li></ul><p>When you run this code, open and examine the logs/embedding.log file. You will see log messages from different process IDs (PIDs). Even though each worker process creates its own EmbeddingService instance, thanks to the Singleton pattern, you will only see the &quot;Loading model...&quot; message once for each PID. Additionally, for repeated texts, when you see &quot;Embedding request received&quot; followed by &quot;Embedding successfully created,&quot; you can understand that this request was served from the cache, meaning the model was not re-executed (this might be hard to notice due to high speed, but this is the internal mechanism).</p><h3>Advantages and Benefits of This Approach</h3><p>The embedding service architecture discussed in this tutorial offers several significant advantages, especially for NLP systems requiring high performance and scalability:</p><ul><li><strong>Efficient Resource Utilization:</strong> Loading the model only once per process prevents wasteful consumption of valuable resources like GPU memory.</li><li><strong>Low Latency:</strong> LRU caching reduces embedding time for repeated texts to almost zero, which is critical for user experience.</li><li><strong>High Throughput:</strong> Parallel execution of multiple processes allows for more texts to be processed simultaneously, increasing the overall throughput of the system.</li><li><strong>Robustness and Observability:</strong> Detailed logging makes it easier to monitor system behavior, diagnose performance issues, and debug errors.</li><li><strong>Flexibility:</strong> Automatic hardware detection allows you to run the code in different hardware environments (CPU, NVIDIA GPU, Apple Silicon) without additional configuration.</li></ul><h3>Next Steps and Enhancements</h3><p>The basic embedding service we built in this article provides a strong foundation for more complex and production-ready systems. Here are some points you might consider to further enhance this structure:</p><ol><li><strong>REST API Integration:</strong> Exposing this service via a web API (using, for example, Flask, FastAPI, or Django REST Framework) allows other applications to easily request text embeddings.</li><li><strong>Model Management:</strong> Add the ability to manage multiple models simultaneously for different NLP tasks or languages. Allow the user to specify which model to use via an API request.</li><li><strong>Asynchronous Processing:</strong> Leverage asynchronous web frameworks like FastAPI to achieve better performance in I/O-bound operations.</li><li><strong>Error Handling and Resilience:</strong> Implement more comprehensive error catching and notification mechanisms for issues like model loading failures, invalid inputs, or other runtime errors.</li><li><strong>Queue System Integration:</strong> If you expect a very high request volume, consider using a message queue system like Redis Queue (RQ) or Celery to queue requests and balance the workload.</li><li><strong>Containerization (Docker):</strong> Packaging the application into a Docker container simplifies its consistent deployment and execution across different environments (development, testing, production).</li><li><strong>Distributed Environments:</strong> Explore scaling the system to multiple servers using container orchestration tools like Kubernetes to build a highly available system.</li></ol><p>A ‘sentence-transformer-embedding-service’ project serves as an excellent example of how effective and optimized solutions can be developed for practical problems. By following the steps in this article and implementing the suggested enhancements, you can get a solid start on building high-performance and scalable text embedding services for your own projects.</p><p>Good luck!</p><h3>References</h3><p>This article was prepared using the following sources:</p><ul><li><strong>Demir, Muhammed Eren</strong> (n.d.). <em>Sentence-Transformer Embedding Service</em> [GitHub repository]. Retrieved from <a href="https://github.com/Muhammederendemir/sentence-transformer-embedding-service">https://github.com/Muhammederendemir/sentence-transformer-embedding-service</a></li><li><strong>Reimers, N., &amp; Gurevych, I.</strong> (n.d.). <em>Sentence-Transformers</em> [Python package]. PyPI. Retrieved from <a href="https://pypi.org/project/sentence-transformers/">https://pypi.org/project/sentence-transformers/</a></li><li><strong>Google.</strong> (n.d.). <em>Gemini</em> [Artificial intelligence model].</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2f69000f5aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[n8n Docker Installation with PostgreSQL & Nginx]]></title>
            <link>https://muhammederendemir.medium.com/n8n-docker-installation-with-postgresql-nginx-275efc16fdc7?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/275efc16fdc7</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[project-management-tool]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Wed, 28 May 2025 10:17:48 GMT</pubDate>
            <atom:updated>2025-06-22T12:00:06.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tzE0bzaTEV4y5ZM8.png" /><figcaption><a href="https://blog.n8n.io/content/images/size/w1200/2024/10/ai-workflow-automationA--1-.png">Image</a></figcaption></figure><p>n8n is an open-source and customizable workflow automation tool. By using Docker, you can host n8n on your own server quickly and securely. This guide provides step-by-step instructions for setting up n8n with docker, including postgresql and nginx integration.</p><h3>🐳 Prerequisites</h3><p>Before you start, ensure the following are installed:</p><ul><li>docker</li><li>docker-compose</li><li>a domain name (e.g. n8n.yourdomain.com)</li><li>ssl certificates (you can use let’s encrypt)</li></ul><h3>📦 Project Structure</h3><p>Your folder should include:</p><pre>n8n-project/<br>├── docker-compose.yml<br>├── nginx.conf<br>└── certs/<br>    ├── fullchain.pem<br>    └── privkey.pem</pre><h3>⚙️ Environment Variables</h3><p>Important environment variables used in docker-compose:</p><ul><li>`DB_TYPE`: sets the database type (use `postgresdb`)</li><li>`N8N_BASIC_AUTH_ACTIVE`: enables basic authentication</li><li>`N8N_BASIC_AUTH_USER`: username for authentication</li><li>`N8N_BASIC_AUTH_PASSWORD`: password for authentication</li><li>`N8N_HOST`: the domain name</li><li>`N8N_PROTOCOL`: use `https`</li><li>`WEBHOOK_TUNNEL_URL`: full public URL</li></ul><h3>🧩 Updated docker-compose File</h3><p>Below is the updated `<strong>docker-compose.yml</strong>` with `<strong>n8n</strong>`, `<strong>postgres</strong>`, and `<strong>nginx</strong>`:</p><pre>version: &quot;3.8&quot;<br><br>services:<br>  n8n:<br>    image: n8nio/n8n<br>    restart: always<br>    environment:<br>      - DB_TYPE=postgresdb<br>      - DB_POSTGRESDB_HOST=postgres<br>      - DB_POSTGRESDB_PORT=5432<br>      - DB_POSTGRESDB_DATABASE=n8n<br>      - DB_POSTGRESDB_USER=n8n<br>      - DB_POSTGRESDB_PASSWORD=n8npass<br>      - N8N_BASIC_AUTH_ACTIVE=true<br>      - N8N_BASIC_AUTH_USER=admin<br>      - N8N_BASIC_AUTH_PASSWORD=adminpass<br>      - N8N_HOST=n8n.yourdomain.com<br>      - N8N_PORT=5678<br>      - N8N_PROTOCOL=https<br>      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true <br>      - WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com/<br>    ports:<br>      - &quot;5678:5678&quot;<br>    volumes:<br>      - n8n_data:/home/node/.n8n<br>    depends_on:<br>      - postgres<br><br>  postgres:<br>    image: postgres:14<br>    restart: always<br>    environment:<br>      - POSTGRES_USER=n8n<br>      - POSTGRES_PASSWORD=n8npass<br>      - POSTGRES_DB=n8n<br>    volumes:<br>      - postgres_data:/var/lib/postgresql/data<br><br>  nginx:<br>    image: nginx:alpine<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - ./nginx.conf:/etc/nginx/nginx.conf:ro<br>      - ./certs:/etc/ssl/certs:ro<br>    depends_on:<br>      - n8n<br><br>volumes:<br>  postgres_data:<br>  n8n_data:</pre><h3>🔐 Nginx Configurationü</h3><p>Make sure `<strong>nginx.conf</strong>` is configured to proxy https requests to n8n:</p><pre>events {<br>  worker_connections 1024;<br>}<br><br>http {<br>  include       mime.types;<br>  default_type  application/octet-stream;<br><br>  access_log  /var/log/nginx/access.log;<br>  error_log   /var/log/nginx/error.log;<br><br>  sendfile        on;<br>  keepalive_timeout  65;<br><br>  server {<br>      listen 443 ssl http2;<br>      server_name n8n.yourdomain.com;<br><br>      ssl_certificate /etc/ssl/certs/fullchain.pem;<br>      ssl_certificate_key /etc/ssl/certs/privkey.pem;<br><br>      ssl_protocols TLSv1.2 TLSv1.3;<br>      ssl_ciphers HIGH:!aNULL:!MD5;<br><br>      access_log /var/log/nginx/n8n_access.log;<br>      error_log /var/log/nginx/n8n_error.log;<br><br>      location / {<br>          proxy_pass http://n8n:5678;<br>          proxy_http_version 1.1;<br>          proxy_set_header Upgrade $http_upgrade;<br>          proxy_set_header Connection &quot;upgrade&quot;;<br><br>          proxy_set_header Host $host;<br>          proxy_set_header X-Real-IP $remote_addr;<br>          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>          proxy_set_header X-Forwarded-Proto $scheme;<br><br>          proxy_read_timeout 90;<br>          proxy_redirect off;<br>      }<br>  }<br><br>  server {<br>      listen 80;<br>      server_name n8n.yourdomain.com;<br>      return 301 https://$host$request_uri;<br>  }<br>}</pre><h3>🧪 Running the Stack</h3><p>Start your services with:</p><pre>docker-compose up -d</pre><h3>🧪 Adding a Domain to the hosts File for Local Development</h3><p>If you do not own a real domain and simply want to test a custom domain like n8n.meddx.digital in your local development environment, you can add the following line to your operating system’s hosts file:</p><pre>127.0.0.1 n8n.yourdomain.com</pre><p>This allows your browser to resolve <a href="https://n8n.yourdomain.com/">https://n8n.yourdomain.com</a> to your local machine, making it possible to test reverse proxy setups (like Nginx) and domain-based configurations. Keep in mind that this change only affects your local machine and won’t make the domain accessible to others over the internet. If you’re using HTTPS, your browser may show a certificate warning — this is expected in a local environment and can be safely bypassed during development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DxrzFxon_HGZ1I8PKQIf4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tYQjXFMo2KgfNFeOcOWX2g.png" /></figure><h3>📝 Conclusion</h3><p>In this guide, we covered how to install n8n using Docker, step-by-step. Thanks to Docker and Docker Compose, you can host n8n on your own server efficiently and securely. After setup, explore n8n’s powerful automation features to enhance your workflows.</p><p>For more information, refer to the <a href="https://docs.n8n.io/">official n8n documentation</a>.</p><h4>🔗 Resources</h4><ul><li><a href="https://docs.n8n.io/hosting/installation/server-setups/docker-compose/">https://docs.n8n.io/hosting/installation/server-setups/docker-compose/</a></li><li><a href="https://docs.n8n.io/hosting/installation/docker/">https://docs.n8n.io/hosting/installation/docker/</a></li><li><a href="https://docs.docker.com/desktop/setup/install/linux/">https://docs.docker.com/desktop/setup/install/linux/</a></li><li><a href="https://www.docker.com/blog/how-to-use-the-official-nginx-docker-image/">https://www.docker.com/blog/how-to-use-the-official-nginx-docker-image/</a></li></ul><blockquote><em>This article was prepared with the help of ChatGPT.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=275efc16fdc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google OSV-Scanner: Open Source Vulnerability Scanner]]></title>
            <link>https://muhammederendemir.medium.com/google-osv-scanner-open-source-vulnerability-scanner-35dee7b00509?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/35dee7b00509</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Thu, 15 May 2025 11:42:12 GMT</pubDate>
            <atom:updated>2025-05-19T08:54:59.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mluhp2LDhVCufVPJicqIoA.png" /><figcaption><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6PUzUrP3tilDmf1ImsYz5ZtThxk5hWRnep4C10m41ug7qdkfdRWMUId22XsYQkjLGtmTI0LB3kUMNjglyn3po038pYZhVXvclfXX4Lk6Kgg0CY7tM9gI9f1-Rmy1evzykydFUEIorRMFMcRcS8Z6RDk0fa65NJzM0GKOsdVOa9FLaQkTTehIYUyEzLi8/s1600/OSS-Banner-OSV.png">Image</a></figcaption></figure><p>While open-source libraries greatly simplify our development process, tracking their security vulnerabilities can be quite challenging. <strong>Google OSV-Scanner</strong> is a CLI tool designed to help detect known vulnerabilities in your project dependencies using the OSV (Open Source Vulnerabilities) database.</p><h4>🔍 What is OSV-Scanner?</h4><p>OSV-Scanner analyzes project dependencies (such as package-lock.json, go.mod, requirements.txt) and checks whether they contain known vulnerabilities listed in the <a href="https://osv.dev/">OSV</a> database.</p><h4>🚀 Key Features</h4><ul><li>Multi-language and package manager support (npm, Go, Python, Maven, Rust, etc.)</li><li>Fast and simple to use</li><li>CI/CD ready</li><li>Real-time analysis using OSV API</li></ul><h4>📦 Supported Artifacts and Manifest Files</h4><p>The scanner supports various dependency files across programming languages:</p><ul><li><strong>JavaScript/Node.js:</strong> package-lock.json, yarn.lock, pnpm-lock.yaml</li><li><strong>Python:</strong> requirements.txt, Pipfile.lock, poetry.lock</li><li><strong>Go:</strong> go.mod, go.sum</li><li><strong>Java/Maven:</strong> pom.xml</li><li><strong>Rust:</strong> Cargo.lock</li><li><strong>Ruby:</strong> Gemfile.lock</li><li><strong>Dart:</strong> pubspec.lock</li><li><strong>Linux:</strong> .deb, .rpm and similar formats</li></ul><p>🔗 For full list:</p><p><a href="https://google.github.io/osv-scanner/supported-languages-and-lockfiles/#supported-artifacts">Supported Artifacts and Manifests</a></p><h3>🛠 Installation with Go</h3><h4>Installation Go</h4><p>Ensure Go is installed on your system:</p><pre>go version</pre><p>If not, download from: <a href="https://go.dev/dl/">https://go.dev/dl/</a></p><h4>🛠Installation with Go</h4><pre>go install github.com/google/osv-scanner/cmd/osv-scanner@latest<br>export PATH=”$PATH:$(go env GOPATH)/bin”<br>osv-scanner — help</pre><h4>📂 Project Scan</h4><pre>osv-scanner --recursive .<br># or<br>osv-scanner --lockfile=requirements.txt</pre><h4>🌐 Get HTML Output or Serve via Web</h4><p>You can generate or host scan results in HTML:</p><pre>osv-scanner scan --format html your/project/dir<br># or<br>osv-scanner scan --serve your/project/dir<br># Default port is 8000; use --port to change:<br>osv-scanner scan --serve --port 8080 your/project/dir</pre><p>📝 For other output types, visit:</p><p><a href="https://github.com/google/osv-scanner/blob/main/docs/output.md">osv-scanner/docs/output.md at main · google/osv-scanner</a></p><p>📝 Output:</p><p><a href="http://localhost:8000/">http://localhost:8000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0K54tHbNmG3chlHDB2vMvw.png" /></figure><h4>🔗 Resources</h4><ul><li><a href="https://osv.dev/">https://osv.dev</a></li><li><a href="https://github.com/google/osv-scanner">https://github.com/google/osv-scanner</a></li><li><a href="https://opensource.googleblog.com/2024/04/osv-and-helping-developers-fix-known-vulnerabilities.html">https://opensource.googleblog.com/2024/04/osv-and-helping-developers-fix-known-vulnerabilities.html</a></li></ul><blockquote><em>This article was prepared with the help of ChatGPT.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35dee7b00509" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Local LLMs with Spring Boot: Ollama and Spring Boot Application]]></title>
            <link>https://muhammederendemir.medium.com/integrating-local-llms-with-spring-boot-ollama-and-spring-boot-application-2a4f22a0b7fe?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a4f22a0b7fe</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Thu, 15 May 2025 11:38:40 GMT</pubDate>
            <atom:updated>2025-06-01T10:35:55.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MLN0tWcicVIYY7Jo.png" /><figcaption><a href="https://ollama.com/public/blog/embedding-models.png">image</a></figcaption></figure><h3>Introduction</h3><p>Large Language Models (LLMs) are at the center of modern artificial intelligence applications. However, most of these models are accessible only through cloud-based APIs, which introduces limitations related to cost, privacy, and internet connectivity requirements. Tools like Ollama provide a practical solution to these issues by enabling LLMs to run on local machines.</p><p>In this article, we’ll walk you through the step-by-step process of integrating Ollama’s powerful local LLM capabilities into your Spring Boot application. With this integration, you can add ChatGPT-like AI capabilities to your enterprise Java applications while keeping all your data under your control.</p><h3>What is Ollama?</h3><p>Ollama is a tool that allows you to run open-source LLMs (like Llama, Mistral, Vicuna) on local computers with ease. It provides a simple command-line interface and HTTP API, enabling developers to integrate these models into their own applications. Ollama optimizes the models to run efficiently even on standard computers.</p><h3>Project Structure</h3><p>The Spring Boot integration project described in this article includes the following core components:</p><ul><li><strong>Model Classes</strong>: Data structures required for communication with the Ollama API</li><li><strong>Service Layer</strong>: WebClient-based service that manages interaction with the Ollama API</li><li><strong>Controller</strong>: Controller class providing Rest API endpoints</li><li><strong>Application Configuration</strong>: Spring Boot configuration</li></ul><p>This project utilizes modern Java features and best practices from the Spring ecosystem to make Ollama’s local LLM capabilities available in Java applications.</p><h3>Step 1: Adding Required Dependencies</h3><p>The Spring Boot application’s pom.xml file includes these dependencies:</p><pre>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;<br>        &lt;artifactId&gt;lombok&lt;/artifactId&gt;<br>        &lt;optional&gt;true&lt;/optional&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><p>The spring-boot-starter-webflux is particularly important, as we&#39;ll be using WebClient for reactive communication with the Ollama API.</p><h3>Step 2: Creating Ollama API Model Classes</h3><p>First, we define model classes for the requests we’ll make to the Ollama API and the responses we’ll receive:</p><pre>@Data<br>@Builder<br>@NoArgsConstructor<br>@AllArgsConstructor<br>public class OllamaRequest {<br>    private String model;<br>    private String prompt;<br>    private Integer numPredict;<br>    private Double temperature;<br>    private Boolean stream;<br>}</pre><pre>@Data<br>@Builder<br>@NoArgsConstructor<br>@AllArgsConstructor<br>public class OllamaResponse {<br>    private String model;<br>    private String response;<br>    private Integer createdAt;<br>    private Boolean done;<br>}</pre><p>These classes represent the structure of requests we’ll make to the /api/generate endpoint of the Ollama API and the responses we&#39;ll receive from these requests.</p><h3>Step 3: Creating the Ollama Service Class</h3><p>We create a service class that will communicate with the Ollama API:</p><pre>@Service<br>public class OllamaService {</pre><pre>private final WebClient webClient;<br>    <br>    @Value(&quot;${ollama.api.url:http://localhost:11434}&quot;)<br>    private String ollamaApiUrl;<br>    <br>    public OllamaService() {<br>        this.webClient = WebClient.builder()<br>                .baseUrl(&quot;http://localhost:11434&quot;)<br>                .build();<br>    }<br>    <br>    public Mono&lt;OllamaResponse&gt; generateResponse(String model, String prompt) {<br>        OllamaRequest request = OllamaRequest.builder()<br>                .model(model)<br>                .prompt(prompt)<br>                .stream(false)<br>                .build();<br>        <br>        return webClient.post()<br>                .uri(&quot;/api/generate&quot;)<br>                .bodyValue(request)<br>                .retrieve()<br>                .bodyToMono(OllamaResponse.class);<br>    }<br>    <br>    public Mono&lt;String&gt; listModels() {<br>        return webClient.get()<br>                .uri(&quot;/api/tags&quot;)<br>                .retrieve()<br>                .bodyToMono(String.class);<br>    }<br>}</pre><p>This service class:</p><ul><li>Uses WebClient to make HTTP requests to the Ollama API</li><li>Sends a POST request to Ollama’s /api/generate endpoint to generate text</li><li>Sends a GET request to the /api/tags endpoint to list available models</li><li>Returns responses as Mono types, in line with Spring’s reactive programming model</li></ul><h3>Step 4: Creating the Controller Class</h3><p>We create a controller class that defines REST endpoints for accessing the Ollama API through our application:</p><pre>@RestController<br>@RequestMapping(&quot;/api/ollama&quot;)<br>public class OllamaController {</pre><pre>private final OllamaService ollamaService;<br>    <br>    @Autowired<br>    public OllamaController(OllamaService ollamaService) {<br>        this.ollamaService = ollamaService;<br>    }<br>    <br>    @PostMapping(&quot;/generate&quot;)<br>    public Mono&lt;ResponseEntity&lt;OllamaResponse&gt;&gt; generateResponse(<br>            @RequestParam String model,<br>            @RequestParam String prompt) {<br>        return ollamaService.generateResponse(model, prompt)<br>                .map(ResponseEntity::ok);<br>    }<br>    <br>    @GetMapping(&quot;/models&quot;)<br>    public Mono&lt;ResponseEntity&lt;String&gt;&gt; listModels() {<br>        return ollamaService.listModels()<br>                .map(ResponseEntity::ok);<br>    }<br>}</pre><p>This controller:</p><ul><li>Generates text using the specified model and prompt parameters via the /api/ollama/generate endpoint</li><li>Lists all available Ollama models via the /api/ollama/models endpoint</li><li>Provides endpoints compatible with reactive programming</li></ul><h3>Step 5: Configuration and Execution</h3><p>We configure the application using the application.properties file:</p><pre>server.port=8080<br>ollama.api.url=http://localhost:11434</pre><p>Before running the Spring Boot application, Ollama must be locally installed and at least one model must be downloaded:</p><pre># Start Ollama<br>ollama serve</pre><pre># Download a model (for example, llama3)<br>ollama pull llama3</pre><p>Then you can run the Spring Boot application:</p><pre>mvn spring-boot:run</pre><h3>Application Usage</h3><p>Once the application is running, you can use the following endpoints:</p><ol><li>To list available models:</li></ol><pre>GET http://localhost:8080/api/ollama/models</pre><ol><li>To generate text:</li></ol><pre>POST http://localhost:8080/api/ollama/generate?model=llama3&amp;prompt=Hello world</pre><h3>Real-World Scenarios and Use Cases</h3><p>This integration has many practical applications:</p><ol><li><strong>Content Creation Applications</strong>: Text summarization, content expansion, blog post generation</li><li><strong>Chat Assistants</strong>: Chatbots for internal corporate use</li><li><strong>Code Assistants</strong>: Code suggestions and explanations for developers</li><li><strong>Document Analysis</strong>: Understanding, summarizing, and classifying documents</li><li><strong>Language Translation</strong>: Translation between different languages</li></ol><p>This type of local LLM integration provides significant advantages, especially in the finance, healthcare, and legal sectors where data privacy is critical and sensitive data should not leave company systems.</p><h3>Advanced Enhancements</h3><p>The following features can be added to further develop the project:</p><ol><li><strong>Streaming Responses</strong>: Stream support for receiving long responses in chunks</li><li><strong>Model Management APIs</strong>: Endpoints for loading, removing, and updating models</li><li><strong>Context Management</strong>: Tracking conversation history and generating responses based on context</li><li><strong>Document Processing</strong>: Extracting text from PDF, Word, and other document formats and providing it as input to LLMs</li><li><strong>Web Interface</strong>: A user-friendly web interface for testing and managing models</li></ol><h3>Conclusion</h3><p>In this article, we’ve seen how to integrate Ollama’s local LLM capabilities into Java applications using Spring Boot. This integration offers an economical, secure, and independent way to add artificial intelligence capabilities to enterprise applications.</p><p>Artificial intelligence integrations are becoming increasingly important in the modern business world. By combining tools like Ollama and Spring Boot, developers can easily incorporate these technologies into their own applications and use them in enterprise solutions.</p><p>This basic integration can be used as a starting point for more complex artificial intelligence solutions and can be expanded according to your needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a4f22a0b7fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Not Password, Key: Fast and Secure Access to Server with SSH Keygen]]></title>
            <link>https://muhammederendemir.medium.com/not-password-key-fast-and-secure-access-to-server-with-ssh-keygen-a247fed158e5?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a247fed158e5</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 10:13:09 GMT</pubDate>
            <atom:updated>2024-11-03T03:20:15.878Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KdwbyNsCe7_DfxqAIRmRg.png" /></figure><p>If you work in the software industry, especially in DevOps or system administration teams, you may need to access multiple servers daily. Typing a username and password each time can lead to both time loss and potential security vulnerabilities. This is where SSH Keygen comes into play. SSH keys not only eliminate the need to enter password information, but they also make your connections more secure.</p><p>In this article, we will guide you step-by-step on how to create keys with SSH Keygen and how to add these keys to your servers. By following these steps, you’ll save time and ensure fast, secure access to your servers.</p><h3>Why Should We Use SSH Keygen?</h3><p>There are several methods to connect to servers, with the most common being the username and password method. While this approach provides secure communication through encryption during the connection, it carries certain risks. Users often choose easily memorable passwords, which can make them vulnerable to persistent attacks due to the passwords lacking sufficient strength and complexity.</p><p>Additionally, there is the risk of storing passwords in insecure environments. Given these security vulnerabilities, the SSH Keygen method emerges as a more reliable alternative compared to password authentication. SSH keys eliminate the need to enter passwords, thereby enhancing security and providing ease of use.</p><h3>How Does SSH Keygen Work?</h3><p>SSH key pairs consist of two cryptographically secure keys used to authenticate a client to an SSH server: the public key and the private key. These keys work together to provide a secure authentication mechanism.</p><ul><li>The private key is stored on the client side and holds significant importance. This key is unique to the user and must be kept secure, as it is used to connect to the server. Therefore, the security of the private key must be maintained at a high level to prevent unauthorized access.</li><li>The public key, on the other hand, is used solely to encrypt messages that can only be decrypted by the private key. The public key is added to the server where the SSH connection will be made and is typically stored in a special file called ~/.ssh/authorized_keys on the server.</li></ul><p>When a client attempts to establish an SSH connection to the server, the server requests proof that the client possesses the private key. If the client successfully validates this, the server creates a shell session, establishing a secure connection. This process allows for a secure and fast connection without the need for a password, relying solely on key-based authentication.</p><h3><strong>Creating a Key Pair with SSH Keygen</strong></h3><p>One of the crucial steps in enhancing security for SSH connections is for each client to generate their own SSH key pair. In this step, we will create an SSH key pair on our local computer to make server connections more secure. By using the SSH Keygen command, a 3072-bit RSA key pair will be created by default under the ~/.ssh directory, consisting of the files id_rsa (the private key) and id_rsa.pub (the public key).</p><h4>Steps to Generate a Key Pair:</h4><ol><li><strong>Running the SSH Key Command:</strong> To create a new SSH key pair, simply execute the following command in the terminal:</li></ol><pre>ssh-copy-id username@hostname</pre><p><strong>Output:</strong></p><pre>Generating public/private rsa key pair.<br>Enter file in which to save the key (/home/username/.ssh/id_rsa):</pre><p><strong>2.</strong> <strong>Specifying the Directory for Key Storage:</strong> By default, the SSH key pair is saved in the ~/.ssh directory on your local computer. However, if you wish to store it in a different directory, the terminal will prompt you for the directory where you want to save it. For general usage, it is advisable to select the default directory (~/.ssh) and press Enter to proceed.</p><p><strong>3.</strong> <strong>Checking for Existing Key Pairs: </strong>If you already have an SSH key pair created, the terminal will give you a warning that “/home/username/.ssh/id_rsa already exists.” In this case, since the existing key pair files will be overwritten, you will not be able to connect using your old keys. Therefore, if you wish to continue connecting to servers with your old keys, you can either save the new key pair under a different name or back up the previous keys.</p><p><strong>Output:</strong></p><pre>/home/username/.ssh/id_rsa already exists.<br>Overwrite (y/n)?</pre><p><strong>4. Setting a Passphrase (Optional):</strong> During the key pair generation phase, the terminal will prompt you to enter a passphrase. This passphrase will only be valid on your own computer and will enhance the security of your SSH key pair. If you do not wish to enter a passphrase, you can skip this step by pressing Enter; however, setting a passphrase is recommended for added security.</p><p><strong>Output:</strong></p><pre>Created directory &#39;/home/username/.ssh&#39;.<br>Enter passphrase (empty for no passphrase):<br>Enter same passphrase again:</pre><p>After completing these steps, you will have an SSH key pair that you can use for secure and fast connections. You can proceed to the next step by adding your public key to the server to establish passwordless connections.</p><pre>Generating public/private rsa key pair.<br>Enter file in which to save the key (/home/username/.ssh/id_rsa): <br>Enter passphrase (empty for no passphrase): <br>Enter same passphrase again: <br>Your identification has been saved in /home/username/.ssh/id_rsa<br>Your public key has been saved in /home/username/.ssh/id_rsa.pub<br>The key fingerprint is:<br>SHA256:30l2dFwRU3JCIExCwVOFdxkrSwGW6hxPxfSgHpwiUuI username@hostname<br>The key&#39;s randomart image is:<br>+---[RSA 3072]----+<br>|    . .o+=*B*o=*B|<br>|   . o  o+++++o*o|<br>|    E . .o=oo.+ o|<br>|     . .oo.o + . |<br>|       oS+. + .  |<br>|        o..+ o   |<br>|          . o    |<br>|                 |<br>|                 |<br>+----[SHA256]-----+</pre><h3>Steps to Add SSH Key to the Server</h3><p>To enable passwordless connection by adding the public key we created on our local computer to the server, there are two main methods:</p><ol><li><strong>Copying with ssh-copy-id Command</strong> This is one of the simplest methods. You can directly copy your public key to the server using the ssh-copy-id command. This command adds your public key to the ~/.ssh/authorized_keys file of the server you want to connect to. The steps are as follows:</li></ol><pre>ssh-copy-id username@hostname</pre><p>When the command runs, you will be prompted to enter the server password. After verification, the public key will be copied to the server, and you will be able to open an SSH session without needing a password on the next connection.</p><p><strong>2.</strong> <strong>Manually Adding Public Key</strong> In this method, you need to manually log into the server and add the public key yourself. The steps are:</p><ul><li>Log in to the server:</li></ul><pre>ssh username@hostname</pre><ul><li>Go to the ~/.ssh directory on the server. If the ~/.ssh directory does not exist, you can create it with the following command:</li></ul><pre>mkdir -p ~/.ssh</pre><ul><li>Copy the content of your public key from the id_rsa.pub file on your local computer and paste it into the ~/.ssh/authorized_keys file on the server. You can use the following command to open the file:</li></ul><pre>nano ~/.ssh/authorized_keys</pre><ul><li>After pasting the public key, save the file and exit.</li></ul><p>After completing these steps, you will not need to enter a password when establishing an SSH connection.</p><h3>Testing the Connection to the Server with SSH Key</h3><p>After successfully adding the SSH key to the server, you can now test the passwordless connection. To do this, try connecting to the server using the following command:</p><pre>ssh username@hostname</pre><p>If everything is configured correctly, you should not need to enter a password to log into the server. You can now establish a secure and fast connection using SSH key authentication.</p><p><strong>Note:</strong> If you are still prompted for a password during the connection, review the following steps:</p><ul><li>Ensure that the authorized_keys file is saved in the correct location and that the public key is added correctly.</li><li>Check the file permissions: the permissions of the ~/.ssh/authorized_keys file should typically be set to 600, and the permissions of the ~/.ssh directory should be set to 700.</li></ul><p>With a successful test, you can now access the server without a password!</p><h3>Conclusion</h3><p>Using SSH Keygen for server access offers a secure and efficient alternative to traditional password authentication. By generating SSH key pairs and adding the public key to your servers, you eliminate the need to enter passwords, enhancing both security and convenience. The process involves straightforward steps: creating the key pair, adding the public key to the server, and testing the connection. With proper configuration, you can enjoy seamless and passwordless access to your servers, reducing time spent on logins while bolstering security against unauthorized access.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a247fed158e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Change Docker Root Dir: Methods and Advantages]]></title>
            <link>https://muhammederendemir.medium.com/change-docker-root-dir-methods-and-advantages-abc7b6cb9be4?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/abc7b6cb9be4</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[it]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 19:49:16 GMT</pubDate>
            <atom:updated>2025-06-01T10:34:01.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PvV69dPjHFTVGh5eryF4nQ.png" /></figure><p>In this article I will explain the configurations we need to make to store the data of the docker running on a Linux server in a special directory.</p><p>Why would we want to make changes to the docker root location ?</p><ul><li><strong>Disk Managment:</strong> Security and performance management can be simplified by storing Docker data on a different disk.</li><li><strong>Data Protection and Backup: </strong>By using a disk with special protection and backup processes, we can store Docker data in a healthier way.</li><li><strong>Distributed Disk Management: </strong>By storing Docker data on different machines, performance, data security and backup advantages can be achieved. For example, let’s assume that docker data is stored in a directory associated with nfs client and nfs server on ubuntu server. Backup and performance processes can be managed more successfully only on nfs server. <a href="https://medium.com/@muhammederendemir/installing-nfs-on-ubuntu-20-04-server-3993bf9ac1b6">Installing NFS on Ubuntu 20.04 server</a></li></ul><h4>How to find docker root path</h4><p>The default docker root path is the directory “ <em>/var/lib/docker</em> ”. Find docker root directory with dokcer info command</p><pre>docker info -f &#39;{{ .DockerRootDir }}&#39;</pre><h4>How to change Docker root path?</h4><p>On our Linux machine we need to be the <strong>“root”</strong> user or we need a user with <strong>“sudo all”</strong> authorization.</p><p>First of all, we will stop docker services and we need to move the data in the docker root directory to the new directory. If we do not stop docker services, there may be problems with data migration.</p><p><strong>Step 1: </strong>Stop Docker services</p><pre>sudo systemctl stop docker<br>sudo systemctl stop docker.socket<br>sudo systemctl stop containerd</pre><p><strong>Step 2: </strong>The data in the Docker root path needs to be moved to the new directory. In the example, commands are created using the directory “/var/lib/docker”.</p><pre>sudo mv /var/lib/docker /new_docker_path</pre><p><strong>Step 3: </strong>The<strong> “data-root” </strong>field in <em>/etc/docker/daemon.json</em> will be modified. If the <strong>daemon.json</strong> file does not exist in the <em>/etc/docker </em>directory, it needs to be created and filled in as follows.</p><p>The following command will allow us to see and modify the contents of the file if it exists, if not it will create a new file.</p><pre>sudo nano /etc/docker/daemon.json</pre><p>The data-root inside the daemon.json file should look like the example below.</p><pre>{<br>  &quot;data-root&quot;: &quot;/new_docker_path&quot;<br>}</pre><p><strong>Step 4: </strong>After saving the changes in <em>/etc/docker/daemon.json</em>, docker services should be started.</p><pre>sudo systemctl start docker</pre><p>Once docker is running, we can check that the changes have taken place with the following command</p><pre>docker info -f &#39;{{ .DockerRootDir}}&#39;</pre><h4>Summary</h4><p>I tried to explain the Docker root directory change method and its advantages. The following sources were used while creating the article.</p><p><strong>Resource: </strong><a href="https://www.ibm.com/docs/en/z-logdata-analytics/5.1.0?topic=compose-relocating-docker-root-directory">https://www.ibm.com/docs/en/z-logdata-analytics/5.1.0?topic=compose-relocating-docker-root-directory</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abc7b6cb9be4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking Barriers in Data Storage: Exploring the Versatility of MinIO]]></title>
            <link>https://medium.com/geekculture/breaking-barriers-in-data-storage-exploring-the-versatility-of-minio-35e87603ff07?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/35e87603ff07</guid>
            <category><![CDATA[data-storage]]></category>
            <category><![CDATA[object-storage]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[minio]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 07:06:06 GMT</pubDate>
            <atom:updated>2023-07-25T07:06:06.681Z</atom:updated>
            <content:encoded><![CDATA[<p>MinIO is a high-performance and scalable distributed object storage system that provides an effective solution for the rapidly increasing data volumes in today’s world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TkmxjFWEHVsvJebXw_31Hw.png" /></figure><h4>What is MinIO?</h4><p>MinIO is a high-performance distributed object storage system that effectively handles the rapidly growing data volumes of today. Compared to traditional file storage systems, MinIO offers a scalable, flexible, and efficient solution for storing, accessing and managing data. Being compatible with the Amazon S3 (Simple Storage Service) APIs, MinIO enables seamless integration with existing S3-based applications. In this way, MinIO has become an ideal solution for quickly and securely storing large data volumes, meeting the needs of modern data storage.</p><h4>Why is MinIO Needed?</h4><ol><li><strong>Big Data Storage:</strong> Traditional data storage systems may face limitations in handling large data volumes. MinIO, with its scalable and distributed architecture, is ideal for quickly and securely storing large datasets. Applications such as big data analytics, machine learning models, and analytics platforms can benefit from MinIO’s high performance and scalability to meet their data storage needs.</li><li><strong>Cloud-Based Applications: </strong>Nowadays, many applications and services operate in the cloud. Due to its compatibility with the Amazon S3 APIs, MinIO can seamlessly integrate with cloud-based applications. This facilitates the usage of existing S3-based applications and fulfills their data storage requirements.</li><li><strong>Data Backup and Recovery:</strong> Backing up and recovering critical data is crucial for business continuity and data security. Being a distributed object storage system, MinIO ensures high data durability by distributing data across multiple nodes. This reduces the risk of data loss and enables secure data backup and recovery operations.</li><li><strong>Object Storage Services:</strong> MinIO is an ideal choice for companies seeking to leverage the advantages offered by object storage services. Object storage is a storage method designed to provide scalability, durability, flexibility, and data accessibility. MinIO provides similar APIs to major object storage services like Amazon S3, allowing users to benefit from these advantages.</li></ol><h4>Advantages of MinIO:</h4><ol><li><strong>High Performance:</strong> MinIO ensures high-speed data transfer through its distributed architecture and optimized features. This makes it ideal for fast data access and processing.</li><li><strong>Scalability:</strong> MinIO can easily scale by adding low-cost hardware components. As the data volume increases, new nodes can be added, allowing the system to expand.</li><li><strong>Durability:</strong> MinIO stores data in a distributed manner to ensure data security. This minimizes the risk of data loss and provides high data durability.</li><li><strong>Compatibility:</strong> MinIO seamlessly integrates with existing applications as it is compatible with the Amazon S3 APIs. Transitioning from existing S3-based applications to MinIO is quick and effortless.</li><li><strong>User-Friendly:</strong> MinIO is easy to use and manage. It provides a web-based interface that offers a user-friendly experience. Additionally, it offers advanced features and APIs.</li><li><strong>Flexible Storage Options: </strong>MinIO provides a wide range of storage options. It can be used for object storage, file storage, or block storage, catering to different scenarios.</li></ol><h4>Usage Scenarios:</h4><ol><li><strong>Big Data Analytics and Storage:</strong> MinIO effectively manages large volumes of data required for big data analytics and storage platforms. It provides a fast and secure data storage solution, enabling efficient execution and processing of big data analytics.</li><li><strong>Data Storage Needs for Cloud-Based Applications: </strong>MinIO’s compatibility with the Amazon S3 API allows seamless integration with cloud-based applications, meeting their data storage requirements. It enables smooth integration and utilization of MinIO’s high-performance data storage capabilities.</li><li><strong>Data Backup and Recovery Security: </strong>MinIO ensures high data durability by distributing data in a decentralized manner, facilitating secure data backup and recovery processes. It minimizes the risk of data loss and strengthens the critical data recovery procedures for business continuity.</li><li><strong>High-Speed Media Storage and Distribution: </strong>MinIO facilitates the rapid and secure storage and distribution of large media files with its high performance and scalability. It is an ideal solution for media companies and broadcasting platforms.</li><li><strong>Compatibility with Object Storage Services: </strong>MinIO’s compatibility allows easy integration with platforms offering object storage services. This enables leveraging MinIO’s scalability, data security, and flexibility advantages.</li><li><strong>Data Storage and Processing for Edge Computing: </strong>MinIO can be utilized for on-site data storage and processing in edge computing applications. It provides fast data access and processing required for data-intensive edge applications.</li></ol><h4>Conclusion</h4><p>MinIO is a high-performance, scalable, and user-friendly solution that meets the modern data storage needs. It can be effectively utilized in various use cases such as big data analytics, cloud-based applications, data backup and recovery. The advantages of MinIO empower users to strengthen their data management strategies and play a crucial role in ensuring data security and accessibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35e87603ff07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/breaking-barriers-in-data-storage-exploring-the-versatility-of-minio-35e87603ff07">Breaking Barriers in Data Storage: Exploring the Versatility of MinIO</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing NFS on Ubuntu 20.04 server]]></title>
            <link>https://muhammederendemir.medium.com/installing-nfs-on-ubuntu-20-04-server-3993bf9ac1b6?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3993bf9ac1b6</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[nfs-server]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 21:02:40 GMT</pubDate>
            <atom:updated>2021-12-21T21:02:40.722Z</atom:updated>
            <content:encoded><![CDATA[<p>Greetings, I talking about NFS and NFS installing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSKGAWP84SPxyLb8UdADYw.png" /></figure><p>NFS, short for Network File System, is a distributed file system<br>protocol. Share files and directories with others over a network.<br>It can help you share. programs on remote systems<br>share information with each other as if they were on the machine and<br>allow access.</p><p>NFS runs in a client-server environment. In other words, if you want to set up NFS to share files between two systems, one must be configured as a server and the other as a client.</p><p>The server acts as an administrator, authenticating and authorizing clients for access to shared data. Almost any number of clients can access shared data as simply as any other file or directory in their local storage.</p><h3>How to install Server for NFS on Ubuntu Server</h3><p>I have prepared a detailed step-by-step tutorial that will guide you on how to install and set up NFS Server in Ubuntu, so you can start sharing data with other client systems. We will be using Ubuntu 20.04 LTS for this tutorial.</p><h4>Configuring the Host Server</h4><p>To install the master server, you must first install the NFS Kernel server.<br>must. Once done, share with all client systems<br>You can create and export the files and directories you want.</p><p>Let’s finish this thing.</p><h4>Step 1: Installing Server for NFS Kernel Server</h4><p>NFS Kernel Server to the Ubuntu system that will run as a server first.<br>We need to install the package. But before that, download the system packages to make sure nothing gets messed up during the process.<br>Let’s update.</p><p>To do this, type the following command in the terminal:</p><pre>sudo apt update</pre><p>For all system package updates, it’s time to install package “nfs-kernel-server” using the following command:</p><pre>sudo apt install nfs-kernel-server</pre><p>This will also install some additional packages on your system, including “nfs-common” and “rpcbind”, which are required to set up file sharing.</p><h4>Step 2: Create NFS Export Directory</h4><p>After the “nfs-kernel-server” package is installed, you can now create an NFS export directory (known as the “export directory” for short) that will be shared with all client systems. To do this, type the following command inside the terminal.</p><pre>sudo mkdir -p /mnt/nfs_share</pre><p>All files that you want to be accessible to the client must be created in this directory. Since we want client systems to have full access to this shared directory, we need to remove any directory permissions that restrict access.</p><p>This can be done with the following command:</p><pre>sudo chown -R nobody:nogroup /mnt/nfs_share/</pre><p>Once you are done with the above command, move on to the next step.</p><h4>Step 3: Assign NFS Server Access to Client Systems</h4><p>Once the Exports directory is ready, you need to grant clients’ systems access to the master server. This permission is defined in the “exports” file located in your system’s /etc folder.</p><p>You will need to edit this file and add a few extra command lines to give clients access to the exports directory of their systems. So, open it using the Nano editor by entering the following command in the terminal:</p><pre>sudo nano /etc/exports</pre><p>From here, you can provide NFS server access to a single client, several clients, or the entire subnet. For this reading, we will be providing all subnet access to the NFS share.</p><p>To do this, you need to add this line to the “export” file.</p><pre>/mnt/nfs_share subnet(rw,sync,no_subtree_check)</pre><p>Here you need to change the subnet of your system in the placeholder provided.</p><p>Also, let’s look at what the other parts of the command mean:</p><p><strong>rw :</strong> read/write command<br><strong>sync :</strong> changes are made on disk before they are applied.<br><strong>no_subtree_check</strong> <strong>:</strong> removes the subtree check.</p><p>However, if you only want to grant access to a single client, you can do so using the following syntax:</p><pre>/mnt/nfs_share client_IP_1(rw,sync,no_subtree_check)</pre><p>For multiple client joints, you have to do this one by one:</p><pre>/mnt/nfs_share client_IP_1(rw,sync,no_subtree_check)</pre><pre>/mnt/nfs_share client_IP_2(rw,sync,no_subtree_check)</pre><p>Since the client system has access to the NFS server, it is time to move on to the next step.</p><h4>Step 4: Export Shared NFS Directory</h4><p>With all the configurations above available, it’s time to export the shared NFS directory and make it available to client systems.</p><p>This is quickly done using the command:</p><pre>sudo exportfs -a</pre><p>Do this for NFS to make sure all configurations are in effect.<br>Restarting the kernel server is required.</p><pre>sudo systemctl restart nfs-kernel-server</pre><p>Finally, time to move on to the final step of this setup.</p><h4>Step 5: Allow Clients Through Firewall</h4><p>After granting clients access to the NFS server and exporting the shared directory Even after transferring, clients still cannot access the files if they are blocked by the firewall. Therefore, you will need to turn on the firewall for your clients. Your Ubuntu computer already has a default firewall — UFW (Uncomplicated Firewall).</p><p>You can type the following command to check if it works on your system:</p><pre>sudo ufw status</pre><p>If it shows inactive, you will have to turn it back on using this command:</p><pre>sudo ufw enable</pre><p>However, if for some reason it is not installed on your system, you can use this command to install it:</p><pre>sudo apt install</pre><p>After installing and enabling UFW on your Ubuntu system, you will need to configure it to allow access to your clients.</p><p>Since we are providing NFS access to the entire subnet, we need to use the command:</p><pre>sudo ufw allow from subnet to any port nfs</pre><p>However, if you have only allowed NFS access on a per-client basis, you will need to enter the client IP as.</p><pre>sudo ufw allow from client_IP_1 to any port nfs</pre><p>And that’s it! You have successfully installed and configured the NFS service on the Server computer.</p><h3>Configuring the Client System</h3><p>Next, we will need to install and set up NFS on the client system to access the shared directory. Similar to the previous one, here is a step-by-step guide to help you out.</p><h4>Step 1: Installing the NFS-Common Package</h4><p>When installing the client system for NFS sharing, install the “nfs-common” package. We need to set up. As before, you must first update the system package and then nfs-common using the following commands<br>you must install:</p><p>To update packages:</p><pre>sudo apt update</pre><p>To install the nfs-common package:</p><pre>sudo apt install nfs-common</pre><p>Once complete, proceed to the next step.</p><h4>Step 2: Let’s create a Mount point</h4><p>Next, you will need to create a mount point. It will be used to mount NFS shared files from NFS server. To do this, type the following command in the terminal:</p><pre>sudo mkdir -p /mnt/nfs_clientshare</pre><h4>Step 3: Mount NFS Shared Directory to Client System</h4><p>The folder you created in the step above works like any other folder on your system. To access the NFS shared directory from the master server, you need to mount it to the new folder:</p><p>To do this, you must first know the IP address of the NFS server.<br>must. Type the following command in the terminal of the server system:</p><pre>ifconfig</pre><p>It will bring up the network interface configuration. Server’s IP<br>is the IP given under “inet” which is 10.0.2.15 in our case.</p><p>Using this IP, type the following command in the terminal of the NFS client to finally mount the NFS shared directory to the client system:</p><pre>sudo mount 10.0.2.15:/mnt/nfs_share /mnt/nfs_clientshare</pre><h4>Step 4: Link To See If Everything Is Working Test it</h4><p>By following the above steps in order, you have successfully created an NFS server for file and folder sharing between a server system and multiple client systems.</p><p>All that remains is to check if everything is working correctly.</p><p>To do this, create a new file in the NFS shared directory on the server.<br>create. You can do this using the command:</p><pre>cd /mnt/nfs_share/</pre><pre>touch file1.txt file2.txt file3.txt</pre><p>After the process is complete, check the client system to see if these files appear in the NFS shared directory using the command:</p><pre>ls -l /mnt/nfs_clientshare/</pre><p>If you see “file1.txt”, “file2.txt” and “file3.txt” files in the list, it means the NFS server is running and you can now start sharing and receiving files between client and server systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3993bf9ac1b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins Mail Notification Actions]]></title>
            <link>https://muhammederendemir.medium.com/jenkins-mail-notification-actions-e82e73bbbb08?source=rss-16a8f880408b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e82e73bbbb08</guid>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[ci]]></category>
            <category><![CDATA[mail]]></category>
            <dc:creator><![CDATA[Muhammed Eren Demir]]></dc:creator>
            <pubDate>Thu, 24 Jun 2021 02:17:10 GMT</pubDate>
            <atom:updated>2021-06-24T02:17:10.792Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jenkins Mail Notification Action</h3><p>Greetings, I talked about sending mail notifications with Jenkins. good reading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*csJ3bY3m71gUw1Om-bzNgw.png" /></figure><p>Jenkins is a CI/CD open source automation tool. With Jenkins, Projects automatic integration and deployment processes are performed. Users can be informed about the results of automatic transactions with Jenkins by sending an e-mail.</p><p>For example, deploying a project with Jenkins. We want to send the results of the distribution process to the users as an e-mail.</p><p>so let’s follow the steps below</p><p><strong>Step 1:</strong> We will check whether you have Mailler Plugin in Jenkins and if not, load.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DcBFmEw_3qRldu5hNcu46g.jpeg" /></figure><p><strong>Step 2:</strong> It will be filled like Jenkins &gt; configuration &gt; E-mail Notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6a72v4XYNOHSuRozXreWg.jpeg" /></figure><p>If the test result is successful, it has been successfully integrated.</p><p><strong>If an error like the following is encountered in the connection, less secure application access should be opened in the mail settings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*kRT9HLETJIkz725LIuQOKA.jpeg" /></figure><p><strong>Step 3:</strong> After selecting mail from Jenkins &gt; jhipster-product-api &gt; Piplene syntax field and filling in the required fields, an example Jenkinsfile or shell command is given as a result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5aXj_q7bEbogp-abhtNrTQ.jpeg" /></figure><p>With Jenkins, we can send mail. Thank you for reading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e82e73bbbb08" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>