<?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 David Mukiibi on Medium]]></title>
        <description><![CDATA[Stories by David Mukiibi on Medium]]></description>
        <link>https://medium.com/@david.mukiibiq?source=rss-771f6debd0a7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OH5ZRuH1t83W-CdFssQdow.jpeg</url>
            <title>Stories by David Mukiibi on Medium</title>
            <link>https://medium.com/@david.mukiibiq?source=rss-771f6debd0a7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:36:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@david.mukiibiq/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[How I Turned My Performance Review Into a Fully Automated Daily Actionable System (With AI help)]]></title>
            <link>https://medium.com/@david.mukiibiq/how-i-turned-my-performance-review-into-a-fully-automated-daily-actionable-system-with-ai-help-e1810b06f8e1?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1810b06f8e1</guid>
            <category><![CDATA[performance-reviews]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[apple-reminders]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Thu, 09 Apr 2026 19:16:01 GMT</pubDate>
            <atom:updated>2026-04-09T19:16:01.296Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlHB_F-9cSJLK6p1laqrfQ.png" /></figure><h3>Performance reviews are good at telling you where you fell short. They are terrible at telling you what to do about it tomorrow morning.</h3><p>After six months at my current company, I received mine. Three reviewers, three perspectives, one dense block of feedback. The content was fair (for the most part), but now i had to get to work, but how? There were no clear next steps on how to move forward, no way to know if I was moving in the right direction between now and the next cycle. Just a document.</p><p>The automation engineer in me had an idea, one that would take the <strong>ambiguity</strong>, <strong>friction of execution</strong>, <strong>execution paralysis </strong>out of the way so that I only focus on the actual work needed doing to improve. I wanted to turn that document into a system, one that runs quietly in the background, nudges me daily, and tracks progress without me having to think about it. Here’s exactly how I built that, using AI (Claude + ChatGPT), a few shell scripts, Apple Reminders, and a cron job, all running on my laptop (Macbook).</p><h3>The Problem with Feedback Loops</h3><p>Most performance feedback lands in one of two places: a forgotten folder, or a vague mental note. Neither produces change, at least to me.</p><p>One of the biggest issues is the gap between receiving feedback and operationalising it. The feedback tells you <em>what</em> to improve. It rarely tells you <em>how</em> to do that in the next 24 hours. Bridging that gap manually, writing action items, scheduling check-ins, remembering to actually do things is friction. And guess what kills follow-through, <strong>friction.</strong></p><p>The goal of this setup is to eliminate that friction entirely. Once built, the system handles the mundane job of reminding you of the <em>when</em>, the <em>what</em> and the <em>how </em>and all you do is just show up and just do the work. Which is where the actual value lies anyway.</p><h3>The Architecture Before the Code</h3><p>Before writing a single line, I mapped out the three things the system needed to do:</p><ol><li><strong>Generate the plan: </strong>90 days of daily tasks derived from my performance review, one task per working day, 12 weeks × 5 days = 60 tasks.</li><li><strong>Deliver the plan weekly: </strong>Each Sunday, populate my per-day Reminders lists (Monday through Friday) with the upcoming week’s tasks.</li><li><strong>Mark the week done: </strong>Each Friday, automatically complete all that week’s tasks so the master list stays clean.</li></ol><blockquote>I deliberately constrained the toolset: iPhone, MacBook, Apple Reminders. No paid software, no new SaaS subscriptions. The Apple ecosystem handles sync natively, once a reminder exists on the Mac, it appears on my iPhone without any extra work.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPIjkKo6kwQA1WxIvUyKHw.png" /></figure><h3>Step 1: Use AI to Derive Actionable Tasks from Your Review</h3><p>The performance review gave me themes, not tasks. Feedback like <em>“david could take more ownership”</em> or <em>“needs to improve cross-team visibility”</em> is directionally useful but not executable.</p><p>I shared the review with ChatGPT, which had months of professional context about my work, and asked it to be honest: what are the actual gaps, and what would closing them look like day-to-day?</p><p>Then I moved to Claude and asked it to design a 90-day attack plan. The constraint I gave it was important: each action item had to be small enough to do in under an hour, on a normal workday, without requiring special setup. The output was 60 tasks organized into 12 weeks, each week building on the last.</p><p>The trade-off here is specificity. The more context you give the AI tool of choice about your actual role and team setup, the more useful the tasks output will be. Generic prompts produce generic plans. I gave it my job title, team structure, current projects, and the verbatim feedback. That specificity made the difference.</p><blockquote>It’s also worth noting that I removed any personally identifiable information (PII) for everyone except myself from the review text file and team structure. After all, the focus is on my performance, not theirs. However, since their roles were relevant to the review, I replaced their names with aliases such as “teammate A” and “manager B.”</blockquote><p>The tasks looked like this:</p><pre>Week 1: Decide and document flagship ownership area (Proactivity &amp; Ownership)<br>Week 1: Write 1-page proposal draft (Proactivity &amp; Ownership)<br>Week 2: Raise one risk early in planning (Early Risk Signaling)<br>Week 7: Draft mini reliability proposal (Technical Initiative)<br>...</pre><p>Each task maps to a theme, which maps back to a specific piece of feedback. That traceability matters at the next review, I can point to concrete evidence of what I did to address each point.</p><h3>Step 2: Seed the Master Reminders List with the growth plan</h3><p>With 60 tasks in hand, the next step was getting them into Apple Reminders, all of them, with the correct due dates, automatically.</p><blockquote>The choice to use Apple reminders was simple; it is a reminders app, it sits natively on my macbook and iphone, I always have my iphone with me during the work day and guess where i do my work during the work day? The macbook.</blockquote><p>The script takes a START_DATE variable and calculates each task&#39;s due date using macOS BSD date with epoch arithmetic. Each task gets seeded into a list called &quot;90 Day Growth Plan&quot; with a 9am due time.</p><pre>#!/bin/bash<br>LIST_NAME=&quot;90 Day Growth Plan&quot;<br>START_DATE=&quot;2026-02-23&quot;<br>add_task() {<br>    TITLE=&quot;$1&quot;<br>    YEAR=&quot;$2&quot;<br>    MONTH=&quot;$3&quot;<br>    DAY=&quot;$4&quot;<br>    /usr/bin/osascript &lt;&lt;EOF<br>tell application &quot;Reminders&quot;<br>    tell list &quot;$LIST_NAME&quot;<br>        set dueDate to current date<br>        set year of dueDate to $YEAR<br>        set month of dueDate to $MONTH<br>        set day of dueDate to $DAY<br>        set hours of dueDate to 9<br>        set minutes of dueDate to 0<br>        set seconds of dueDate to 0<br>        make new reminder with properties {name:&quot;$TITLE&quot;, due date:dueDate}<br>    end tell<br>end tell<br>EOF<br>}</pre><p>Run it once. The master list is populated. You don’t touch it again.</p><h3>Step 3: Weekly Sync</h3><p>The master list is the source of truth, but it’s not what I look at daily. Looking at all 60 tasks at once is exactly the kind of cognitive overload I am trying to avoid.</p><p>Every Sunday at 8pm, a cron job runs a shell scriptweekly_growth_sync.sh. It calculates the upcoming Monday, loops through each weekday, queries the master list for tasks due on that date, and writes them into per-day lists (Monday, Tuesday, etc.). Below is just a snippet of the script.</p><pre>#!/bin/bash<br><br>set dayReminders to reminders of sourceList whose due date ≥ targetDate and due date &lt; nextDate<br>repeat with r in dayReminders<br>    set reminderName to name of r<br>    set existing to reminders of targetList whose name is reminderName<br>    if (count of existing) is 0 then<br>        make new reminder at targetList with properties {name:reminderName}<br>    end if<br>end repeat</pre><p>The duplicate check matters. If the script runs more than once in a week, say you run it manually to debug, you don’t want Monday’s list to have the same task twice. The count of existing guard handles this cleanly.</p><blockquote><em>The trade-off with per-day lists is maintenance: if you add a task or shift a date in the master list, the weekly lists don’t automatically update. They pull a fresh snapshot every Sunday. This is intentional as it keeps the weekly view stable once the week has started.</em></blockquote><h3>Step 4: Auto-Complete the Week</h3><p>By Friday, the week’s tasks should be done. Whether they are or not, I want the master list to reflect a completed week so it stays clean and readable.</p><p>Every Friday at 6pm, a second cron job runs the shell script weekly_growth_complete.sh. It calculates the Monday-to-Friday window for the current week in the master list and marks every task in that range as done. Below is a snippet.</p><pre>#!/bin/bash#!/bin/bash<br><br>set weekReminders to reminders of sourceList whose completed is false ¬<br>    and due date ≥ thisMonday and due date &lt; endOfFriday<br>repeat with r in weekReminders<br>    set completed of r to true<br>end repeat</pre><blockquote>This is a deliberate design choice, not a bug. The script completes tasks regardless of whether you actually did them. The reasoning being that if you didn’t do something and it wasn’t deferred, the week is over. Leaving it open creates visual debt that discourages you from opening the list at all. Done is a better default than an ever-growing backlog of guilt.</blockquote><p>If you want stricter tracking, you can invert the logic, instead of marking incomplete tasks done, you could log them elsewhere before completing them.</p><h3>Step 5: Schedule It and Forget It</h3><p>The cron entries are straightforward:</p><pre># Every Sunday at 8pm populate next week&#39;s daily lists<br>0 20 * * 0 /path/to/weekly_growth_sync.sh<br><br># Every Friday at 6pm complete the current week<br>0 18 * * 5 /path/to/weekly_growth_complete.sh</pre><blockquote>One important caveat: <strong>cron does not run missed jobs</strong>. If your macbook is closed at 8pm Sunday, the sync doesn’t run. You’ll open Monday with empty daily lists.</blockquote><p>The fix is migrating to launchd. A launchd plist agent with StartCalendarInterval will fire the job when the machine wakes, even if it missed the scheduled time. For a home Mac mini running 24/7, cron is fine. For a laptop, launchd is the right call.</p><h3>What This Actually Looks Like Day-to-Day</h3><p>I followed Chris Asante in this video <a href="https://medium.com/p/e1810b06f8e1/youtube.com/watch?v=tOCMkasAiSk">here</a> to set up my reminders app and its widgets strategically to remove another layer of friction, remembering to open the reminders app to tick off items and to give me a glimpse into my day’s tasks.</p><p>With how the reminders widgets are set up following the above video, each morning I have the day’s reminders lists at a glance with little to no effort. Each list has a task that has a due date and time for that day at 9am (start of the work day), I do the work, add a note about what I actually did, and check it off.</p><p>That’s the entire interaction. The system handles everything else.</p><p>By week 9, the tasks look like this:</p><pre>Week 9: Ask manager what next-level ownership means (Strategic Alignment)<br>Week 9: Lead milestone discussion (Visible Leadership)<br>Week 9: Mentor peer on technical topic (Leverage &amp; Enablement)<br>Week 9: Publish cumulative impact summary (Promotion Narrative)</pre><p>At this point, the themes from the original performance review are showing up as concrete evidence and not just intentions.</p><h3>What This System Is and Isn’t</h3><p>This is a delivery mechanism, not a productivity philosophy. It doesn’t make you work easier. It simply removes the decision fatigue around <em>what</em> to work on, which makes it easier to start.</p><blockquote>The tools are deliberately boring. Bash, AppleScript, cron, Reminders. That’s the point. Boring tools seldom break, don’t require subscriptions, and don’t need maintenance. The Apple ecosystem sync means anything created on the Mac appears on my iPhone automatically. Zero configuration, zero friction.</blockquote><blockquote>This is version 1.0 of the system and it shows, there’s no handling for PTO, sick days, or paused weeks. If you miss a week, the Friday auto-complete will mark those tasks done regardless.</blockquote><p>A future improvement would be addressing the above as I recently went on vacation aka PTO and my iPhone, on one serene morning reminded me to <em>“study the system and identify a potential improvement path”</em></p><blockquote>The bigger point is this: you don’t need better tools. You just need to use the tools you already have more deliberately. This whole setup took an evening to design and build and has run without intervention for weeks. The next performance review will be different, not because I worked harder, but because I actually showed up every day, lazy but building value.</blockquote><blockquote>All scripts referenced in this article are available in this GitHub <a href="https://github.com/davidmukiibi/PerformanceReviewSystem">repo</a>.</blockquote><h3>Conclusion</h3><p>I’m running this with Apple ecosystem native tools because that’s what I have. But this idea doesn’t belong to any ecosystem.</p><p>If you’re on Android and/or Windows, you can wire this up with Google Tasks, Gemini, and a Python script running on a schedule. If you’re already using Notion, connect it to n8n or Zapier and have your tasks pushed there automatically. If you have a Raspberry Pi sitting on your desk doing nothing, yes, you can run the automation from there as well.</p><p>The principle is the same everywhere: <strong>AI breaks down the goal into digestible chunks (with your guidance), automation delivers it to you daily, and YOU just show up.</strong></p><blockquote><strong>90 days later, you’re an improved champ</strong></blockquote><p>The tools are just one path. Find yours; whether that’s for school, a side project, or a business goal and build something lazy that delivers value every day. If you want a thought partner while you figure it out, don’t be shy. Reach out and we’ll build these lazy systems together.</p><h3>Credits</h3><p>Two people deserve a mention here because they shaped how I think about automation and productivity.</p><p><strong>Chris Asante</strong> showed me how Apple Reminders can be a serious productivity layer, not just a grocery list app. You can find the specific video <a href="https://medium.com/youtube.com/watch?v=tOCMkasAiSk">here</a></p><p><a href="https://www.youtube.com/@beardfm"><strong>Stephen Robles</strong></a><strong> </strong>got me deep into Apple Shortcuts in a way that changed how I approach automation day to day.</p><p>Neither of them told me to build exactly this. I just took what they planted and grew something that fit my life to solve a problem I had.</p><p><em>That’s kind of the whole point.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1810b06f8e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon’s Alexa meets DevOps (2/2)]]></title>
            <link>https://medium.com/the-andela-way/amazons-alexa-meets-devops-2-2-b3fb47e4d7f4?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3fb47e4d7f4</guid>
            <category><![CDATA[alexa-skills]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[the-andela-way]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Mon, 24 Feb 2020 08:45:02 GMT</pubDate>
            <atom:updated>2020-02-24T08:45:02.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-K6dbXaLWdD-aPdLH1u5g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@vminkfotos?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Vu M. Khuee</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a> with a twist</figcaption></figure><blockquote>This is continuing from part 1 where I showed you how to create a new alexa skill from scratch</blockquote><p>In this part I will take you through writing the code for the backend using the Alexa SDK and AWS boto3 Python SDK to query AWS S3 as hinted on earlier in part (1/2) <a href="https://medium.com/the-andela-way/amazons-alexa-meets-devops-1-2-4aebe51f8624">here</a>. Let’s begin.</p><p><strong>Building the backend</strong></p><blockquote>The alexa skill we are creating is one that will <em>create</em>, <em>delete</em> and <em>list</em> a registered AWS user’s S3 buckets</blockquote><p>To pull this off, we have to integrate alexa with AWS S3 through its well documented API.</p><blockquote>To our advantage, the awesome engineers at AWS have created very user friendly APIs for all their services and coupled them with very easy-to-read, understand and use SDKs and documentation</blockquote><p>As mentioned earlier, for this one we shall use AWS python SDK, <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html">boto3</a>. Just like amazon’s AWS documentation states<em>:</em></p><p><strong><em>“Boto is the Amazon Web Services (AWS) SDK for Python. It enables Python developers to create, configure and manage AWS services, such as EC2 and S3. Boto provides an easy to use, object-oriented API, as well as low-level access to AWS services”</em></strong></p><p>Talk is really cheap is you ask me; so let’s write some code.</p><p>Create a main.py file or give the file any name you wish and write the code below in it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oVw7st1TQ5lUfowMSLZ6Q.png" /></figure><p>In the screenshot above, we import all necessary packages we shall require to build this backend as well as set up STS (Secure Token Service), an AWS security credentials service. That is line 16 to 27. Don’t mind line 18, I will show you where to get that when we are setting up AWS IAM permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-eq5G_6JIwcUWJHQqZjDQ.png" /></figure><p>On line 55 we pick the bucket name to be created from a slot value and we assign it to a variable “bucket_name”.</p><blockquote>This is the name of the s3 bucket you told alexa when you mentioned a phrase like “create kampala bucket” to Alexa</blockquote><p>Line 57 to 63 we now create the S3 bucket with the help of AWS’ boto3 SDK and also set the “speak_output” variable with appropriate responses when certain checks (“if” statement on line 59) pass or fail.</p><blockquote>Line 64 we handle errors incase any occur while we try to create the s3 buckets</blockquote><p>Finally on line 69 we now end the execution of the “create bucket” class definition while at the same time we tell alexa service to build and deliver our response to the user as seen on lines 70 to 73.</p><blockquote>For this alexa skill I have “created”, “listed”, “counted” and “deleted” S3 buckets</blockquote><blockquote>In the screenshot above is one of the classes that creates an S3 bucket. For the sake of the length of this article, I have not included the rest of the remainging code but all of it in its entirety can be found in this <a href="https://github.com/davidmukiibi/aws_devops_alexa_skill">github</a> repository.</blockquote><blockquote>I tried to write the code as simple as possible so that anyone can understand it even without comments. Let me know incase you need any further clarification on any part of this article or the code</blockquote><p><strong>AWS IAM permissions</strong></p><blockquote>Since the alexa skill is going to be hosted on AWS lambda and we are calling the s3 API, we have to grant permissions to AWS lambda to call the s3 API while it runs the skill backend</blockquote><p>To achieve this, we make use of an assume role. This is what allows “trusted” users/services (lambda, ec2, etc) to assume a “role” for a given time period (like 1 hour, or 10 minutes, depending on what you set). Essentially it grants an entity all permissions it has for a given time.</p><blockquote>We shall now create the assume role wih “create”, “list” and “delete” permissions scope</blockquote><p>Head over <a href="https://console.aws.amazon.com/iam/home?region=us-east-1#/roles$new?step=type">here</a> to create an assume role. You should see something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1yqr8divmZzLUP9NZc5ww.png" /></figure><p>Select “<strong><em>AWS Service</em></strong>” as the <strong><em>trusted entity</em></strong> type, then select “<strong><em>Lambda</em></strong>” as the service that will call AWS services on your behalf. What this means is essentially allowing this service to use this role.</p><p>With that selected, click “<strong><em>Next: Permissions</em></strong>” button. That will take you to this page to assign permissions to the role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysI9e9ZBAUl9qRxJ8w5cyA.png" /></figure><p>Select the “<strong><em>AmazonS3FullAccess</em></strong>” to grant all S3 access rights to this role. <em>I know this is a little too much permissions.</em></p><p>You can add tags if you so wish by clicking the “<strong><em>Next: Tags</em></strong>” button to take you to the next page to add some. After that, click next to head to this page where you can now give your role a meaningful name and finally create the role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l62BYdVap3HHCsKiNiVibQ.png" /></figure><p>And just like that, we have created a role. But we are not finished yet as we are yet to “tell” the role which entities/users are allowed to use it. Lets do that next.</p><p>Head over to your newly create role as shown below in the IAM section of your AWS console and click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c81POFxiEAAfFfLHGgpFLQ.png" /><figcaption>Role</figcaption></figure><p>You will then be taken to the next page where you can see your role in detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BUWV3e3SqXZpHDvMSITwfQ.png" /><figcaption>Edit Role Trust Relationships</figcaption></figure><p>Click on the “<strong><em>Trust Relations</em></strong>” tab to edit these and add the entities that will use this role. For our case, the entity that will make use of this role is the Alexa hosted service lambda function. We therefore need its Amazon Resource Name (ARN) to add it among the trusted relationships of this newly created role.</p><p>Switch over to your alexa developer console and under the “<strong><em>code</em></strong>” tab, click the icon as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTPXmJXGKx8GJebGT8ahdQ.png" /><figcaption>Assume Role ARN</figcaption></figure><p>This will display the ARN for your skill as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6HBKjDbgkZxnRYfOt3DL8A.png" /><figcaption>AWS Lambda Execution Role ARN</figcaption></figure><p>Copy this and the go back to the AWS console and add the copied ARN to the assume role trust relationships and your new trust relationship configuration json file should look like so. (don’t mind line 15)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dPZyvwBVQgoSCSjjkpMoFA.png" /></figure><p>In the default trust relationship, we have added lines 12 to 20 to allow the lambda function hosting our alexa skill to assume this role on line 16.</p><p>With that done, we are now good to go. Let’s take this skill for a spin. Shall we?</p><p>Go back to the alexa developer console <a href="https://developer.amazon.com/alexa/console/ask">here</a> and then go to the “<strong><em>test</em></strong>” tab. You can enable the microphone and speak the commands or simply type them in using your computer keyboard. Which I will do for the sake of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GN0WhyFZX2Ge5zTeWK2vQ.png" /><figcaption>Test The Skill</figcaption></figure><p>Invoke the alexa skill with the same invocation name you created at the beginning. The invocation name for this skill is “<strong><em>devops cloud assistant</em></strong>”.</p><p>This will trigger the “<strong><em>LaunchRequest</em></strong>” intent and subsequently the intent handler and alexa will speak the phrase “Welcome back sir. how may I help you today?” as I set it through the “speech_text” variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Whi19RLHwSnQFzHfcPNUA.png" /><figcaption>Skill Invocation</figcaption></figure><p>Go ahead and speak/type more command words/phrases similar to those in your “<strong><em>utterances</em></strong>”. These have to be identical phrases otherwise a fallback intent will be initiated and that does us no good.</p><blockquote>It’s worth noting that at the end of the alexa response to your request, she remains open to receive further commands/utterances for 30 seconds after which you will have to invoke the skill again from the top using the invocation name</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7ABhZSI_-zFbRDBHvOAbQ.png" /><figcaption>Skill Invocation</figcaption></figure><p>And just like that, we have created an S3 bucket on amazon AWS using amazon Alexa.</p><blockquote>It is worth noting that all these voice commands also work on amazon speaker enabled devices like the echo or echo dot</blockquote><p>Go ahead and try other “commands” to delete or list your S3 buckets. To confirm your action you can go to the AWS S3 page and check for your created/deleted buckets.</p><p>All the code for this is pushed to <a href="https://github.com/davidmukiibi/aws_devops_alexa_skill">this</a> github repository for your reference.</p><blockquote>The code is not perfect but it works, and as our forefathers once said, if it works, don’t touch it. So whoami to touch it?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iREdGusRoWhbjaj-v9Z2Vg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@amseaman?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Andrew Seaman</a> on <a href="https://unsplash.com/s/photos/bottlenecks?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>A few bottlenecks to look out for:</strong></p><ol><li>You must fulfill the requirements for all the platforms you are “<em>glueing</em>” together to avoid development headaches. Such requirements in this project included AWS IAM permissions to allow the alexa skill access to the AWS S3 API. Essentially <strong><em>authentication</em></strong>.</li><li>Alexa skill builder <a href="https://developer.amazon.com/en-US/docs/alexa/custom-skills/slot-type-reference.html">slot</a> types for example are limited to a given set of types. like numbers, movie titles, city names, etc and some are restricted/limited to regions. For instance there are slot types one can access/use during development while in the US and can not access/use while in Kenya. By this I mean, when you type in the search bar of the slot types as you select which slot type to use, you never see the one you are looking for if you are in a region where it is restricted. It is worth noting though that you can create your own slot types, for instance is you want them to be specific to say, african surnames or village clan chiefs, etc.</li><li>S3 bucket naming convention. This is not an issue up until when you are creating such a project where the slot type is fine but that name you want to use, which matches the alexa slot type is not accepted by S3 because it is not unique to the whole S3 universe.</li></ol><blockquote>All these requirements must align like the orion’s belt to pull off a project of the sort seamlessly. The slot type you choose determines what bucket names you can create and those must align with the s3 buckets naming convention</blockquote><blockquote>This project is just a tip of the iceberg in terms of the code quality, solution creativity, and alexa service “best practice” adherence. It is a showcase of the possibilities and capabilities Alexa can bring to the table even for us Engineers in the software delivery realm.</blockquote><p>Feel free to fork this repository and make your own additions to the code, or use the idea as an inspiration to do a lot more with alexa than is currently available to automate and simplify your life.</p><blockquote>Imagine telling alexa to run your unit tests and report back with what percentage they passed, all while you watch a movie in your living room, or commuting to office while you drive, or telling alexa to build a docker image for you for a given micro service while you focus on something else. Just imagine…</blockquote><p>Let me know of your works on this topic on <a href="https://twitter.com/davidcarson02">twitter</a>, <a href="http://www.linkedin.com/in/david-mukiibi">linkedin</a> or here in the comments. I’d love to borrow some ideas myself or even collaborate on a project with you.</p><blockquote>To Endless Possibilities. Cheers!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3Je5oGx0hZ4Vvd9CPD_GQ.jpeg" /><figcaption>Cheers</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3fb47e4d7f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/amazons-alexa-meets-devops-2-2-b3fb47e4d7f4">Amazon’s Alexa meets DevOps (2/2)</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon’s Alexa meets DevOps (1/2)]]></title>
            <link>https://medium.com/the-andela-way/amazons-alexa-meets-devops-1-2-4aebe51f8624?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4aebe51f8624</guid>
            <category><![CDATA[alexa-skills]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[the-andela-way]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[generics]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Sun, 23 Feb 2020 09:43:13 GMT</pubDate>
            <atom:updated>2020-02-23T10:34:11.809Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon’s alexa as well as many other voice assistants are taking the new world by storm with automation of daily routine tasks. Given how fast the world rotates in today’s age, automation seems more appealing than ever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A6tPtUi8R4cNzuYK4-syYA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@austindistel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Austin Distel</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a> with my own twist</figcaption></figure><blockquote>As a DevOps Engineer, one of the kings of automation, I choose to take alexa for a spin into our world in this series of articles of how Amazon’s Alexa meets DevOps</blockquote><p>In this 2 part series, am going to take you through developing an alexa skill using the Alexa Skills Kit, AWS boto3 and AWS S3. Which will then be hosted on AWS Lambda.</p><p>In this part am going to take you through the basics of building an alexa skill through the alexa interaction model (“frontend”) and then in the 2nd part take you through the “backend” with the alexa SDK and then bring it all together with AWS S3; Let’s begin.</p><figure><img alt="Amazon Alexa" src="https://cdn-images-1.medium.com/max/420/1*UnOjvqj8A5L-nC0M37pGbQ.png" /><figcaption>source: Google</figcaption></figure><p><strong>A brief introduction to Alexa Development</strong></p><p>When building for Alexa, we use the <strong><em>Alexa Skills Kit</em></strong> to create alexa skills with the help of the Alexa Voice Service interaction model which is supported by the backend that is built using the alexa sdk..</p><p>Just like any normal web application, an Alexa skill also has 3 tiers. It has a frontend (Alexa Voice Service Interaction Model), a backend (Alexa SDK in python or NodeJS) and storage (dynamoDB) which is optional, unless you want to be memorable to Alexa.</p><blockquote>For this article, we are going to stick to the first 2 tiers for simplicity</blockquote><blockquote>While we build for Alexa in this article, we are going to look at 3 main parts. 1/ Alexa Voice Service, 2/ Alexa SDK and the platform/service we are going to interact/integrate with using Alexa (AWS S3)</blockquote><p>To get start, you should have an account with AWS and Alexa Development Platform. If you don’t already have one, create an account for AWS <a href="https://portal.aws.amazon.com/billing/signup#/start">here</a> and Alexa Development <a href="https://www.amazon.com/ap/register?showRememberMe=true&amp;openid.pape.max_auth_age=7200&amp;openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&amp;marketPlaceId=ATVPDKIKX0DER&amp;pageId=amzn_dante_us&amp;openid.pape.preferred_auth_policies=Singlefactor&amp;openid.return_to=https%3A%2F%2Fdeveloper.amazon.com%2Falexa%2Fconsole%2Fask%2Ftest%2Famzn1.ask.skill.fc477a0e-a079-44a4-a63b-381dae5eb1d2%2Fdevelopment%2Fen_GB%2F&amp;prevRID=4TYMWNV2CP4QP5P64JQ2&amp;openid.assoc_handle=amzn_dante_us&amp;openid.mode=checkid_setup&amp;prepopulatedLoginId=&amp;failedSignInCount=0&amp;openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&amp;openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0">here</a>. With that out of the way, let’s start.</p><p>To create an Alexa skill, head over to this <a href="https://developer.amazon.com/alexa/console/ask">link</a> where you should see a page that looks like this one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9Q_QeeXD-MIVCyrcDMaJQ.png" /></figure><p>Clicking on the “<strong><em>Create Skill</em></strong>” button will start the skill creation process. This will take you to this page where you will give your new skill a name, choose a default language, choose a model to add to your skill, one that suits the needs the skill will address (for this article I chose custom) and finally you choose the method to host your skill’s backend. see image below for reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41d13YHKDaTHzHfwD4D99Q.png" /><figcaption>alexa skill creation</figcaption></figure><p>For the hosting method, choose one that fits your tech stack, <strong><em>nodejs</em></strong> or <strong><em>python</em></strong> (alexa hosted backends) or choose “<strong><em>provision your own</em></strong>” if you are going to host the skill yourself somewhere other than the default alexa hosted platform.</p><p>With all that set, click the “<strong><em>Create Skill</em></strong>” button which will segue you to this page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*huyLVwy-aXR-occKOs4yNQ.png" /><figcaption>skill template</figcaption></figure><blockquote>The developers in charge of the Alexa development project have put up awesome templates to help kickstart anyone creating an alexa skill with some ready made skills whose templates have useful behaviour that may be necessary for one creating a new skill</blockquote><p>Go ahead and select a template whose features closely match your desired ones. You can know this through the tags on each template as highlighted on the screenshot above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_7JroIlkApQxJH9muno-A.png" /></figure><p>With that selected, go ahead and click the “create” button which will then go ahead and create your new skill with template code from the template you chose in the previous section. This code can be edited to your custom specification.</p><blockquote>With that done, you will be redirected to your new skill dashboard console</blockquote><p>To start/use your newly created skill, you have to mention a specific word to invoke it. This invocation phrase/name of your skill (the words you speak to the alexa device to start your skill) is normally defaulted to your skill’s name, but you can change it in the “<strong><em>Invocation”</em></strong> tab on your skill console under the <strong><em>Build </em></strong>tab as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YptnmQbtjgNUK7P1X3dSxQ.png" /></figure><blockquote>With that out of the way, let’s build the frontend</blockquote><p><strong><em>Frontend</em></strong></p><p>In the Alexa Voice Service interaction model we define and build the “<em>frontend</em>” for the alexa skill.</p><blockquote><em>The</em> interaction model<em> is the interface through which a user’s interaction with the skill is digested and forwarded to the backend</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxawIcZpmTuXJNYr3LTMYA.png" /><figcaption>alexa frontend builder (<a href="https://developer.amazon.com/alexa/console/ask/build/custom/amzn1.ask.skill.fc477a0e-a079-44a4-a63b-381dae5eb1d2/development/en_GB/dashboard">https://developer.amazon.com/alexa/console/ask</a>/build/)</figcaption></figure><p>To define the interaction model, we map a user’s spoken input(phrase) to intents defined in the backend cloud-hosted alexa skill service.</p><p><strong><em>Frontend building blocks:</em></strong></p><ul><li>Intent</li><li>Slot</li><li>Utterance</li></ul><blockquote>An <strong>intent</strong> represents an action that fulfils a user’s spoken request/phrase. These can optionally have <em>arguments</em> called <em>slots</em>.</blockquote><blockquote>A <strong>slot</strong> is a variable value that is supplied to the intent at runtime through an utterance spoken by the user</blockquote><blockquote>An utterance is a spoken phrase that a user may speak</blockquote><p>Slots have types; something like a variable in python of type <em>int</em> where all values of that variable will be integers.</p><p><strong><em>Backend</em></strong></p><p>The alexa backend is built using the alexa skills sdk. There is a number of these in various languages like <em>python</em>, <em>java</em> and <em>node js</em>. For this one we shall use <em>python</em>.</p><p>When a user speaks an utterance, the Alexa Voice Service “digests” it, checks the “frontend” (interaction model) for an utterance that matches the said phrase and if there is a match it sends it to the <em>intent</em> under which that utterance was registered.</p><blockquote>Utterances specify the words/phrases users can say to invoke a skill’s intents. These should include as many representative phrases as possible that you think your users will say to invoke that specific intent, all of which are mapped to their respective intents in the interaction model as shown in the image below.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Uzi9VXm9zq694WqTN1ceQ.png" /><figcaption>Sample utterances for the CreateBucket intent</figcaption></figure><p>The Alexa Voice Service goes ahead and queries the backend for an intent handler with a similar name as that of the invoked intent which must also be “lebelled” as the handler for that intent. We shall see this in action soon when we get to the code.</p><blockquote>An intent handler is the Alexa skill backend where a user request is sent to be digested</blockquote><p>The backend (intent handler) then digests the request, constructs a response and hands it over to the Alexa Voice Service to speak to the user through an alexa device like an <em>echo dot</em> or<em> echo show</em>.</p><blockquote>When creating a new alexa skill, you have to declare where the backend will be hosted, it can be hosted on any platform that can expose an HTTP(S) API endpoint.</blockquote><blockquote>Platforms such as kubernetes, EC2, GCE, aws lambda</blockquote><p>For this artcile we are using an Alexa hosted backend/endpoint which is hosted on AWS lambda but deployed and maintained by the Alexa development platform so that all we focus on is the actual alexa skill and not the underlying infrastructure. You know the drill; <strong><em>serverless</em></strong>.</p><p>In part (2/2) of this article series, we shall go ahead and build out the backend of this skill and set all the required user permissions on the AWS IAM side of things and eventually deploy the completed skill and test it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*2GOMAkM6NxV4J97kCtnQLg.png" /><figcaption>Source: Google</figcaption></figure><p>Just like the screenshots above may have hinted, yes, the skill is going to query AWS’ S3 to create, delete and list a registered AWS user’s S3 buckets.</p><p>Fill free to drop a comment or suggestion or question about anything in this article for improvement, addition or collaboration. <a href="http://www.linkedin.com/in/david-mukiibi">LinkedIn</a>/<a href="https://twitter.com/davidcarson02">Twitter</a></p><p>With that said, follow me to 2/2 <a href="https://medium.com/the-andela-way/amazons-alexa-meets-devops-2-2-b3fb47e4d7f4">here</a> to continue the journey into building for voice automation with Amazon’s Alexa in the DevOps realm.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4aebe51f8624" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/amazons-alexa-meets-devops-1-2-4aebe51f8624">Amazon’s Alexa meets DevOps (1/2)</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host your application on Google Kubernetes Engine]]></title>
            <link>https://medium.com/the-andela-way/how-to-host-an-application-on-gke-e95e7b1177eb?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e95e7b1177eb</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[the-andela-way]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Thu, 15 Nov 2018 12:44:31 GMT</pubDate>
            <atom:updated>2018-11-15T18:20:03.088Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcLoCGes3i0pMJh4R0zkSA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/o4UhdLv5jbQ?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">True Agency</a> on <a href="https://unsplash.com/search/photos/true-agency?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><blockquote>As a developer, it is always a daunting task to host your creation on a platform other than a <a href="https://azure.microsoft.com/en-us/overview/what-is-paas/">Platform as a Service</a> for example Heroku.</blockquote><p>In this article I will take you through the process of deploying an application to an <a href="https://azure.microsoft.com/en-us/overview/what-is-iaas/">Infrastructure as a Service</a> for example <a href="https://cloud.google.com/kubernetes-engine/">Google Kubernetes Engine</a> and hope that it will remediate your fear of “lower-level” hosting services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJUgyM2DnJAFe_8WJESLHA.png" /><figcaption>source: presslabs.com</figcaption></figure><p>We will take the following steps to host our application:</p><ol><li>Kubernetes cluster creation</li><li>Dockerizing the application</li><li>Set up Kubernetes configuration</li><li>Nginx installation and configuration</li><li>DNS configuration</li><li>Provisioning Secure Socket Layer (SSL) certificates</li></ol><h4><strong>The Application</strong></h4><p>The application has a frontend built with <a href="https://reactjs.org/">React</a> and backend (API built with <a href="http://flask.pocoo.org/">Python Flask</a> and <a href="https://www.postgresql.org/">Postgresql</a> as the database).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JOzeDZ80GaIApmews8mWCw.png" /><figcaption>React, Python flask and Postgres</figcaption></figure><blockquote>This is basically an implementation of the 3 tier architecture; presentation layer (frontend), logic layer (API) and data layer (database) all separate and independent.</blockquote><blockquote>The application is a “bucketlist” application where a user can record there bucketlist items along with with action items on how they will achieve them.</blockquote><p>The first step to hosting this application on GKE is to dockerize it. That is, dockerizing each of the 3 tiers of the application. Clone <a href="https://bitbucket.org/dawei-mukiibi/application-only/src/master/">this</a> repository to follow along.</p><h4>Prerequisites</h4><p>The tools we shall use in this article include the following:</p><ol><li><a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">kubectl</a></li><li><a href="https://cloud.google.com/sdk/install">gcloud</a></li><li><a href="https://docs.docker.com/install/overview/">docker</a></li><li><a href="https://cloud.google.com/resource-manager/docs/creating-managing-projects">google cloud project</a></li></ol><p>Follow the in-screen prompts to get you set up with the above tools. This may involve logging into your google cloud account.</p><blockquote>If you don’t already have<strong> </strong>them setup, go on and setup through those links.<strong> </strong>If you already have them setup, let’s match on.</blockquote><h4><strong>Kubernetes cluster creation</strong></h4><p>Let’s start off by creating a kubernetes <a href="https://kubernetes.io/docs/setup/scratch/">cluster</a> and while at it configure all the required credentials to interact with the newly created cluster.</p><blockquote>There are several <a href="https://cloud.google.com/compute/docs/console">ways</a> to create a cluster in kubernetes; among those include using the<strong> google cloud console</strong>, <strong>command line (gcloud)</strong> or <strong>REST</strong>.</blockquote><p>For this we shall use <strong><em>command line (gcloud)</em></strong>. This allows us to work from our terminal which as a developer you have process working with. Go ahead and set these environment variables first.</p><blockquote>I have put together all these environment variables in an env.sh file, on your terminal, you can run “source env.sh” to populate all of them at once.</blockquote><ol><li><strong><em>$PROJECT</em></strong>: this is the google project ID. The same project you created or want to use for this project.</li><li><strong><em>$CLUSTER</em></strong>: this is the name of the cluster you want to create.</li><li><strong><em>$ZONE</em></strong>: this is the zone in which the cluster will be created.</li><li><strong><em>$GCR_REGISTRY: </em></strong>this is the gcr registry you’re container images reside.</li><li><strong><em>$FRONTEND_DOCKER_IMAGE_NAME: </em></strong>this is the image name you wish your frontend container image to have.</li><li><strong><em>$DATABASE_DOCKER_IMAGE_NAME: </em></strong>this is the image name you wish your database container image to have.</li><li><strong><em>$BACKEND_API_DOCKER_IMAGE_NAME: </em></strong>this is the image name you wish the api container image to have.</li></ol><p>Before we create the cluster, there’s one more piece of the puzzle we don’t have yet. A service account. head over <a href="https://cloud.google.com/iam/docs/creating-managing-service-accounts#iam-service-accounts-create-console">here</a> and create a service account and make sure to assign it these roles:</p><ol><li>roles/storage.admin as stated <a href="https://cloud.google.com/container-registry/docs/access-control">here</a></li><li>roles/project.owner</li></ol><p>After all those environment variables are set and service accounts and roles assigned, then you can run this command:</p><pre>gcloud beta container --project “$PROJECT” clusters create “$CLUSTER” --zone “$ZONE”</pre><p>This command will take a few minutes to complete. On completion, it will have also populated the credentials file as needed for you to interact with the newly created kubernetes cluster.</p><p>Now that we have a cluster, let the kubernetes games begin.</p><h4><strong>Dockerizing the application</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*BwrfAaYVSkezthJHRe7LSQ.png" /><figcaption>source: cengn.ca</figcaption></figure><p>I have set up the application in a way that each tier has its own folder. This makes it easier to organise each tier’s dockerfile.</p><p>On your terminal, change directory into the <strong><em>frontend</em></strong> folder. Since this application is under version control, make sure you checkout the branch you want to build the docker image for.</p><p>Just to be organized throughout the 3 tiers, I put all docker related files in the <strong><em>docker/</em></strong> folder. So, while in the root of the <strong><em>frontend</em></strong> application tier folder, run this command</p><pre>docker build -t $GCR_REGISTRY/$PROJECT/$FRONTEND_DOCKER_IMAGE_NAME:v1 -f docker/Dockerfile .</pre><p>This will take a few minutes to run while it builds and configures the docker image for the frontend tier. When the build is done, go ahead and build the API and database docker images as well.</p><p>Still in your terminal, change directory into the <strong><em>api</em></strong> folder and run this command to build the backend API docker image.</p><pre>docker build -t $GCR_REGISTRY/$PROJECT/$BACKEND_API_DOCKER_IMAGE_NAME:v1 -f docker/Dockerfile .</pre><p>And finally let’s build for the database tier. On your terminal change directory into the <strong><em>database</em></strong> folder and run:</p><pre>docker build -t $GCR_REGISTRY/$PROJECT/$DATABASE_DOCKER_IMAGE_NAME:v1 -f docker/Dockerfile .</pre><p>With the above commands completing successfully, we shall have 3 docker images; Frontend, API and Database locally on your desktop/laptop. Go ahead and edit the <strong><em>deployments.yaml</em> </strong>file in the <strong><em>k8s-configuration</em></strong> folder with the names of the newly created docker images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foa_rJS6QCUFo8fi54Eyrw.png" /></figure><p>For <em>Google Kubernetes Engine</em> to use these images, we have to make them accessible to it. One way of doing that is by pushing them to the <em>Google Container Registry</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*V5s877nzUSxYQ3J5bU_szg.png" /><figcaption>Google Container Registry, source: blog.deimos.fr</figcaption></figure><blockquote>This is<em> Google Cloud Platform</em>’s version of docker hub; google’s container image repository.</blockquote><p>In your terminal, run:</p><pre>gcloud auth configure-docker</pre><p>This will configure docker to use google cloud&#39;s official docker image repositories, the likes of gcr.io, eu.gcr.io, us.gcr.io, so that to push a docker image to those repositories, you do it the same way as you do for docker.</p><p>Let&#39;s now push all the 3 images to <a href="https://cloud.google.com/container-registry/?utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=emea-emea-all-en-dr-bkws-all-rsa-trial-e-gcp-1003963&amp;utm_content=text-ad-none-any-DEV_c-CRE_167354242557-ADGP_Hybrid+%7C+AW+SEM+%7C+BKWS+~+EXA_M:1_EMEA_EN_Compute_Container+Registry_google+container+registry-KWID_43700038695385948-kwd-197849459819-userloc_1009824&amp;utm_term=KW_google%20container%20registry-ST_google+container+registry&amp;ds_rl=1242853&amp;ds_rl=1245734&amp;ds_rl=1245734&amp;gclid=EAIaIQobChMI5eb-svDW3gIVT5PtCh2X3AwkEAAYASAAEgJqlvD_BwE"><em>Google Container Registry</em></a>, simply run:</p><pre>docker push $GCR_REGISTRY/$PROJECT/$FRONTEND_DOCKER_IMAGE_NAME:v1 &amp;&amp; docker push $GCR_REGISTRY/$PROJECT/$BACKEND_API_DOCKER_IMAGE_NAME:v1 &amp;&amp; docker push $GCR_REGISTRY/$PROJECT/$DATABASE_DOCKER_IMAGE_NAME:v1</pre><p>With that complete, let’s now address the elephant in the room; Deploying the application to <em>Google Kubernetes Engine</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*-vrBH4VaiOUvmcZrG3uDUw.png" /><figcaption>source: google.com</figcaption></figure><h4><strong>Kubernetes configuration folder structure</strong></h4><p>I put all the kubernetes configuration files in the <strong><em>k8s-configurations</em></strong> folder. In here we have the deployments, ingress, secrets and services configurations bundled in similarly named <em>yaml</em> files.</p><ol><li><strong><em>deployments.yaml</em></strong>. A deployment is simply a “<em>workload</em>” that holds your applications pod (which contains a container) configurations. This configuration file contains the container image, ports, labels, replica count, etc.</li><li><strong><em>services.yaml</em></strong>. In kubernetes, services are the “glue” of the different “<em>workloads</em>”. These provide connectivity between <em>containers</em> in the kubernetes eco-system. This is because, the way kubernetes was created, a container, can not “talk” to another container if not in the same <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">pod</a>. Essentially, the <strong><em>frontend</em></strong> and <strong><em>API</em></strong> will never “talk” to each other directly if not in the same pod and for this setup, they are not in the same pod. That is why we have to use services.</li><li><strong><em>ingress.yaml. </em></strong>In kubernetes, <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">ingress</a> is a set of rules that direct external internet traffic to services in a kubernetes cluster. This is helpful if you have many services that need to expose deployments to the internet. With ingress, you only use one HTTP load balancer, and it will handle traffic to all those deployments that need the internet, unlike using a separate load balancer for each, which can be costly in terms of cloud computing costs.</li><li><strong><em>secrets.yaml. </em></strong>For our application, the secret we need is an SSL certificate to facilitate SSL termination. This will allow our application to be accessed securely through HTTPS.</li></ol><p>Let’s now go ahead and turn the contents of the kubernetes configuration files into actual cloud computing resources.</p><p>Google’s best practice is that we create <strong><em>services</em></strong> first before <strong><em>deployments</em></strong>. So we shall apply the <strong><em>services.yaml</em></strong> configuration file first. Head over to the <strong><em>k8s-configuration</em></strong> folder and start turning code into actual computing resources.</p><p>On your terminal, while in the <strong><em>k8s-configuration</em></strong> folder, run:</p><pre>kubectl create -f services.yaml</pre><p>Output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VSu1SN76BIDVs9IpUzVgA.png" /><figcaption>iterm output</figcaption></figure><blockquote>This command will create every resource declared in the given <strong><em>services.yaml</em></strong> file.</blockquote><blockquote>This is the declarative way of creating kubernetes resources; declare all of them in a <strong><em>yaml</em></strong> file and pass that file using the<strong><em> -f</em></strong> flag to the <strong><em>kubectl create</em></strong> command and all the magic happens thereafter.</blockquote><p>Do the same for <strong><em>secrets.yaml </em></strong>file, <strong><em>ingress.yaml </em></strong>file and the <strong><em>deployments.yaml</em></strong> file. Run:</p><pre>kubectl create -f ingress.yaml &amp;&amp; kubectl create -f deployments.yaml &amp;&amp; kubectl create -f secrets.yaml</pre><p>With that command completing successfully, head over to GCP <a href="https://console.cloud.google.com/">console</a> under <em>kubernetes engine &gt; workloads </em>section and there you will find your resources you just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HQp5RTyCwKrWnjVigxVevw.png" /><figcaption>Google Kubernetes Engine dashboard</figcaption></figure><p>If you don’t see anything, make sure you have switched to the correct account you setup for this project, in the top right corner, and make sure you have selected the correct project in the top left corner as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8qDv-jXzYoBTUEkjsG2cA.png" /><figcaption>google cloud platform console dashboard</figcaption></figure><p>Take a look at the workloads section, you should have the frontend, API and database up and running with green tick indicators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJEdCEkRM7vEUhnt5tT7KQ.png" /><figcaption>GKE workloads dashboard</figcaption></figure><p>Head over to the services section too and make sure all services are up and healthy with green tick indicators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6fVd_fafMtxt0zA61akDA.png" /><figcaption>GKE services dashboard</figcaption></figure><p>At this point everything is good to go, except for one thing. An ingress controller, without which we can not access any part of our application on google cloud through the browser.</p><p>An <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-controllers">Ingress controller</a> is responsible for fulfilling the Ingress, usually with a loadbalancer. Creating an ingress resource alone will not work without an ingress controller. Thankfully for us, and for helm, we do not have to get into the intricate details of setting up an ingress controller from zero.</p><h4><strong>Ingress controller configuration</strong></h4><p>To get an Ingress controller up and running in our cluster, we are going to use <a href="https://helm.sh/">helm</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ANDxSZMbvvhaxwqdI-6rPw.png" /><figcaption>source: google.com</figcaption></figure><blockquote><strong>Helm</strong> is to <strong><em>Kubernetes</em></strong> what <strong>homebrew</strong> is to <strong><em>macOS</em></strong>, <strong>apt-get </strong>is to <strong><em>ubuntu </em></strong>and<strong><em> </em>pip </strong>is to <strong><em>python. </em></strong>It is a package manager for <strong><em>Kubernetes.</em></strong></blockquote><p>Helm allows us to install dependencies and whole applications that have been bundled together into a package with just one command. Let’s start off by installing and configuring helm.</p><p>In your terminal, run:</p><pre>curl -o get_helm.sh <a href="https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get">https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get</a> &amp;&amp; chmod +x get_helm.sh &amp;&amp; ./get_helm.sh &amp;&amp; helm init</pre><p>The command above fetches the latest version of the helm client and installs it on your local machine (laptop/desktop)</p><p>For helm to work with our cluster, it needs a server-side component installed in the cluster that helm will “talk” to in order to manage and pass commands to so as to create all resources we shall require, for this case, an Ingress controller.</p><p>This component is called <a href="https://docs.helm.sh/glossary/#tiller">T<strong><em>iller</em></strong></a>. To install tiller in a Google Kubernetes cluster, we need to have a service account and cluster role binding configured for tiller. This will allow tiller to be able to install kubernetes resources inside our cluster.</p><p>In your terminal, run the following commands to install and configure tiller as required:</p><pre>kubectl create serviceaccount --namespace kube-system tiller &amp;&amp; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller &amp;&amp; kubectl patch deploy --namespace kube-system tiller-deploy -p ‘{“spec”:{“template”:{“spec”:{“serviceAccount”:”tiller”}}}}’ &amp;&amp; helm init --service-account tiller --upgrade</pre><p>To confirm the tiller installation, run:</p><pre>kubectl get deployments -n kube-system | grep tiller-deploy</pre><p>This will output your newly created <em>tiller-dploy</em> deployment.</p><p>We now have helm and tiller installed and configured on both our local work-station and remote cluster. We can now go ahead and install an Ingress controller into our cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBxR4Kc8hlWPGGL6UrjBPw.png" /><figcaption>nginx ingress for GKE</figcaption></figure><p>There is a variety of Ingress controllers out there, for this, we shall use the <a href="https://kubernetes.github.io/ingress-nginx/">nginx</a> Ingress controller like we declared in our <strong><em>ingress.yaml </em></strong>configuration file. In your terminal run:</p><pre>helm install --name nginx-ingress stable/nginx-ingress --set rbac.create=true</pre><p>This will install the nginx Ingress controller. To confirm our installation, run:</p><pre>kubectl get service nginx-ingress-controller</pre><p>This will give you an output of the nginx controller service of type loadBalancer with an external IP.</p><blockquote>This external IP takes a little while to get created, so if you see &quot;pending&quot;, give it a few seconds/minutes for google to provision it for you.</blockquote><p>At this point, you can access the frontend through the external IP of the nginx ingress controller service. But just like <a href="https://www.youtube.com/watch?v=J5GGG0PaSe4">salt-bae</a>, why be ordinary 😎. Let’s hook that IP up with a domain name so that we can access it through something like http://<a href="http://www.myapp.com/">www.myapp.com</a> instead of <a href="http://35.90.3.9/">http://35.90.3.9.</a></p><p>If you dont have one, you can buy one from the likes of <a href="https://www.godaddy.com/">godaddy</a>, <a href="https://www.hover.com/">hover</a>, <a href="https://domains.google/#/">google-domains</a>, etc. Let’s now configure our domain.</p><h4><strong>DNS configuration</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*VrkW2Kr1N6aftcSfPAoenQ.png" /><figcaption>source: pngall.com</figcaption></figure><p>I have used my own domain name which I will take down a week after this demo article. Head over to your domain dashboard and set up some subdomain names for the <strong><em>frontend</em></strong>, <strong><em>api</em></strong> and <strong><em>database</em></strong>.</p><p>My domain name is <strong><em>davidmukiibi.com</em></strong> and the subdomains I created look like so:</p><pre>frontend.davidmukiibi.com<br>api.davidmukiibi.com<br>database.davidmukiibi.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gad1aXmWlLkG6rUjXT3RaA.png" /><figcaption>hover domain dashboard</figcaption></figure><p>In your terminal, run:</p><pre>kubectl get services | grep LoadBalancer | awk &#39;{print $4}&#39;</pre><p>Copy the output of that command; this is the external IP address through which our application is exposed to the internet.</p><blockquote>In your domain dashboard, fill in this external IP address as the value for the 3 record sets we have created.</blockquote><p>If you check our <strong><em>ingress.yaml</em></strong> file, you will notice we instructed our ingress controller through the ingress resource to force redirect any request to <em>https</em> using this annotation:</p><pre>nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;</pre><p>This will allow only secure connections through to our application.</p><p>Allowing only secure connections to your application is a best practice especially if it works with user data. With that said, we need an SSL certificate to allow end-to-end encryption between our application and the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EcvKVyS-J2YdKNAzK5aNNA.png" /><figcaption>source: google.com</figcaption></figure><p>We shall use let’s encrypt since it offers free SSL certificates valid for 3 months. You can use any certificates if you have any, whether paid or free.</p><h4><strong>Provisioning the ssl cert</strong></h4><p>To acquire the SSL certificates from lets encrypt, we shall use a tool called certbot. Let’s install letsencrypt and certbot.</p><p>Change directory into the <strong><em>k8s-configuration</em></strong> folder, if using ubuntu linux, run:</p><pre>apt-get install letsencrypt</pre><p>If using macOS, run:</p><pre>brew install certbot &amp;&amp; pip install letsencrypt --user</pre><blockquote>Go <a href="https://certbot.eff.org/">here</a> to find your OS installation steps.</blockquote><p>Since we have 3 subdomains associated with the one domain we have, we shall create a wildcard SSL certificate. This will cater for all subdomain of the <em>davidmukiibi.com</em> domain.</p><p>In your terminal, run:</p><pre>certbot --manual --logs-dir certbot --config-dir certbot --work-dir certbot --preferred-challenges dns certonly --server <a href="https://acme-v02.api.letsencrypt.org/directory">https://acme-v02.api.letsencrypt.org/directory</a> --email your-email-address -d “*.davidmukiibi.com”</pre><blockquote>Replace “<strong><em>your-email-address” </em></strong>in the above command with your own email address.</blockquote><p>Follow the on-screen prompts to provision your domain’s wildcard SSL certificate. When you reach the prompt that says:</p><pre><strong>Please deploy a DNS TXT record under the name<br>_acme-challenge.erpnext.davidmukiibi.com with the following value: &lt;value here&gt;</strong></pre><blockquote>“<strong>davidmukiibi.com” should be your own domain name</strong></blockquote><p>Head over to your domain dashboard and create a “<em>txt”</em> record for <strong>_acme-challenge.erpnext.davidmukiibi.com</strong> and fill in the value given on your terminal by certbot.</p><blockquote>NOTE: “davidmukiibi.com” should be your own domain name</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-P2agIJa_KwIiUDEz8L_A.png" /><figcaption>SSL TXT acme challenge</figcaption></figure><blockquote>Give it a minute or two after creating that record</blockquote><p>Go back to the terminal and press enter on your keyboard to continue with the Certificate provisioning process.</p><blockquote>The reason you may have to wait is that at times it takes longer to propagate hence certbot will fail to provision and you will have to repeat the whole process afresh</blockquote><p>When all is done, certbot will have created a “<em>cerbot</em>” folder in your current working directory. And the onscreen output will direct you to where your SSL certificate is along with the 2 import files we need, that is the <strong><em>cert.pem</em></strong> and <strong><em>privkey.pem</em></strong> files. While in the directory with the <strong><em>*.pem</em></strong> files, run:</p><pre><strong>cat cert.pem | base64</strong> <strong>| pbcopy</strong></pre><p>This encodes<strong><em> cert.pem</em></strong> to base64 and copies the <strong><em>cert.pem</em></strong> encoded result output to the clipboard.</p><p>Head over to<strong> </strong>the <strong><em>secrets.yaml</em></strong> file and paste it into the value of <strong>tls.crt: &lt;here&gt;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqoFstjy-kpO8dao_frqAg.png" /><figcaption>secrets.yaml</figcaption></figure><p>Run:</p><pre><strong>cat privkey.pem | base64 | pbcopy</strong></pre><p>to encode the <strong><em>privkey.pem</em></strong> and paste the result as the value of <strong>tls.key:&lt;here&gt; </strong>in the <strong><em>secrets.yaml</em></strong> file<strong>.</strong></p><blockquote>The commands: “cat cert.pem | base64 | pbcopy” and “cat privkey.pem | <strong>base64 |</strong> pbcopy” base64 encode the privkey.pem and cert.pem files and copy the result at the same time. So you will have no output on your terminal but if you ctrl + v or cmd + v in a text editor, you will see the encoded result.</blockquote><p>With the secrets.yaml populated as above, run:</p><pre>kubectl create -f secrets.yaml</pre><p>This will create a kubernetes resource of type secret which our ingress resource will use for SSL termination a.k.a secure browsing using HTTPS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3Fexwa4trN8IGOiu5S1dw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/search/photos/mimi-thian">Mimi Thian</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>We can now spin up our web browsers and head over to <strong><em>frontend.davidmukiibi.com</em></strong> to check out our application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6dNulxcPb1iQjy1est5uQ.png" /></figure><blockquote>Notice how it auto redirects to HTTPS? That’s the magic that comes with using the nginx ingress controller. 💪</blockquote><p>And there you have it. Finally hosted a 3 tier architectured application on Google Kubernetes Engine.</p><p>Go ahead and delete the resources you just created if you don&#39;t need them anymore as they will get billed by Google Cloud and yet not in use.</p><p>To delete the cluster and all resources created earlier, run:</p><pre>gcloud container clusters delete $CLUSTER</pre><p>Special shoutout 👏 to <a href="https://github.com/john555">John</a>, who put together the whole application.</p><p>Catch up on docker commands that will simplify your docker workflow real quick from this <a href="https://medium.com/the-andela-way/introduction-to-docker-commands-eab5cc9bb08d">article</a> I put together.</p><p>Feel free to suggest edits or additions to the knowledge shared here. You can also reach out for a chat through my <a href="https://twitter.com/davidcarson02">Twitter</a> or <a href="http://www.linkedin.com/in/david-mukiibi-b58124104">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e95e7b1177eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/how-to-host-an-application-on-gke-e95e7b1177eb">Host your application on Google Kubernetes Engine</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to docker commands]]></title>
            <link>https://medium.com/the-andela-way/introduction-to-docker-commands-eab5cc9bb08d?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/eab5cc9bb08d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[the-andela-way]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Wed, 28 Feb 2018 12:09:44 GMT</pubDate>
            <atom:updated>2018-04-27T00:01:53.480Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OvtVNCfSajJvZJp3R2vug.jpeg" /><figcaption><a href="http://google.com/">Google</a></figcaption></figure><p>For anyone who has interacted with a certain tool in your development career, you know that there are those commands or keyboard shortcuts that you have at your fingertips that make your life easier while using that tool. It is with that same thought that I present to you the commands any new docker learner should have at one’s finger tips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTtfM-VA1zDIDONFqHniKg.png" /><figcaption><a href="http://google.com/">Google</a></figcaption></figure><ul><li>docker ps lists all running containers on your computer. Additionally run the command below to list all containers in whatever state they are in.</li></ul><pre>docker ps -a</pre><ul><li>docker rm &lt;container ID/name&gt; remove a container whose ID/name is specified in place of &lt;container ID/name&gt;. At times you need to force remove a container, for that run:</li></ul><pre>docker rm -f &lt;container ID/name&gt;</pre><ul><li>docker start &lt;container ID/name&gt; starts a stopped container or one that is not running whose ID/name is specified in place of &lt;container ID/name&gt; in the above command. If, say you need an interactive shell of that container, run the command below to provide for that.</li></ul><pre>docker start -ai &lt;container ID/name&gt;</pre><ul><li>docker stop &lt;container ID/name&gt; stops a running container whose ID/name is specified in place of &lt;container ID/name&gt;. When this command is run, it takes 10 seconds by default to stop that stated container, but you can specify a longer or shorter time with the -t flag followed by time in seconds. something like:</li></ul><pre>docker stop kd778373jjdjsh2998rgghhsg -t 30</pre><ul><li>docker logs &lt;container ID/name&gt; fetches logs of a container whose ID/name is specified in place of &lt;container ID/name&gt;. At times you have an application running in a container and given its setup, you have no way of accessing the container shell to inspect the logs incase the container is still running or exited. This command is useful in many situations such as debugging, logging and monitoring.</li><li>docker exec &lt;container ID/name&gt; &lt;command to run in container&gt;. say you have a running container and you need to run a certain command in it; that is where this command comes into play. This docker command allows you to run a given shell command in that container. For instance, to print the current working directory of a container to your computer’s terminal, run:</li></ul><pre>docker exec &lt;container name/ID&gt; pwd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*B9R0EdP4cyFAx58nTksJDQ.png" /><figcaption><a href="http://google.com/">Google</a></figcaption></figure><ul><li>docker images lists all images stored locally on your computer. Additionally, in your terminal run the command below to list all images, including intermediate images.:</li></ul><pre>docker images -a</pre><ul><li>docker rmi &lt;image ID&gt; remove an image whose ID is specified in place of &lt;image ID&gt;. Just like containers, at times you need to force remove an image. For that, run:</li></ul><pre>docker rmi -f &lt;image ID&gt;</pre><ul><li>docker port &lt;container ID/name&gt; this lists all the port mappings of the given container.</li><li>docker run &lt;image ID&gt; this creates a container from the image specified in place of &lt;image ID&gt;. Additionally if you need some further customization to the docker run command, flags such as -it give you an interactive shell through which you interact with the docker container. So the command will look like docker run -it &lt;image ID&gt;. There&#39;s a bunch of other flags you can apply to this docker command for a more customized container creation process. Run the command below for more options to run with this command.</li></ul><pre> docker run -it &lt;image ID&gt; --help </pre><ul><li>docker build . this builds a docker image from a Dockerfile. In your terminal, run this command in the folder that contains the Dockerfile, Do not forget the period at the end of the command as that specifies the context docker uses while building the docker image. If the Dockerfile does not reside in the same folder where you are running the command, add the -f flag to specify the folder/URL where the Dockerfile resides.</li></ul><pre>docker build -f /folder/where/the/Dockerfile/resides/ .</pre><ul><li>docker pull this command pulls an image from the docker registry to your computer. For instance to pull a postgres image, you run:</li></ul><pre>docker pull postgres</pre><p>If you want to pull a specific version of an image, you add the version of that image like:</p><pre>docker pull postgres:9.6</pre><ul><li>docker push &lt;docker ID/image to be pushed&gt; this will push a locally available image to the docker registry.</li></ul><pre>docker push david/database_image</pre><p>Where david is the repository name, and database_image is the image to be pushed to the docker registry.</p><ul><li>docker login this logs a user into the docker registry from the terminal. Additional flags can be passed with this command to provide for the password -p and username -u.</li></ul><pre>docker login -u david -p password</pre><p>The above command logs in user david with password password</p><ul><li>docker tag this tags a local image with a tag that the docker registry will use instead of the one used locally. This tag can also be the same as the local tag; there’s no harm in that.</li></ul><pre>docker tag david:database_image $DOCKER_ID_USER/database_image</pre><p>In the above command, david:database_image is the local image name/tag. $DOCKER_ID_USER/database_image is the tag docker registry will use. DOCKER_ID_USER environment variable should be set to your docker username before running the tagging command, or do not set it at all and instead replace it with the docker name directly.</p><blockquote>“We challenge each other, and leave as friends”. Hit me up on <a href="https://twitter.com/davidcarson02">Twitter</a> or <a href="https://www.linkedin.com/in/david-mukiibi-b58124104/">LinkedIn</a> for any collaborations on the topic or edits of this article.</blockquote><blockquote>Au revoir!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eab5cc9bb08d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/introduction-to-docker-commands-eab5cc9bb08d">Introduction to docker commands</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker meets Flask and Postgres]]></title>
            <link>https://medium.com/the-andela-way/docker-meets-flask-and-postgres-5259d4a87c03?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5259d4a87c03</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[the-andela-way]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 14:29:48 GMT</pubDate>
            <atom:updated>2018-04-27T00:02:22.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXBVP1Px4YPDzZG8RTNQ0Q.png" /><figcaption>By <a href="https://twitter.com/davidcarson02">David Mukiibi</a></figcaption></figure><p><em>In this article, we will Dockerize a flask application API with a postgresql database</em></p><blockquote>I’m assuming you are well acquainted with docker and docker compose. Knowledge of the use of docker commands such as docker build, docker run and docker compose commands such as docker-compose up, docker-compose build is sufficient for this article.</blockquote><p>Head over to this <a href="https://github.com/davidmukiibi/docker-flask">repository</a> and clone it. In your terminal navigate into the <strong><em>api image</em></strong> folder. In this folder we have a <strong><em>Dockerfile</em></strong> and a <strong><em>bucketlist</em></strong> folder. The latter holds the <a href="https://github.com/davidmukiibi/CP2A-BucketList-Application-API#the-bucketlist-api">application API</a> code while the Dockerfile contains all the docker image configurations for the API image to be built. We will build the image in the next section.</p><p>In your terminal, while still in the <em>bucketlist</em> folder, run:</p><pre>docker build -t david:api-image-final .</pre><p>The above command does the following:</p><ol><li><strong>docker build: “</strong>tells” the docker to build an image.</li><li><strong>-t: </strong>while building that image,<strong> </strong>tag it with <strong><em>david:api-image-final</em></strong>. “<strong><em>david</em></strong>” is the docker repository name and “<strong><em>api-image-final</em></strong>” is the image tag.</li><li><strong>. : </strong>that right there is a period. The key just above the right option key of the keyboard. This tells the docker daemon to use the current folder aka <strong><em>pwd</em></strong> as the docker context.</li></ol><blockquote>I have commented pretty much everything in all the files in this github code repository to guide you through what every command does.</blockquote><p>When the above docker command has run successfully, a docker image will have been built and stored locally on your computer.</p><p>In your terminal, run the command below to see the docker images locally stored on your computer:</p><pre>docker images<strong><em> </em></strong></pre><p>Then also run the command below,</p><pre>cd database-image/database/</pre><p>In here, there’s a <strong><em>createdb.sql</em></strong> file and a <strong><em>Dockerfile</em></strong>. In the terminal, while still in the <strong><em>database-image/database </em></strong>folder,<strong><em> </em></strong>run the command:</p><pre>docker build -t david:database-final-image .</pre><p>This command is similar to the one we saw above, but this time building an image for the <em>postgresql</em> database server.</p><blockquote>These image builds will take some time to complete depending on your internet connection speed</blockquote><p>With the two images built, let’s create <a href="https://www.docker.com/what-docker">containers</a> from them and connect those containers to each other so that they can “talk/communicate” to each other.</p><p>To pull this off, we shall use another docker feature/tool called docker compose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*CDkilA3HlFh4JUjPPkxh5A.png" /><figcaption>By <a href="https://codefresh.io/">code.io</a></figcaption></figure><blockquote>To install docker compose, go to <a href="https://docs.docker.com/compose/install/">docker-compose</a> and follow the installation guide step by step.</blockquote><p>After a successful docker compose installation, in your terminal, navigate to the root folder.</p><pre>cd docker-flask/</pre><p>This folder contains the <strong><em>docker-compose.yml</em></strong> file. This yaml file is one that docker compose uses to create containers out of the images we built earlier . When the two containers are up and running, they will then be able to “talk” to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*6YvaMJLXECe6FTWckNrSBA.jpeg" /><figcaption>By <a href="https://www.independenceplus.com/5-keys-of-effective-communication-in-the-workplace/">independenceplus.com</a></figcaption></figure><blockquote>It is in the docker compose file that we declaratively set up all the necessary configurations that allow the interaction between these containers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*lu5prM28fxIlbHmjPT8VIg.jpeg" /><figcaption>source: google.com</figcaption></figure><p>Run the command below to use the docker images we built earlier to create containers, start them and then link the two to communicate with each other:</p><pre>docker-compose -f docker-compose.yml up</pre><p>When the above command has successfully executed, we will have two containers up and running with the application API ready to accept <a href="https://www.webopedia.com/TERM/I/ingress_traffic.html">ingress connections</a> and the database server ready to accept connections from the application API container.</p><blockquote>Since this application does not have a front-end, we make use of an application called <a href="https://www.getpostman.com/">postman</a> to query the flask application API.</blockquote><p>To use the application, read through this <a href="https://github.com/davidmukiibi/CP2A-BucketList-Application-API/blob/master/README.md">README.md</a> file for the different API endpoints.</p><pre>In a nutshell, that’s it!</pre><blockquote>“We challenge each other, and leave as friends”. Hit me up on <a href="https://twitter.com/davidcarson02">Twitter</a> or <a href="https://www.linkedin.com/in/david-mukiibi-b58124104/">LinkedIn</a> for any collaborations on the topic or edits of this article.</blockquote><blockquote><strong><em>Au revoir!</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5259d4a87c03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/docker-meets-flask-and-postgres-5259d4a87c03">Docker meets Flask and Postgres</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building custom machine images with Packer]]></title>
            <link>https://medium.com/the-andela-way/building-custom-machine-images-with-packer-a21c6d932bf6?source=rss-771f6debd0a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a21c6d932bf6</guid>
            <category><![CDATA[the-andela-way]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[David Mukiibi]]></dc:creator>
            <pubDate>Fri, 12 Jan 2018 14:42:23 GMT</pubDate>
            <atom:updated>2018-04-27T00:09:20.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*LAv1bqUrOt8G4e4L_6jjZg.jpeg" /></figure><p>In this article we shall build a custom machine image for the google cloud platform. This article is not exhaustive of all platforms packer can build an image for; there’s tonnes of platforms it builds images for as can be seen from its website <a href="http://www.packer.io/">packer.io</a>.</p><p>With that said, let’s delve into building the images for the above mentioned platform.</p><h3>Google Cloud Platform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*MCS66Qsneyv0yS0occC05g.png" /></figure><p>For packer to build a custom image, it needs a “blueprint”so as to know what to include in the image. The “blueprint” is the packer template and is put together by you. It is a *.json file which tells the packer builder what cloud provider to build for, what softwares to install in your custom built image, and much more as we are yet to see.</p><p>Let’s quickly put together the packer template. I’m going to name it “packer.json” but it can be named anything, as long as it is a .json extension.</p><p><strong>Variables</strong></p><pre>“variables”: {</pre><pre>“service_account_json”: “path/to/authentication/file”,</pre><pre>“repo_path” : “path/to/local/or/remote/code/repository”,</pre><pre>“project_id”: “{{env `PROJECT_ID`}}”</pre><pre>}</pre><p>The above code block is used to set any variables that the packer template will need while building our custom image. This is the section we define variables such as, authentication credentials required for packer and google cloud to interact. This is needed when packer is building the image as it interacts with the Google cloud to start an instance, do all the necessary setup as described in the packer template, and then later create the image and store it on Google cloud itself.</p><blockquote>while packer is running in your terminal, head over to the Google Cloud console, under the Google Compute Engine section, you will notice an instance that was not there previously and won’t be after packer is run</blockquote><p>The above key-value pairs in the variables code block, in this case, are the google service account credentials (<strong>service_account_json</strong>) which is a json file, the directory path (<strong>repo_path</strong>) to the local repository of the code you would like to bake into the resulting packer image which is set as an environment variable(this variable is only necessary if the resulting image will be used to setup your application server otherwise it can be skipped), and the google project ID (<strong>project_id</strong>), a unique identifier for the google project we are building the custom image for.</p><blockquote>We could use a file path for all the above variables, but it’s best practice to use environment variables instead.</blockquote><p><strong>Builders</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*nMJn7bdnkO4yFnvg8nUniQ.png" /></figure><pre>“builders”: [<br>    {<br>      “type”: “googlecompute”,<br>      “project_id”: “{{user `project_id`}}”,<br>      “machine_type”: “n1-standard-1”,<br>      “source_image”: “ubuntu-image”,<br>      “region”: “europe-west1”,<br>      “zone”: “europe-west1-b”,<br>      “image_description”: “custom machine image”,<br>      “image_name”: “new_custom_image”,<br>      “disk_size”: 10,<br>      “account_file”: “{{ user `service_account_json`}}”<br>    }<br>]</pre><p>The above code block is an array of one or more components that defines the builders that will be used to create the machine image from this template, and configures each of those builders. For our case here, we are using the googlecompute builder.</p><p>In the builders code block, we have:</p><ul><li>Type (<strong>type</strong>) key/value pair. This is the name of the builder that will be used to create the custom machine image for the current packer build.</li><li>Project ID (<strong>project_id</strong>) key/value pair. This is the google cloud project identifier that packer uses to identify which project it interacts with while building the custom image. Additionally it is used for authentication purposes.</li><li>Machine type (<strong>machine_type</strong>) key/value pair. This is the machine type you intend to use while you build the custom image. The machines are of various types you can choose from. Selection of a machine type depends on your setup needs and requirements. You can find all the machine types for google cloud platform <a href="https://cloud.google.com/compute/docs/machine-types">here</a>.</li><li>Source image (<strong>source_image</strong>) key/value pair. This is the image whose base Operating System you intend to build on top of. For this article’s sake, this can be ubuntu or windows or whatever Operating System you intend to build on top of. Building on top of an already baked image saves us a lot of build time as you don’t have to install the operating system for this custom image we are building. The source image comes with most of the OS specific packages and softwares pre-installed.</li><li>Region and zone (<strong>region</strong>, <strong>zone</strong>) key/value pairs. These are the regions and zones the machine image will run in. Those specified here are google cloud specific, but other cloud providers have equivalents for the same.</li><li>Image description (<strong>image_description</strong>). This is the description of what the image you’re building is all about. This provides information about the image created.</li><li>Image name (<strong>image_name</strong>). This is the name of the custom image you are building. This name should be unique.</li><li>Disk size (<strong>disk_size</strong>). This is the size in Gigabytes of the volume your image should reserve. This can be any number above zero, as long as you can pay for it given the cloud provider billing. Best advice would be you check the provider billing for any resources you intend to use before you use it as that will keep your expenditure in check.</li><li>Service account json file (<strong>account_file</strong>). As mentioned above in the variables block section, this is for authentication purposes with the cloud provider you’re building an image for. In this code block, we reference the account_file key we declared above in the variables code block whose value is the authentication credentials json file. You may be wondering where this file comes from, or how to write it. The answer is, you don’t write it, google generates it for you as you create a service account for your google project.</li></ul><blockquote>There’s more arguments that can be added to the template depending on your configuration. All possible arguments that can be included can be found <a href="https://www.packer.io/docs/builders/googlecompute.html">here</a></blockquote><p><strong>Provisioners</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*LQPPp142kcs4yI62TFhiYw.png" /></figure><pre>“provisioners”: [ {<br>        “type”: “file”,<br>        “source”: “path to file”,<br>        “destination”: “file/path/to/destination folder/in/the/new/machine/image”<br>    },<br>    {<br>        “type”: “shell”,<br>        “script”: “bash_script.sh”<br>    },<br>    {<br>        “type”: “file”,<br>        “source”: “{{ user `service_account_json`}}”,<br>        “destination”: “/path/to/file/account.json”<br>     } ]</pre><p>The provisioners code block contains an array of all provisioners that Packer will use to install and configure software within the custom image that is being created and eventually the same software will be present in any of the instances created from this image. Some of the roles of provisioners include, but not limited to:</p><ul><li>installing packages</li><li>patching the kernel</li><li>creating users</li><li>downloading application code</li></ul><p>Provisioners are <em>optional</em>. Hence, if no provisioners are defined within a packer template, then no software other than the defaults will be installed within the resulting custom machine image.</p><p>There is a number of provisioners out there as you can find <a href="https://www.packer.io/docs/provisioners/index.html">here</a>, but for this article I will only illustrate the ones we shall be using for this demo.</p><p>The first provisioner is of type<em> </em><em>file. </em>The role of this is to upload files to the machine image that is being built by packer for later use by any service that may need them and will be available in all instances created from this image. These files may contain authentication tokens, application code, etc.</p><p>If need be, you can still upload an entire file folder using this same provisioner. You could look into how to do that <a href="https://www.packer.io/docs/provisioners/file.html">here</a>.</p><p>As we define the <em>file</em> provisioner, we also have to define the source and destination of the file we intend to upload using the <em>source</em> and <em>destination</em> key/value pairs respectively. The source is where the file or folder is on the local system you are running packer on, and the destination is where you want the file or folder to reside, in the new machine image you are building, in each and every instance created from this image.</p><p>The other provisioner used, is the <em>shell </em>provisioner. The role of this provisioner is to execute shell commands just like you would normally do within the computer terminal. These shell commands install softwares into the machine image we are building with packer. You can specify as many shell provisioners as you want for all the commands you want to run while building the image. But it is best practice that you combine most of the similar commands (commands that are dependant on each other or related in functionality) into a bash script and execute the script instead with the shell provisioner. Using bash scripts this way makes debugging your packer template file a lot more easier.</p><blockquote>More provisioners and how they can be used can be found <a href="https://www.packer.io/docs/provisioners/file.html">here</a>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipMvkcZYngTcmlXi1hlmyQ.png" /></figure><p>With that said, let’s assemble the various code blocks together to make a meaningful packer template and build the custom image.</p><p><strong>Packer template</strong></p><pre>{<br>    “variables”: {<br>         “service_account_json”: “../shared/account.json”,<br>         “repo_path” : “{{env `REPO_PATH`}}”,<br>         “project_id”: “{{env `PROJECT_ID`}}”<br>     },</pre><pre>“builders”: [ <br>        {<br>           “type”: “googlecompute”,<br>           “project_id”: “{{user `project_id`}}”,<br>           “machine_type”: “n1-standard-1”,<br>           “source_image”: “ubuntu-image”,<br>           “region”: “europe-west1”,<br>           “zone”: “europe-west1-b”,<br>           “image_description”: “custom machine image”,<br>           “image_name”: “new_custom_image”,<br>           “disk_size”: 10,<br>           “account_file”: “{{ user `service_account_json`}}”<br>        }<br>     ],</pre><pre>“provisioners”: [<br>         {<br>             “type”: “file”,<br>             “source”: “path to file”,<br>             “destination”: “file/path/to/destination folder/in/the/new/machine/image”<br>         },<br>         {<br>             “type”: “shell”,<br>             “script”: “bash_script.sh”<br>         },<br>         {<br>             “type”: “file”,<br>             “source”: “{{ user `service_account_json`}}”,<br>             “destination”: “/path/to/file/account.json”<br>          }<br>      ]<br>}</pre><p>Before we run the packer build command to finally build the custom image, make sure that packer is installed and the environment variables are set. The environment variables that we declared in the variables block are the ones whose values we have to set. If we do not set them, packer will “complain”. These are set the same way we set normal environment variables via the computer terminal.</p><p>With the environment variables set, we can now run packer by running this command in the terminal packer build packer.json.</p><blockquote>Remember we named our packer template file <em>packer.json</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*T7VXxsWs9pQ2Ih31trDIYQ.jpeg" /></figure><p>When packer is done building the image, head over to the GCP console, in the images section, and viola, the newly created image will be there. See the image below for reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CnqrC7-Gu5rFhLqaRVxBxw.png" /></figure><p>And with that, an image has successfully been created for Google Cloud Platform. Instances can be created from this image just like any other image google provides by default.</p><p>That’s it for this article, for the next one in this series, I will take you through building a machine image for another provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*l0KTHKiPwh2dz5AzLd7uWQ.jpeg" /></figure><p>For any additions and/or questions, feel free to post them here or reach out directly on <a href="https://twitter.com/davidcarson02">twitter</a>. Adios!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a21c6d932bf6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/building-custom-machine-images-with-packer-a21c6d932bf6">Building custom machine images with Packer</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>