{"id":1230,"date":"2022-01-23T09:44:23","date_gmt":"2022-01-23T16:44:23","guid":{"rendered":"https:\/\/bullyrooks.com\/?p=1230"},"modified":"2022-01-23T09:44:23","modified_gmt":"2022-01-23T16:44:23","slug":"kube-cloud-pt2-database-configuration-in-kubernetes","status":"publish","type":"post","link":"https:\/\/bullyrooks.com\/index.php\/2022\/01\/23\/kube-cloud-pt2-database-configuration-in-kubernetes\/","title":{"rendered":"Kube Cloud Pt2 | Database Configuration in Kubernetes"},"content":{"rendered":"\n<p>We now have an application that will connect to our MongoDB locally, but we&#8217;ll need to tell it how to connect when its deployed to Okteto.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create Kubernetes Configuration<\/h2>\n\n\n\n<p>First, create a secret in okteto with the database details.  Run this command on your terminal.  The uri should look like your uri in the <code>application.yml<\/code> file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl create secret --namespace ${your okteto namespace} generic mongo-secrets --from-literal=SPRING_DATA_MONGODB_URI='mongodb+srv:\/\/${your mongo username}:${your mongo password}@bullyrooks.4zqpz.mongodb.net\/bullyrooks?retryWrites=true&amp;w=majority'<\/code><\/pre>\n\n\n\n<p>Now update <code>deployment.yaml<\/code> in the helm templates to add an environment variable that will be provided from the secret.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>          ports:\n            - name: http\n              containerPort: {{ .Values.port.containerPort }}\n              protocol: TCP\n          env:\n          - name: SPRING_DATA_MONGODB_URI\n            valueFrom:\n              secretKeyRef:\n                name: mongo-secrets\n                key: SPRING_DATA_MONGODB_URI     <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Git Commit and Push<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git add .\n\n$ git commit -m \"added database connection\"\n\n$ git push\n<\/code><\/pre>\n\n\n\n<p>This should trigger a build on the main branch which will result in a deployment to okteto.  You can then manually confirm the functionality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test with Postman<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"857\" height=\"513\" src=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-43.png?resize=857%2C513&#038;ssl=1\" alt=\"\" class=\"wp-image-1238\" srcset=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-43.png?w=857&amp;ssl=1 857w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-43.png?resize=300%2C180&amp;ssl=1 300w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-43.png?resize=768%2C460&amp;ssl=1 768w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Dependabot<\/h2>\n\n\n\n<p>At this point, I decided to try out dependabot integration with github actions.  It&#8217;s very simple to use.  In your <code>\/.github<\/code> directory (not <code>\/.github\/workflows<\/code>) create a file called <code>dependabot.yaml<\/code> with this content<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: 2\nupdates:\n  # Maintain dependencies for GitHub Actions\n  - package-ecosystem: \"github-actions\"\n    directory: \"\/\"\n    schedule:\n      interval: \"daily\"\n  - package-ecosystem: \"maven\"\n    directory: \"\/\"\n    schedule:\n      interval: \"daily\"<\/code><\/pre>\n\n\n\n<p>Now, on the first commit and daily after that, the dependabot script will find any updated versions of libraries used in github actions or maven dependencies, create a PR and kick off your feature branch build.  Once that passes, you can merge that into your main branch.  Its really helpful, because you&#8217;ll be up to date with your dependencies and you&#8217;ll know if an update will be problematic because your build\/test will fail.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\nWe now have an application that will connect to our MongoDB locally,&hellip;\n<\/div>\n<div class=\"link-more\"><a href=\"https:\/\/bullyrooks.com\/index.php\/2022\/01\/23\/kube-cloud-pt2-database-configuration-in-kubernetes\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Kube Cloud Pt2 | Database Configuration in Kubernetes&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":[159,147,79,80,153],"course":[154],"class_list":["post-1230","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-dependabot","tag-github-actions","tag-helm","tag-kubernetes","tag-okteto","course-kubernetes-application-hosted-in-the-cloud-pt-2","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1188,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/01\/04\/cloud-kube-setup-cloud-hosting\/","url_meta":{"origin":1230,"position":0},"title":"Cloud Kube | Setup Cloud Hosting","author":"Bullyrook","date":"January 4, 2022","format":false,"excerpt":"We've got a helm chart and associated docker image. Now we're going to setup a cloud kubernetes provider to deploy our application to. Okteto offers a very generous kubernetes hosting platform that's free for small developer projects. Setup Okteto First register on okteto by creating an account via your github\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":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-31.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-31.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-31.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1205,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/01\/04\/kube-cloud-automate-kube-deploy\/","url_meta":{"origin":1230,"position":1},"title":"Kube Cloud | Automate Kube Deploy","author":"Bullyrook","date":"January 4, 2022","format":false,"excerpt":"Lets improve our CD pipeline by automating deployment. Update Build Pipeline I only want main to deploy on successful build. So add these lines to the end of the main.yaml github action workflow - name: Deploy uses: WyriHaximus\/github-action-helm3@v2 with: exec: | helm repo add bullyrooks https:\/\/bullyrooks.github.io\/helm-charts\/ helm repo update 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":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-36.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-36.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-36.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1264,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/02\/13\/kube-cloud-pt3-health-indicators\/","url_meta":{"origin":1230,"position":2},"title":"Kube Cloud Pt3 | Health Indicators","author":"Bullyrook","date":"February 13, 2022","format":false,"excerpt":"Spring offers a way to tell if your services and their dependent resources are up and healthy. Kubernetes can leverage this functionality via their liveness and readiness probes to report if pods are available to service requests. In this session, we're going to enable and connect those health checks. Enable\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":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-4.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1296,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/02\/19\/kube-cloud-pt4-tracing\/","url_meta":{"origin":1230,"position":3},"title":"Kube Cloud Pt4 | Tracing","author":"Bullyrook","date":"February 19, 2022","format":false,"excerpt":"For this portion we're going to use OpenTelemetry for tracing. OpenTelemetry projects intent is to solve all of the observability space in an opensource way. Unfortunately, at this time the logging and metrics portions are still in development, so we won't be able to use them. However the tracing piece\u2026","rel":"","context":"In &quot;General&quot;","block_context":{"text":"General","link":"https:\/\/bullyrooks.com\/index.php\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-35.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-35.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-35.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-35.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-35.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1356,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/02\/27\/kube-cloud-pt5-create-an-event-consumer\/","url_meta":{"origin":1230,"position":4},"title":"Kube Cloud Pt5 | Create an Event Consumer","author":"Bullyrook","date":"February 27, 2022","format":false,"excerpt":"Now that we've got messages being published to kafka, we are going to need to build our consumer that receives those events and stores them into the mongo database. Go ahead and create a new repository called message-repository according to the microservice startup course here. This is the pom.xml that\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":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-49.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-49.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/02\/image-49.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1220,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/01\/23\/cloud-kube-pt2-setting-up-a-datastore\/","url_meta":{"origin":1230,"position":5},"title":"Cloud Kube Pt2 | Setting Up a Datastore","author":"Bullyrook","date":"January 23, 2022","format":false,"excerpt":"The first part of these courses was all about setting up an build and deploy pipeline so that we could automate building a helm chart and deploying to our cloud hosted environment at Okteto. In this course we're going to start adding more functionality so that we can demonstrate best\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":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-38.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-38.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/01\/image-38.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1230","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=1230"}],"version-history":[{"count":2,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1230\/revisions"}],"predecessor-version":[{"id":1239,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1230\/revisions\/1239"}],"wp:attachment":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/media?parent=1230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/categories?post=1230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/tags?post=1230"},{"taxonomy":"course","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/course?post=1230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}