Hi there 👋

I am a software engineer working primarily as a Java/Spring Developer. The site contains posts/logs regarding:

  • How To: Code snippets on how to solve a small task. Errors and stacktraces with fixes.
  • Posts: Posts exploring topics for a software development.
  • Series: Sequence of posts around a topic.

Find Files And Delete Recursively

Problem Sometimes when using monorepos to host multiple services in a single repository, there may be a requirement to delete a file or list of files from each microservice. For example, I needed to delete application-dev.yml files for all the services after getting rid of dev environment in favor of acceptance. Solution Use following find command to find application-dev.yml files recursively and delete them. 1 find . -name "application-dev.yml" -type f -delete we may also use glob filters while using find:...

November 20, 2022 1 min

Nginx Ingress Controller forward headers

Error While moving to kubernetes, and migrating spring boot apps, we encountered a strange behavior that few of the webpages served by freemarker templates in spring boot were adding port :8080 instead of just using the hostname with SSL port :443 Fix After some investigation and trying to find some workaround, we found out that X-Forwarded-* headers needs to be forwarded by nginx ingress controller when it’s behind an azure app gateway(L7 load balancer)....

Spring Boot Request Header too large

How to solve IllegalArgumentException: Request header is too large in spring boot When migrating a spring boot application to cloud, multiple layers got added to serve traffic. On prem: nginx -> spring boot app (tomcat) Azure: nginx -> azure application gateway -> nginx ingress controller -> spring boot app(tomcat) In Azure, we noticed that some of http requests threw 400 http status code in our logs. While investigating further, we found the reason IllegalArgumentException: Request header is too large...

Git Config

Git Config commands git config –global init.defaultBranch main

August 8, 2022 1 min

Fix Only_full_group_by_sql_error

Recently, I encountered sql state 42000 error in a spring boot application while moving from MySQL version 5.6 to 8.0. After inspecting stack trace and some googling, I got to know that few default configurations have changed in MySQL 8.0 (as expected 😃 ). This caused our poorly written queries to fail during migration. Background Lets look at sample query using spring-data jpa to gather some analytics by aggregating data about a customer ordering products...

Bash execute a command N times

How to run a command n times in bash 1 for i in {1..N}; do COMMAND; done

August 7, 2022 1 min

Kotlin Enum

Let’s have a look at enums in kotlin. Unlike Java, where enum is a Type; in Kotlin, enums are classes Defining an enum 1 2 3 enum class Direction { NORTH, SOUTH, WEST, EAST } Defining an enum with a variable 1 2 3 enum class Direction(val shortName: Char) { NORTH('N'), SOUTH('S'), WEST('W'), EAST('E') } Template Method pattern in Enum 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 enum class Direction(val shortName: Char) { NORTH('N') { override fun move() = "Moving in North Direction" }, SOUTH('S') { override fun move() = "Moving in South Direction" }, WEST('W'){ override fun move() = "Moving in West Direction" }, EAST('E'){ override fun move() = "Moving in East Direction" }; abstract fun move(): String } Companion methods in enum 1 2 3 4 5 6 7 enum class Direction(val shortName: String) { NORTH("N"), SOUTH("S"), WEST("W"), EAST("E"); companion object { fun valueOfIgnoreCase(name: String) = valueOf(name....

Nginx Ingress Sample Configurations for Helm values

Ingress configurations in helm values files. The following setup assumes that you have a helm chart which provides the configuration to deploy a service and an ingress for it Now, lets look at few of the sample helm values file configurations for ingress configurations with ingress-nginx. Enable Cors 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ingress:enabled:trueannotations:kubernetes.io/ingress.class:nginxnginx.ingress.kubernetes.io/enable-cors:"true"nginx.ingress.kubernetes.io/cors-allow-methods:"DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT"nginx....

Google Search Tips and Tricks

1. Exact phrase search Use double quotes "" to search for exact phrase match. e.g.: “JedisDataException: ERR unknown command CONFIG” 2. Exclude terms use hyphen (-) to exclude search terms which should not contibute to the search result. e.g.: coke -cola to exclude cola from search results. 3. Website search use search term site:sitename to search a site for the results. e.g. jedis site:ravikrs.com 4. Related website use link:ravikrs.com to find which sites have links for your website’s content...

Bastion Pod in Kubernetes

Background When deploying applications to kubernetes, we should restrict access to resources like databases, queues, cache, etc. From a security prospective, we should not be able to connect to storage/database from outside the kubernetes deployment(applications). Only applications deployed to kubernetes cluster should be allowed access to databases,queues, etc. Problem But for debugging purpose its essential to be able to connect to such resources. For e.g. we might need to check some data in the database or verify if an item is getting stored in redis cache, etc...