{"id":822,"date":"2020-03-30T13:00:00","date_gmt":"2020-03-30T13:00:00","guid":{"rendered":"http:\/\/bullyrooks.com\/index.php\/2020\/04\/10\/simple-spring-boot-service-to-kubernetes-application-step-13-c3d437bb7570\/"},"modified":"2021-02-04T02:00:42","modified_gmt":"2021-02-04T02:00:42","slug":"simple-spring-boot-service-to-kubernetes-application-step-13-c3d437bb7570","status":"publish","type":"post","link":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-13-c3d437bb7570\/","title":{"rendered":"Automating Deployment (for CICD)"},"content":{"rendered":"\n<p class=\"graf graf--p graf-after--h3 graf--trailing\" id=\"d5ee\">Now that we\u2019ve deployed our application, lets reduce some of the manual steps and make our deployments more reproducible with the intent of eventually making them automated for CI\/CD.<\/p>\n\n\n\n<h3 class=\"graf graf--h3 graf--leading wp-block-heading\" id=\"0c56\">Publish our Chart to the Chart Repository<\/h3>\n\n\n\n<p class=\"graf graf--p graf-after--h3\" id=\"47f2\">Normally, we would need to create a helm chart repository, however, codefresh has given us one by default. We just need to make it available to our pipeline and add some steps to push a chart up.<\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"ae20\">Go to our pipeline workflow for medium-customer. On the right side you should see some tabs as well as a gear. Click on the gear. Click on<code class=\"markup--code markup--p-code\"> Import from Shared Configuration<\/code> and choose <code class=\"markup--code markup--p-code\">CF_HELM_DEFAULT<\/code> (which is the default helm repository codefresh gives us). We don\u2019t need to do anything else here so close up the environment variables window.<\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"dd24\">Back on the workflow we need to add some new steps:<\/p>\n\n\n\n<pre id=\"1b51\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>  UpdateChartImageVersion:\n    title: Update Helm Chart Version\n    stage: helmpublish\n    image: gksoftware\/yq\n    working_directory: '\/codefresh\/volume\/medium-customer'\n    environment:\n      - CHART=src\/main\/helm\/medium-customer\n    commands: \n      - yq w -i ${CHART}\/values.yaml image.tag '\"${{CF_SHORT_REVISION}}\"'\n  HelmChartPush:\n      title: Push Helm Chart to Chart Repository\n      stage: helmpublish\n      image: codefresh\/cfstep-helm\n      working_directory: '\/codefresh\/volume\/medium-customer'\n      environment:\n        - CHART_REF=src\/main\/helm\/medium-customer\/\n        - ACTION=push<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote graf graf--blockquote graf-after--pre is-layout-flow wp-block-quote-is-layout-flow\" id=\"9393\"><p>Again, this is yaml so be very careful about formatting. What we\u2019re doing here is opening up the values.yaml for the chart, updating the tag version to the tag that we just used for the docker image and then using codefresh\u2019s custom step to package up the chart, update the chart index and publish the updated index.<\/p><\/blockquote>\n\n\n\n<p class=\"graf graf--p graf-after--blockquote\" id=\"0584\">What we\u2019re doing with a chart and chart repository is essentially creating a \u2018package\u2019 of our application which helm can use to install the app. This is very similar to the package managers that we used to install kubectl. However, in this case we\u2019re going to use helm to tell kubernetes to install and start up our application.<\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"4f45\"><strong class=\"markup--strong markup--p-strong\">Make sure that you run this pipeline now<\/strong>. We need to publish the chart with the new pipeline steps to make it available in the next section.<\/p>\n\n\n\n<h3 class=\"graf graf--h3 graf-after--p wp-block-heading\" id=\"3699\">Testing it&nbsp;Out<\/h3>\n\n\n\n<p class=\"graf graf--p graf-after--h3\" id=\"a78e\">Lets try it out with minikube. First destroy our running application<\/p>\n\n\n\n<pre id=\"663d\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>helm delete medium<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"45ec\">Now lets configure helm to be able to talk to codefresh\u2019s helm chart repository. First we need access, so we\u2019ll create an API token. Go to User Accounts in the lower left of the console screen. Click on <code class=\"markup--code markup--p-code\">generate <\/code>in the API Keys section. Create a key called <code class=\"markup--code markup--p-code\">helmaccess<\/code> click the <code class=\"markup--code markup--p-code\">SCOPES <\/code>checkbox to give all access. Click <code class=\"markup--code markup--p-code\">CREATE <\/code>and then use the eyeball in the <code class=\"markup--code markup--p-code\">API KEY<\/code> section to view the generated token. Save this somewhere locally, since we\u2019ll never be able to view it again.<\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"1025\">At this point I had to switch over my command line to Git Bash (since I\u2019m on windows) if you\u2019re on windows, you may want to do the same.<\/p>\n\n\n\n<p class=\"graf graf--p graf-after--p\" id=\"ab8e\">First install the chartmuseum plugin that will let us talk to codefresh\u2019s chart repository.<\/p>\n\n\n\n<pre id=\"fb8d\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>helm plugin install https:\/\/github.com\/chartmuseum\/helm-push.git<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"b285\">Next add your access token to the environment<\/p>\n\n\n\n<pre id=\"5d7d\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>export HELM_REPO_ACCES_TOKEN=\"&lt;your access token&gt;\"<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"bdfd\">now link the codefresh chart repo to your helm<\/p>\n\n\n\n<pre id=\"8e25\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>helm repo add codefresh cm:\/\/h.cfcr.io\/&lt;your account name&gt;\/default<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"d2f9\">update your view<\/p>\n\n\n\n<pre id=\"8c1e\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>helm repo update<\/code><\/pre>\n\n\n\n<p class=\"graf graf--p graf-after--pre\" id=\"3c41\">now use helm to install the chart<\/p>\n\n\n\n<pre id=\"53d3\" class=\"wp-block-code graf graf--pre graf-after--p\"><code>helm install medium codefresh\/medium-customer<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote graf graf--blockquote graf-after--pre is-layout-flow wp-block-quote-is-layout-flow\" id=\"91d8\"><p>As you can see here we\u2019re using the chart repository to reference the chart instead of the local path.<\/p><\/blockquote>\n\n\n\n<p class=\"graf graf--p graf-after--blockquote\" id=\"cf1a\">The advantage of a chart is that now I don\u2019t need to know any thing about the source code in order to deploy my application. As long as I can access this chart repository (and the container image registry) I can deploy this service to <strong class=\"markup--strong markup--p-strong\">ANY <\/strong>kubernetes cluster I can spin up.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\nNow that we\u2019ve deployed our application, lets reduce some of the manual&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-13-c3d437bb7570\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Automating Deployment (for CICD)&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":[86,77,76,79,81,80],"course":[40],"class_list":["post-822","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-chart-museum","tag-cicd","tag-codefresh","tag-helm","tag-helm-chart","tag-kubernetes","course-spring-with-kubernetes","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":833,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-18-9dff659cd334\/","url_meta":{"origin":822,"position":0},"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":823,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-21-6986a29db37a\/","url_meta":{"origin":822,"position":1},"title":"Simplify Deployment","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Now that we have multiple components lets simplify our deployment so that we can deploy our complete application in one step. Create an Umbrella\u00a0Chart Create a new git repository called medium-application. This is the repository that will house the helm umbrella chart. Create a directory called helm and run helm\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":817,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-20-fe28a586cdc6\/","url_meta":{"origin":822,"position":2},"title":"Creating an Ingress in Kubernetes","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"We\u2019ve got multiple service available for deployment now. Lets allow them to communicate internally and externally with the cluster. We\u2019ll do that by creating an ingress. Current State of Our Application We\u2019re using our services as nodeports which allows us to expose an external port that will map to the\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":818,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-19-944a76415384\/","url_meta":{"origin":822,"position":3},"title":"Put the UI in to Helm","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Lets take the docker image we just created and wrap it with helm so that we have an easy way to deploy our application. Create Helm Chart Templates We\u2019ve created helm charts before, so lets create a helm directory at the frontend root. Then run helm create in that directory\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":824,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-10-e1a3a8e865bb\/","url_meta":{"origin":822,"position":4},"title":"Automated Build Pipeline","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Lets set up automated build so that we can generate a docker image when a change hits master. Build the\u00a0Pipeline Go in to codefresh and choose Projects. Create a new project in the top right. Call it medium. Click on create pipeline. Call the pipeline medium-customer and choose our git\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":829,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-15-34e1bba8351b\/","url_meta":{"origin":822,"position":5},"title":"Messaging and Event Driven Design","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"In order publish messages, we need a message broker and add some logic to use the message broker. We\u2019re going to use a cloud based SaaS service as a message broker and use spring cloud stream to interact with it. Setup the Message\u00a0Broker We\u2019ll need a message broker in order\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\/822","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=822"}],"version-history":[{"count":3,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/822\/revisions"}],"predecessor-version":[{"id":901,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/822\/revisions\/901"}],"wp:attachment":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/media?parent=822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/categories?post=822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/tags?post=822"},{"taxonomy":"course","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/course?post=822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}