{"id":827,"date":"2020-03-30T00:00:00","date_gmt":"2020-03-30T00:00:00","guid":{"rendered":"http:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-1-d67f80487848\/"},"modified":"2021-02-03T17:01:11","modified_gmt":"2021-02-03T17:01:11","slug":"simple-spring-boot-service-to-kubernetes-application-step-1-d67f80487848","status":"publish","type":"post","link":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-1-d67f80487848\/","title":{"rendered":"Setup: IDE and New Project"},"content":{"rendered":"\n<p id=\"c0a7\">&nbsp;Its very easy to get a spring boot microservice up and running. You can read any variety of articles on medium (or other service) on how to do that. However, there\u2019s little about how to do some of the more complicated things that you need in order to support a deployed application and even fewer that link them all together. This series of articles is intended to draw a clear line between all of the stages in order to help guide you to a deployed application with multiple services.<\/p>\n\n\n\n<h3 class=\"graf graf--h3 graf--leading wp-block-heading\" id=\"3fdd\">Setup Your Development Environment<\/h3>\n\n\n\n<p class=\"graf graf--p graf-after--h3 graf--trailing\" id=\"cd15\">This first article is specifically about setting up a development environment for a service. Although this is generally straightforward, I\u2019m going to cover some tools that make it really easy to initialize an environment from scratch.<\/p>\n\n\n\n<h3 class=\"graf graf--h3 graf--leading wp-block-heading\" id=\"2b92\"><strong class=\"markup--strong markup--h3-strong\">Create the Github Repository<\/strong><\/h3>\n\n\n\n<p class=\"graf graf--p graf-after--h3\" id=\"9b8a\">We\u2019ll need a version control repository first. Log into your github account and create a new repository. We\u2019re going to make a public repository called <code class=\"markup--code markup--p-code\">medium-customer<\/code> as a public repository. Initialize the repository with a readme (to give us something to clone) and add a gitignore file configured for <code class=\"markup--code markup--p-code\">java<\/code>. Clone that repository into your local environment.<\/p>\n\n\n\n<h3 class=\"graf graf--h3 graf-after--p wp-block-heading\" id=\"5371\">Create Your Project Workspace<\/h3>\n\n\n\n<p class=\"graf graf--p graf-after--h3\" id=\"ae0b\">In the next step we\u2019re going to use <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/start.spring.io\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/start.spring.io\/\">spring initializr<\/a> to initialize our spring boot project. However, before we do that we\u2019re going to make it easy on ourselves by using our intellij plugins to do the heavy lifting. Install the following plugins into intellij (if they\u2019re not installed already):<\/p>\n\n\n\n<ul class=\"postList wp-block-list\"><li id=\"8357\" class=\"graf graf--li graf-after--p\">Spring Assistant<\/li><li id=\"34ac\" class=\"graf graf--li graf-after--li\">MapStruct Support<\/li><li id=\"5df3\" class=\"graf graf--li graf-after--li\">Lombok<\/li><li id=\"5f4e\" class=\"graf graf--li graf-after--li\">Database Navigator.<\/li><\/ul>\n\n\n\n<p class=\"graf graf--p graf-after--li\" id=\"997f\">Once you have the plugins installed, use <code class=\"markup--code markup--p-code\">File\/New Project\u2026<\/code>to create a new project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/1OZhOVsK9sacDivKZMnoIQA.png?w=960\" alt=\"\" data-recalc-dims=\"1\"\/><\/figure>\n\n\n\n<p class=\"graf graf--p graf-after--figure\" id=\"96ab\">Now setup your maven project<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/1OZhOVsK9sacDivKZMnoIQA.png?w=960\" alt=\"\" data-recalc-dims=\"1\"\/><\/figure>\n\n\n\n<p class=\"graf graf--p graf-after--figure\" id=\"3e9f\">And choose the dependencies in the next screen.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2021\/02\/1OZhOVsK9sacDivKZMnoIQA.png?w=960\" alt=\"\" data-recalc-dims=\"1\"\/><\/figure>\n\n\n\n<p class=\"graf graf--p graf-after--figure\" id=\"5b94\">Hopefully, we\u2019ll get a chance to use them all, I\u2019m including some that we might not use directly. The important ones for now are<\/p>\n\n\n\n<ul class=\"postList wp-block-list\"><li id=\"9349\" class=\"graf graf--li graf-after--p\">Lombok<\/li><li id=\"cf86\" class=\"graf graf--li graf-after--li\">Spring web<\/li><li id=\"bf9d\" class=\"graf graf--li graf-after--li\">H2 database<\/li><li id=\"a9be\" class=\"graf graf--li graf-after--li\">Spring data jpa.<\/li><\/ul>\n\n\n\n<p class=\"graf graf--p graf-after--li\" id=\"8307\">Finish up creating the project. <strong class=\"markup--strong markup--p-strong\">Make sure that the project location points to the directory that we cloned the github repository into.<\/strong><\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"b9e8\">We also need to include mapstruct, since we\u2019ll be using that for mapping and translating our java beans. Add the following properties and dependencies to your maven pom.xml file<\/p>\n\n\n\n<pre id=\"6fb1\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>&lt;properties&gt;\n   ...\n   &lt;org.mapstruct.version&gt;1.3.1.Final&lt;\/org.mapstruct.version&gt;\n&lt;\/properties&gt;<\/code><\/pre>\n\n\n\n<pre id=\"43a6\" class=\"wp-block-code graf graf--pre graf-after--pre\"><code>&lt;dependencies&gt;\n   ...\n   &lt;dependency&gt;\n      &lt;groupId&gt;org.mapstruct&lt;\/groupId&gt;\n      &lt;artifactId&gt;mapstruct&lt;\/artifactId&gt;\n      &lt;version&gt;${org.mapstruct.version}&lt;\/version&gt;\n   &lt;\/dependency&gt;\n   &lt;dependency&gt;\n      &lt;groupId&gt;org.mapstruct&lt;\/groupId&gt;\n      &lt;artifactId&gt;mapstruct-processor&lt;\/artifactId&gt;\n      &lt;version&gt;${org.mapstruct.version}&lt;\/version&gt;\n   &lt;\/dependency&gt;\n   ...\n&lt;\/dependencies&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"graf graf--h3 graf-after--pre wp-block-heading\" id=\"cab1\">Build and&nbsp;Commit<\/h3>\n\n\n\n<p class=\"graf graf--p graf-after--h3\" id=\"2282\">Now lets make sure that we\u2019ve got something that actually works. Spring initializr gives us some basic project structure and tests, so it will confirm that the compile and spring boot context initialization works.<\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"e9ec\">Run:<\/p>\n\n\n\n<pre id=\"98f9\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>maven clean install<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"9b14\">You should see a successful build<\/p>\n\n\n\n<pre id=\"5843\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>&#91;INFO] Results:\n&#91;INFO]\n&#91;INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0\n&#91;INFO]\n&#91;INFO]\n&#91;INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ medium-customer ---\n&#91;INFO] Building jar: C:\\workspace\\github\\medium-customer\\target\\medium-customer-0.0.1-SNAPSHOT.jar\n&#91;INFO]\n&#91;INFO] --- spring-boot-maven-plugin:2.2.6.RELEASE:repackage (repackage) @ medium-customer ---\n&#91;INFO] Replacing main artifact with repackaged archive\n&#91;INFO]\n&#91;INFO] --- maven-install-plugin:2.5.2:install (default-install) @ medium-customer ---\n&#91;INFO] Installing C:\\workspace\\github\\medium-customer\\target\\medium-customer-0.0.1-SNAPSHOT.jar to C:\\Users\\brian\\.m2\\repository\\com\\brianrook\\medium\\medium-customer\\0.0.1-SNAPSHOT\\medium-customer-0.0.1-SNAPSHOT.jar\n&#91;INFO] Installing C:\\workspace\\github\\medium-customer\\pom.xml to C:\\Users\\brian\\.m2\\repository\\com\\brianrook\\medium\\medium-customer\\0.0.1-SNAPSHOT\\medium-customer-0.0.1-SNAPSHOT.pom\n&#91;INFO] ------------------------------------------------------------------------\n&#91;INFO] BUILD SUCCESS\n&#91;INFO] ------------------------------------------------------------------------\n&#91;INFO] Total time: 16.037 s\n&#91;INFO] Finished at: 2020-03-27T15:11:20-06:00\n&#91;INFO] ------------------------------------------------------------------------<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"2104\">Now lets commit and push to master for our initial project commit.<\/p>\n\n\n\n<pre id=\"6c3b\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>git checkout -b initial\ngit add .\ngit commit -m \"initial commit\"\ngit push<\/code><\/pre>\n\n\n\n<pre id=\"48a7\" class=\"wp-block-code graf graf--pre graf-after--pre\"><code>git checkout master\ngit merge --squash initial\ngit commit -m \"Initial commit\"\ngit push<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\n&nbsp;Its very easy to get a spring boot microservice up and running.&hellip;\n<\/div>\n<div class=\"link-more\"><a href=\"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-1-d67f80487848\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Setup: IDE and New Project&rdquo;<\/span>&hellip;<\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[29,44,49,46,48,47,50,42,43,45],"course":[40],"class_list":["post-827","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-git","tag-github","tag-initializr","tag-intellij","tag-lombok","tag-mapstruct","tag-maven","tag-spring","tag-spring-boot","tag-version-control","course-spring-with-kubernetes","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1141,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/01\/02\/kubernetes-application-hosted-in-the-cloud\/","url_meta":{"origin":827,"position":0},"title":"Kubernetes Application Hosted in the Cloud","author":"Bullyrook","date":"January 2, 2022","format":false,"excerpt":"It's been a few years since my last spring boot based kubernetes application. That course ended with a microservice deployed into kubernetes via minikube locally. I'm using this course to expand on that effort. In this course I'm going to show a few ways to do the same things in\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":836,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-11-636b842a3c0f\/","url_meta":{"origin":827,"position":1},"title":"Helm for Deployment","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"We\u2019re about ready to deploy into kubernetes. However, deployment is not exactly straightforward. There are a lot of configuration files that we need to create and maintain in order to explain to the container management system how to deploy our application. We can use tools like kubectl to promote these\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":821,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-7-2a141b03db3f\/","url_meta":{"origin":827,"position":2},"title":"Database as a Service","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Now that we\u2019ve got our service pretty might tightened up lets get started moving towards deploying it. The first step is using a real database instead of the in memory one. Cloud Based Database\u00a0Setup We\u2019re going to use postgreSQL as our database. The most straightforward option is to run postgreSQL\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":833,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-18-9dff659cd334\/","url_meta":{"origin":827,"position":3},"title":"UI Build Pipeline","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Simple Spring Boot Service to Kubernetes Application: Step\u00a018 Lets quickly update our build pipeline to push an image for our front end application into our repo. This opens the path to using helm to package and deploy our chart. Create a New\u00a0Pipeline Log into codefresh and go into pipelines. Choose\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":837,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-8-3e94686c9a34\/","url_meta":{"origin":827,"position":4},"title":"Containerize the Service With Docker","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Now we\u2019re going to take our functional service and containerize it. This will allow us to control the deployment environment that our java spring boot service runs in as well as provide some additional security and isolation from application updates that can break our application. Containerization Overview If you\u2019ve spent\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":815,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-14-8e1ade0b7b84\/","url_meta":{"origin":827,"position":5},"title":"System Design","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"We\u2019ve successfully deployed a service and confirmed that its accessible. However, a single service doesn\u2019t make an app. We now need to fill out the rest of the application and introduce some best practices around service governance and system engineering. The Application Design We\u2019re going to be organizing the UI\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/comments?post=827"}],"version-history":[{"count":3,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"predecessor-version":[{"id":879,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/827\/revisions\/879"}],"wp:attachment":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/tags?post=827"},{"taxonomy":"course","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/course?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}