<?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 Jaseem Jas on Medium]]></title>
        <description><![CDATA[Stories by Jaseem Jas on Medium]]></description>
        <link>https://medium.com/@jasmedia?source=rss-aa774d1ebc8b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*bapR6JmP1-9K563znR3Y1Q.jpeg</url>
            <title>Stories by Jaseem Jas on Medium</title>
            <link>https://medium.com/@jasmedia?source=rss-aa774d1ebc8b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:03:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jasmedia/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[Why I Built cc-pr-reviewer: Taming the PR Review Firehose]]></title>
            <link>https://jasmedia.medium.com/why-i-built-cc-pr-reviewer-taming-the-pr-review-firehose-ba59393909af?source=rss-aa774d1ebc8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba59393909af</guid>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Jaseem Jas]]></dc:creator>
            <pubDate>Sun, 26 Apr 2026 02:38:41 GMT</pubDate>
            <atom:updated>2026-04-26T02:42:37.366Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The pain point</strong></p><p>As a staff engineer, a big chunk of my week goes into reviewing pull requests — not just from my own team, but across the entire organization. Multiple repos, multiple languages, multiple contexts. On a typical day my review queue spans half a dozen services I don’t actively work on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*0U_9dlH6GL6HNhWU5bommw.png" /></figure><p>The mechanics of doing a <em>good</em> review are where it falls apart:</p><ul><li><strong>GitHub’s web UI is fine for tiny diffs</strong>, but the moment a PR touches more than a handful of files, I lose the thread. I can’t jump to definitions, I can’t see the call sites of a changed function, I can’t run the tests.</li><li><strong>Reviewing locally means context-switching hell</strong>. Clone the repo (if I haven’t already), fetch, check out the PR branch, open the IDE, wait for it to index, <em>then</em> start reading. Multiply that by 5–10 PRs a day across 5+ repos and most of my “review time” is actually setup time.</li><li><strong>Switching IDE windows kills flow</strong>. Every PR is a new project, a new mental model to load.</li></ul><p>The result: reviews get rushed, surface-level, or deferred. None of which is good for the org.</p><h4>What I wanted instead</h4><p>One place that:</p><blockquote>1. Shows me every PR waiting on my review across every repo, in one list.<br>2. Lets me pick one and <em>immediately</em> be in a fully-set-up local working tree for that PR — no manual cloning, no `gh pr checkout`, no IDE bootstrap.<br>3. Hands the review off to something smart enough to do the first pass for me, so I can focus my human attention on the parts that actually need judgment.</blockquote><h4>Enter cc-pr-reviewer</h4><p>`cc-pr-reviewer` is a small terminal UI (built with [Textual](<a href="https://textual.textualize.io/">https://textual.textualize.io/</a>)) that does exactly that.</p><p><strong>The list</strong>. It shells out to `gh search prs — review-requested=<a href="http://twitter.com/me">@me</a> — state=open` and renders the results in a scrollable table — repo, PR number, title, author, age, draft status, plus a “Reviews” column that tracks how many times I’ve reviewed each PR and whether it’s gone stale since.</p><p><strong>The handoff</strong>. Pick a PR, hit Enter, and the TUI:</p><blockquote>1. Clones the repo into `~/gh-pr-workspace/&lt;owner&gt;/&lt;repo&gt;` (or `git fetch`es if it’s already there — clones are reused across PRs in the same repo).<br>2. Runs `gh pr checkout &lt;N&gt; — force` to land on the PR branch.<br>3. Launches `claude` (Claude Code) inside that working tree with a prompt that invokes the [PR Review Toolkit](<a href="https://claude.com/plugins/pr-review-toolkit">https://claude.com/plugins/pr-review-toolkit</a>) plugin.</blockquote><p>Because Claude Code starts inside a real, fully-checked-out repo, it has the same context I would have if I’d done all the setup manually — file-level navigation, the ability to grep, run tests, read related files.</p><p><strong>The review</strong>. The PR Review Toolkit fans the work out across six specialized sub-agents:</p><ul><li>Code Reviewer — style, correctness, project conventions</li><li>PR Test Analyzer — test coverage gaps</li><li>Silent Failure Hunter — swallowed errors, bad fallbacks</li><li>Type Design Analyzer — encapsulation, invariants</li><li>Comment Analyzer — comment rot, doc accuracy</li><li>Code Simplifier — dead code, redundant abstractions</li></ul><p>I can optionally toggle a flag (`p`) that asks Claude to publish the findings as inline PR review comments via `gh api`, grouped under one review.</p><p>When Claude exits, the TUI auto-refreshes the list. On to the next one.</p><h4>Why a TUI and not a web app?</h4><p>Two reasons:</p><ul><li><strong>It already has the terminal I’m in</strong>. No new tab, no auth flow, no browser context.</li><li><strong>`App.suspend()` + `subprocess.call`</strong> is the magic that makes the Claude handoff work. The TUI releases the TTY, Claude takes over interactively in the same terminal, and the TUI resumes when Claude exits. A web app couldn’t do that cleanly.</li></ul><h4>What it actually changed for me</h4><ul><li>Review queue at the start of the day → 8 PRs across 5 repos. Old workflow: ~2 hours just to set up + skim. New workflow: ~30 minutes to get a real first pass on all of them, with Claude flagging the things worth my human attention.</li><li>I review more carefully because the setup cost is gone.</li><li>I review <em>more PRs</em> because the cost per PR dropped.</li></ul><h4>Try it</h4><p>It’s MIT-licensed, on PyPI, single-file Python (only runtime dep is Textual):</p><p>```sh<br>uv tool install cc-pr-reviewer<br>cc-pr-reviewer<br>```</p><p>Prereqs: `gh` (logged in), `claude` CLI, and the PR Review Toolkit plugin installed in Claude Code.</p><p>Repo: <a href="https://github.com/jasmedia/cc-reviewer">https://github.com/jasmedia/cc-reviewer</a></p><p>If you’re a staff/principal/lead and PR review across an org is eating your week, I’d love to hear if this helps — or what’s missing.</p><p>#ClaudeCode #DeveloperTools #CodeReview #OpenSource</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba59393909af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Slack alerts with Airflow 2]]></title>
            <link>https://jasmedia.medium.com/integrating-slack-alerts-with-airflow-2-fc9dc941c224?source=rss-aa774d1ebc8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc9dc941c224</guid>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jaseem Jas]]></dc:creator>
            <pubDate>Sat, 27 Mar 2021 13:08:42 GMT</pubDate>
            <atom:updated>2021-03-27T13:08:42.117Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_c4pjPCexgAaZB7ytelbIQ.png" /></figure><p>You need alerting when your DAG fails so that you can take actions at the earliest. And it is just easier to get alerts where your entire team has an eye on SLACK. One of the biggest advantages to using Airflow is the versatility around its<strong> hooks</strong> and <strong>operators</strong>. Hooks are interfaces to external platforms, databases and also serve as the basic building blocks of Operators.</p><p>I read some documents to implement slack alerts for notifying DAG status. but most of the articles are written for Airflow version 1. So I thought it is useful to write a doc for Slack alerts on Airflow 2. There is some change in slack implementations in Airflow 2.</p><p>Slack recommends Web Hooks to send data to it. So let’s go through the steps to do it.</p><h3>Step #1:</h3><p><a href="https://api.slack.com/docs/slack-button#register_your_slack_app">Create a Slack</a> app if you don’t have it already.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*DpI1j8Tx4FSnS_TAKgAhBQ.png" /></figure><p>Enable Incoming Webhooks on the next page and Create an Incoming Webhook by clicking on Add New Webhook to Workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*DQtxpKy8E8WcLe28N2UWFg.png" /></figure><p>So go ahead and select a channel that the app will post to (I already created a channel named as #slack-alerts), and then click to Authorize your app. You’ll be sent back to your app settings, and you should now see a new entry under the Webhook URLs for Your Workspace section, with a Webhook URL that’ll look something like this: <a href="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX">hooks.slack.com/services/T00000000/B0000000..</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*9kdKgs4qdzy1qNQEGa5U1g.png" /></figure><h3>Step #2:</h3><p>Create an Airflow connection for Slack with HTTP connection and the part after <a href="https://hooks.slack.com/services">hooks.slack.com/services</a> should go under password and channel name go under login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*EQdE7sS4gnJ_bLpDTPOd8g.png" /></figure><h3>Step #3:</h3><p>Create Python functions to trigger on DAG success and failure and import slack config from previously created slack connection.</p><pre>from airflow.providers.slack.hooks.slack import BaseHook<br>from airflow.providers.slack.hooks.slack_webhook import SlackWebhookHook</pre><pre>SLACK_CONN_ID = &#39;slack&#39;</pre><pre>def task_success_slack_alert(context):<br>    &quot;&quot;&quot;<br>    Callback task that can be used in DAG to alert of successful task completion<br>    Args:<br>        context (dict): Context variable passed in from Airflow<br>    Returns:<br>        None: Calls the SlackWebhookHook execute method internally<br>    &quot;&quot;&quot;<br>    slack_webhook_token = BaseHook.get_connection(SLACK_CONN_ID).password<br>    channel =  BaseHook.get_connection(SLACK_CONN_ID).login;<br>    slack_msg = &quot;&quot;&quot;<br>            :large_blue_circle: Task Succeeded! <br>            *Task*: {task}  <br>            *Dag*: {dag} <br>            *Execution Time*: {exec_date}  <br>            *Log Url*: {log_url} <br>            &quot;&quot;&quot;.format(<br>        task=context.get(&quot;task_instance&quot;).task_id,<br>        dag=context.get(&quot;task_instance&quot;).dag_id,<br>        ti=context.get(&quot;task_instance&quot;),<br>        exec_date=context.get(&quot;execution_date&quot;),<br>        log_url=context.get(&quot;task_instance&quot;).log_url.replace(&#39;<a href="http://localhost:8080&#39;">http://localhost:8080&#39;</a>, &#39;<a href="https://airflow.perfotricks.com&/#39;">https://airflow.yourdomain.com&#39;</a>),<br>    )</pre><pre>slack_hook = SlackWebhookHook(webhook_token=slack_webhook_token, message=slack_msg, channel=channel, username=&quot;airflow&quot;)</pre><pre>return  slack_hook.execute()</pre><pre>def task_fail_slack_alert(context):<br>    &quot;&quot;&quot;<br>    Callback task that can be used in DAG to alert of failure task completion<br>    Args:<br>        context (dict): Context variable passed in from Airflow<br>    Returns:<br>        None: Calls the SlackWebhookHook execute method internally<br>    &quot;&quot;&quot;<br>    slack_webhook_token = BaseHook.get_connection(SLACK_CONN_ID).password<br>    channel =  BaseHook.get_connection(SLACK_CONN_ID).login;</pre><pre>slack_msg = &quot;&quot;&quot;<br>            :red_circle: Task Failed. <br>            *Task*: {task}  <br>            *Dag*: {dag} <br>            *Execution Time*: {exec_date}  <br>            *Log Url*: {log_url} <br>            &quot;&quot;&quot;.format(<br>        task=context.get(&quot;task_instance&quot;).task_id,<br>        dag=context.get(&quot;task_instance&quot;).dag_id,<br>        ti=context.get(&quot;task_instance&quot;),<br>        exec_date=context.get(&quot;execution_date&quot;),<br>        log_url=context.get(&quot;task_instance&quot;).log_url.replace(&#39;<a href="http://localhost:8080&#39;">http://localhost:8080&#39;</a>, &#39;<a href="https://airflow.perfotricks.com&/#39;">https://</a><a href="https://airflow.perfotricks.com&/#39;">airflow.yourdomain</a><a href="https://airflow.perfotricks.com&/#39;">.com&#39;</a>),<br>    )</pre><pre>slack_hook = SlackWebhookHook(webhook_token=slack_webhook_token, message=slack_msg, channel=channel, username=&quot;airflow&quot;)</pre><pre>return  slack_hook.execute()</pre><p>log_url replaced with host name to access the log directly from browser.</p><h3>Final Step:</h3><p>You can add on_failure_callback to default_args when defining DAG as below so that you get alert if any task in the DAG fails:</p><pre>default_args = {</pre><pre>&#39;owner&#39;: &#39;airflow&#39;,</pre><pre>&#39;start_date&#39;: airflow.utils.dates.days_ago(2),</pre><pre>&#39;retries&#39;: 0,</pre><pre>&#39;on_failure_callback&#39;: task_fail_slack_alert</pre><pre>}</pre><pre>dag = DAG(</pre><pre>dag_id=DAG_NAME,</pre><pre>default_args=default_args,</pre><pre>schedule_interval=schedule_interval,</pre><pre>)</pre><p>You can add on_success_callback=task_success_slack_alert anywhere in operators.</p><p>I hope you enjoyed it.</p><p>Cheers,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc9dc941c224" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate application build and deployment on Kubernetes (GKE) with Gitlab CI/CD]]></title>
            <link>https://jasmedia.medium.com/automate-application-build-and-deployment-on-kubernetes-gke-with-gitlab-ci-cd-af071365b92?source=rss-aa774d1ebc8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/af071365b92</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[gke]]></category>
            <dc:creator><![CDATA[Jaseem Jas]]></dc:creator>
            <pubDate>Sun, 07 Jun 2020 16:39:41 GMT</pubDate>
            <atom:updated>2020-06-07T16:39:41.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y_AAp5QJ_22k4h6GRlULEA.png" /></figure><h3>Connecting Gitlab to Kubernetes.</h3><p>Gitlab has a native integration with Kubernetes and we can configure any group or project to use it.</p><p>To begin, first select the Kubernetes tab on the Operations menu under Group if more than one projects, then click on Add Kubernetes Cluster.</p><p>On the next screen click on the Add existing Cluster tab. Here you will be prompted to input a few details to allow Gitlab to connect to your k8s cluster. Gitlab has excellent documentation on <a href="https://gitlab.com/help/user/project/clusters/index#adding-an-existing-kubernetes-cluster">how to add a cluster</a>, which I recommend reading to get a thorough understanding of the integration. So let’s start step by step.</p><h3>Creating Accounts</h3><p>First up, we will need to create a new system-level account in Kubernetes to connect with Gitlab. This account is called a ServiceAccount. In order to do this we can use the kubectl command line utility and define the account using YAML syntax (which is used throughout k8s) as seen below:</p><pre>$ kubectl create -f - &lt;&lt;EOF</pre><pre>apiVersion: v1</pre><pre>kind: ServiceAccount</pre><pre>metadata:</pre><pre>  name: gitlab</pre><pre>  namespace: default</pre><pre>EOF</pre><p>This YAML definition will create a ServiceAccount named “gitlab” in the “default” namespace.</p><p>Next step, set up Gitlab account cluster administrator privileges so it can freely create and destroy services on behalf you. Once again, we will use kubectl and a YAML definition.</p><pre>$ kubectl create -f - &lt;&lt;EOF</pre><pre>kind: ClusterRoleBinding</pre><pre>apiVersion: rbac.authorization.k8s.io/v1</pre><pre>metadata:</pre><pre>  name: gitlab-cluster-admin</pre><pre>subjects:</pre><pre>- kind: ServiceAccount</pre><pre>  name: gitlab</pre><pre>  namespace: default</pre><pre>roleRef:</pre><pre>  kind: ClusterRole</pre><pre>  name: cluster-admin</pre><pre>  apiGroup: rbac.authorization.k8s.io</pre><pre>EOF</pre><h3>Connect the Cluster</h3><p>Now, lets take a look at all the information that Gitlab requires to connect to the Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*6hpa-CScaGQ4JXZPSx-rrQ.png" /></figure><p>The first field is Kubernetes cluster name. This can be anything meaningful to help you identify the k8s cluster.</p><p>The next field API URL can be obtained by running the following command:</p><pre>kubectl cluster-info | grep &#39;Kubernetes master&#39; | awk &#39;/http/ {print $NF}&#39;</pre><pre>https://34.239.111.233</pre><p>Grab the URL returned by the command and paste it into the API URL field.</p><p>The CA Certificate and the token can be obtained by extracting data from the “secret” created when Gitlab account was made. Kubernetes has the concept of a secret resource which is designed to store sensitive information. In addition to the setup process, you can create your own secrets to store your applications sensitive information such as database credentials, API keys, etc.</p><p>To list all secrets in the project run:</p><pre>kubectl get secrets</pre><pre>NAME                  TYPE                                  DATA   AGE</pre><pre>gitlab-token-6kl45    kubernetes.io/service-account-token   3      18h</pre><pre>regcred               kubernetes.io/dockerconfigjson         1      6h46m</pre><p>Find the secret that starts with gitlab-token-* and use it in the next command (eg: gitlab-token-6kl45):</p><pre>kubectl get secret &lt;SECRET_NAME&gt; -o jsonpath=&quot;{[&#39;data&#39;][&#39;ca\.crt&#39;]}&quot; | base64 --decode</pre><pre>-----BEGIN CERTIFICATE-----</pre><pre>...</pre><pre>-----END CERTIFICATE-----</pre><p>Copy and paste everything returned from the command, starting with the — — -BEGIN CERTIFICATE — — — and ending with — — -END CERTIFICATE — — -, into the CA Certificate field</p><p>The Token can be obtained in a similar fashion by executing the following:</p><pre>kubectl get secret &lt;SECRET_NAME&gt; -o jsonpath=&quot;{[&#39;data&#39;][&#39;token&#39;]}&quot; | base64 --decode</pre><p>copy paste the returned value into the Token field within Gitlab.</p><p>As for Project Namespace, I used ‘default’. Ensure to check the RBAC enabled cluster checkbox and unchecked GitLab-managed cluster. When you are ready, go ahead and click the Add Kubernetes Cluster button.</p><h3>Setting up CI/CD</h3><p>Setting up a Continuous Integration and Continuous Deployment pipeline is easy to setup with Gitlab. It’s baked into the Gitlab offering and easily configurable by just adding a file with ‘.gitlab-ci’ extension to the root of your project folder. A CI/CD pipeline is triggered when you push code to the Gitlab repository. The pipeline must run on a server, which is called a “Runner”. Runners can be virtual private servers, public servers, or anywhere you can install the Gitlab runner client. In our use case, we are going to install a runner on the k8s cluster so that jobs are executed in kubernets pods. This approach also makes it scaleable so we can run multiple jobs in parallel.</p><p>To install the Gitlab runner client on the k8s cluster, we will first need to install another tool named Helm, it is a package manager for Kubernetes and simplifies installation of software. I like to think of Helm being similar to Brew for Mac, they both have a repo of software that can be installed onto a system.</p><h3>Installing Helm</h3><p>Installing Helm through Gitlab, just requires you to click the Install button. Assuming everything was configured properly, it will take just a few seconds to install.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*4FZip2xdilmfE9xm7Pzcdg.png" /></figure><p>After it has completed, let’s take a peek at the cluster to see what Gitlab has installed. Using the <em>kubectl get ns </em>command we can see that Gitlab has created its own namespace, named gitlab-managed-apps.</p><blockquote>To see pods in the <em>Gitlab namespace run</em> kubectl get pods -n gitlab-managed-apps. Here we see that the “Helm tiller” has been created successfully and is running.</blockquote><h3>Installing the Gitlab Runner</h3><p>As stated earlier, the Gitlab runner allows our CI/CD jobs to be run in the k8s cluster. Installing the runner with Gitlab is simple, just click the Install button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*M9vNSzjS5mkbsGQGu0s99A.png" /></figure><p>After its completed, let’s take a look at the pods again and you should see a new pod for the Gitlab runner.</p><p>You can verify that the runner is connected to your project by viewing the Settings ➜ CI/CD ➜ Runners section within Gitlab.</p><blockquote>NOTE: don’t forget to disable shared runner before setting up pipeline. otherwise pipeline jobs will run on shared runners. Gitlab limits shared runner usage 2000 minutes per month. but private runner access is unlimited.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*gD7ER06dbjHKp60YKwg54Q.png" /></figure><h3>Run a Pipeline</h3><p>Great, so now we have a fully functional Gitlab group, connected to Kubernetes with runners ready to execute our CI/CD pipelines. Let’s setup an example Golang project to see how these pipelines can be triggered. For this project we will run a simple HTTP server that returns the “Hello World”. you can try this step with your project itself.</p><p>First, write the go code:</p><pre># main.go</pre><pre>package mainimport (</pre><pre>&quot;fmt&quot;</pre><pre>&quot;log&quot;</pre><pre>&quot;net/http&quot;</pre><pre>)</pre><pre>func main() {</pre><pre>http.HandleFunc(</pre><pre>&quot;/hello&quot;,</pre><pre>func(w http.ResponseWriter, r *http.Request) {</pre><pre>fmt.Fprintf(w, &quot;Hello World!&quot;)</pre><pre>},</pre><pre>)log.Fatal(http.ListenAndServe(&quot;:8080&quot;, nil))</pre><pre>}</pre><p>And then the Dockerfile to run it:</p><pre># Dockerfile</pre><pre>FROM golang:1.11</pre><pre>RUN mkdir -p /usr/src/go/app</pre><pre>WORKDIR /usr/src/go/app</pre><pre>COPY . /usr/src/go/app</pre><pre>RUN go get -d -v ./...</pre><pre>RUN go install -v ./...CMD [&quot;app&quot;]</pre><p>Next , create a ‘.gitlab-ci.yml’ file to define our CI/CD pipeline. The file will be evaluated on every code push and if the branch, or tags, match any jobs, they will be executed automatically by one of the Gitlab runners that we configured earlier.</p><p>The first step in our pipeline will be to build a docker image of our application whenever we push to the master branch and tagged it. We can do it with the following configuration:</p><pre># Gitlab CI Definition (.gitlab-ci.yml)</pre><pre>stages:</pre><pre>  - build</pre><pre>  - deploy</pre><pre>services:</pre><pre>  - docker:19.03.1-dind</pre><pre>variables:</pre><pre>  DOCKER_TLS_CERTDIR: &quot;&quot;</pre><pre>  DOCKER_HOST: tcp://localhost:2375</pre><pre>build:</pre><pre>  image: docker:19.03.1</pre><pre>stage: build</pre><pre>  only:</pre><pre>   - tags</pre><pre>script:</pre><pre>  - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}</pre><pre>  - docker build -t ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_NAME} .</pre><pre>  - docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_NAME}</pre><p>The services block includes the official Docker-in-Docker (or dind) image, that will be linked in all jobs to build application docker container inside Gitlab CI docker containers.</p><p>Next we have the build job. The image indicates we are using the latest Docker image from Docker Hub. The stage tells Gitlab what stage this job is in. One neat thing to keep in mind is that jobs in the same stage will run in parallel. The only: tag indicates that we will only run this job on commits to the master branch and tagged. Finally the script: is the meat of the job, which will run the docker build command to create our image, then docker login to the Gitlab registry, and then docker push that image to our registry Default Gitlab registry. You can try this with any docker registries. It will show the tagged docker image under <em>packages &gt; container registry</em>.</p><blockquote><em>At this point we can commit and push the code and you should see a brand new image in the Gitlab registry.</em></blockquote><p>After an image is built and stored in registry, the next step is to deploy it. We need to create a secret (named it ‘regcred’) to connect our private container registery to pull image.</p><pre>kubectl create secret docker-registry &lt;SECRET NAME&gt; --docker-server=registry.gitlab.com --docker-username=&lt;USER NAME&gt; --docker-password=&lt;PASSWORD&gt; --docker-email=&lt;USER EMAIL&gt;</pre><p>Then we need to define the deployment configuration that tells kubernetes how we want to run the application. The following yaml file is exactly that and supply imagePullSecret name as we created in previous step.</p><pre># Deployment Configuration (deployment-template.yaml)</pre><pre>apiVersion: apps/v1</pre><pre>kind: Deployment</pre><pre>metadata:</pre><pre>  name: frontend</pre><pre>  namespace: default</pre><pre>labels:</pre><pre>  app: frontend</pre><pre>spec:</pre><pre>  replicas: 1</pre><pre>  selector:</pre><pre>    matchLabels:</pre><pre>      app: frontend</pre><pre>  template:</pre><pre>    metadata:</pre><pre>      labels:</pre><pre>        app: frontend</pre><pre>    spec:</pre><pre>      containers:</pre><pre>        - name: frontend</pre><pre>        image: registry.gitlab.com/groupname/project_name:$CI_COMMIT_TAG</pre><pre>        imagePullPolicy: Always</pre><pre>        ports:</pre><pre>          - containerPort: 3000</pre><pre>      imagePullSecrets:</pre><pre>        - name: regcred</pre><p>To trigger a deployment, I have configured the .gitlab-ci.yml file to do so when the code repo is tagged. Here is the job definition to do so:</p><pre># Gitlab CD Definition (.gitlab-ci.yml)</pre><pre>deploy:</pre><pre>  image: thisiskj/kubectl-envsubst</pre><pre>  stage: deploy</pre><pre>  environment:</pre><pre>    name: default</pre><pre>  only:</pre><pre>    - tags</pre><pre>  script:</pre><pre>    - envsubst \$CI_COMMIT_TAG &lt; deployment-template.yaml &gt; deployment.yaml</pre><pre>    - kubectl apply -f deployment.yaml</pre><p>This job will run the <em>envsubst</em> command to replace the $CI_COMMIT_TAG variable inside of the deployment-template.yaml, with the name of the git tag that triggered the build. The environment variable $CI_COMMIT_TAG is set by the Gitlab runner and we tell <em>envsubst</em> to essentially search and replace that variable within the file. I used <em>envsubst</em> from docker image ‘thisiskj/kubectl-envsubst’ (you can build and deploy docker image with <em>envsubst </em>behalf of your docker regisitry).</p><h3>Viewing the Application</h3><p>At this point everything is wired up and our deployment will run on every new tag.</p><pre>kubectl get deployments</pre><pre>NAME        READY   UP-TO-DATE   AVAILABLE   AGE</pre><pre>frontend    1/1     1            1           27h</pre><p>I hope you enjoyed it.</p><p>Cheers,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af071365b92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elasticsearch Backup using SLM and Restore on Amazon S3]]></title>
            <link>https://itnext.io/elasticsearch-backup-using-slm-and-restore-on-amazon-s3-c42bd0c0fd26?source=rss-aa774d1ebc8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c42bd0c0fd26</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <dc:creator><![CDATA[Jaseem Jas]]></dc:creator>
            <pubDate>Tue, 24 Dec 2019 09:07:47 GMT</pubDate>
            <atom:updated>2020-06-09T14:39:31.911Z</atom:updated>
            <content:encoded><![CDATA[<h3>Elasticsearch Backup using SLM and Restore with Amazon S3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWRC_yNe5XvZ3WhUw8nqBw.png" /></figure><p>It is not a good idea to store backups in your on production servers. better to use Cloud data storage service like AWS S3 or some other services. You can also use Minio like open source self hosted Object Storage with ZFS. I am going to demonstrate how to backup Elasticsearch data into S3 and create the retention policy on it.As I mentioned before, I used two script to manage the backup lifecycle in s3, one for creating snapshot and another one for delete the old snapshot. But the Snapshot Lifecycle Management (SLM) is one of great feature on Elasticsearch 7.5 version on wards. In this post demonstrating how to configure S3 and manage the lifecycle of backup. Just follow the previous <a href="https://medium.com/@jasmedia/elasticsearch-backups-lifecycle-management-with-slm-8268366553a8">documentation</a> if you want to install Elasticsearch and configure it.</p><h3>Create S3 Bucket</h3><p>I hope you have already created an AWS account and IAM user credentials for S3. So Let’s start with creating a S3 bucket to store Elasticsearch snapshots. Go to the AWS S3 services page and click on ‘create bucket’ button and set a name for the bucket and follow the steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1yqwE0Kw9BuhbnhrymhQA.png" /></figure><h3>Configure S3 Access in Elasticsearch keystore</h3><p>Next, set IAM User credentials to Elasticsearch keystore for accessing S3 bucket what we already created. Use following commands to set these credentials.</p><pre>bin/elasticsearch-keystore add s3.client.default.access_key<br>bin/elasticsearch-keystore add s3.client.default.secret_key</pre><h3>Install S3 Plugin</h3><p>You need to install the Elasticsearch s3-repository plugin, just run the command:</p><pre>bin/elasticsearch-plugin install repository-s3</pre><p>you can check if the repository-s3 is installed.</p><pre>curl -X GET &quot;localhost:9200/_cat/plugins?v&amp;s=component&amp;h=component,version,description&amp;pretty&quot;</pre><p>response should be like:</p><pre>component version description<br>repository-s3 7.5.0 The S3 repository plugin adds S3 repositories</pre><h3>Configure Backup Repository</h3><p>Setup the backup repository with s3 bucket.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2c5087f68503511d64b7a26c7fdbcdd/href">https://medium.com/media/b2c5087f68503511d64b7a26c7fdbcdd/href</a></iframe><p>response should be “acknowledged” : true if the repository creation succeeded.</p><h3>Configure SLM policy</h3><p>After that set the s3 snapshot lifecycle management policy on it. set backup time, snapshot name, repository, indices and retention policy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3b7c40ad042eed6152b3b7c2bf51ac7/href">https://medium.com/media/e3b7c40ad042eed6152b3b7c2bf51ac7/href</a></iframe><p>Finally just run the command for backing up into s3 immediately.</p><pre>curl -X POST &quot;localhost:9200/_slm/policy/my-s3-snapshots/_execute?pretty&quot;</pre><p>you will get a response with snapshot name if it is succeeded. and your S3 bucket looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMALMY6Z2khJ-qkHbPDhCw.png" /></figure><p>Now we can check the policy.</p><pre>curl -X GET &quot;localhost:9200/_slm/policy/my-s3-snapshots?human&amp;pretty&quot;</pre><p>The response should be :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f7f25b48044ecbd7190615ba55e700c/href">https://medium.com/media/9f7f25b48044ecbd7190615ba55e700c/href</a></iframe><p>This response contains number of snapshots taken, next snapshot time, and lot of other details on SLM policy.</p><h3>Restore from Snapshot</h3><p>You will get full list of snapshot and note down the snapshot name which one you want to restore.</p><pre>curl -X GET “localhost:9200/_snapshot/my_s3_repository/_all?pretty”</pre><p>Remove one index from Elasticsearch cluster to test the restore processes.</p><p>First, list available indices in your cluster.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fa3d0d461bda30f9845bd3d7d297212/href">https://medium.com/media/8fa3d0d461bda30f9845bd3d7d297212/href</a></iframe><p>Delete index ‘hastags’ for demonstrating restoration of s3 backup.</p><pre>curl -X DELETE &quot;localhost:9200/hashtags?pretty&quot;</pre><p>Just run the above indices list command to verify the deletion. Now time to run restore command :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d198f295780c618e9186f5a79c65e76/href">https://medium.com/media/1d198f295780c618e9186f5a79c65e76/href</a></iframe><p>No need to specify the index name if you are restoring the data into a new cluster. Otherwise you will get an error message ‘index with same name already exists’ if some of the indices already available in Elasticsearch cluster.</p><p>Now again verify index restore with index list command. you can see the difference in uuid before and after index restored.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a5a09aa3b790d2bc25c0086bcfcdd85/href">https://medium.com/media/8a5a09aa3b790d2bc25c0086bcfcdd85/href</a></iframe><p>This is the coolest method to manage the backup lifecycle on Elasticsearch. you can also use Kibana to configure life cycle policy. You can directly restore the snapshot to a new Elasticsearch cluster using above repository configuration.</p><p>Cheers,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c42bd0c0fd26" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/elasticsearch-backup-using-slm-and-restore-on-amazon-s3-c42bd0c0fd26">Elasticsearch Backup using SLM and Restore on Amazon S3</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elasticsearch backups lifecycle management with SLM]]></title>
            <link>https://jasmedia.medium.com/elasticsearch-backups-lifecycle-management-with-slm-8268366553a8?source=rss-aa774d1ebc8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8268366553a8</guid>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[retention]]></category>
            <category><![CDATA[snapshot]]></category>
            <category><![CDATA[backup]]></category>
            <dc:creator><![CDATA[Jaseem Jas]]></dc:creator>
            <pubDate>Tue, 17 Dec 2019 14:29:37 GMT</pubDate>
            <atom:updated>2019-12-17T14:29:37.418Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*QhFH63df10Wq-ocKKoicEA.png" /></figure><p>Elasticsearch backup and retention was very hard to do before ES Version 7.5. Because we need to write a script to delete the old backups from the storage and it is very difficult to find out which are old backups if you are not provided the date of snapshot in the name of snap. Now ES Version 7.5 on wards supporting the snapshots life cycle management and retention.</p><p>Now I am going to explain how to create the elsaticsearch backup using snapshots and create the snapshot life cycle management and retention.</p><p>First step is just download the latest version of the ES. The MacOS archive for Elasticsearch v7.5.0 can be downloaded and installed as follows. :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17b515c568d57332997f52e4e2699afc/href">https://medium.com/media/17b515c568d57332997f52e4e2699afc/href</a></iframe><p>Just follow the link if you want install Elasticsearch in other formats : <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html</a>. Recommended to use the package manager to install elasticsearch in production.</p><p>Elasticsearch can be started from the command line as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42061cc7acb05d09d9d75dac3423aa52/href">https://medium.com/media/42061cc7acb05d09d9d75dac3423aa52/href</a></iframe><p>By default, Elasticsearch runs in the foreground, prints its logs to the standard output (stdout), and can be stopped by pressing Ctrl-C.</p><p>You can test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e648072a4aff578b444d9d51f9491bf4/href">https://medium.com/media/e648072a4aff578b444d9d51f9491bf4/href</a></iframe><p>Which should give a response like this :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeaa65e7b9bf5380269e238faaff6c93/href">https://medium.com/media/eeaa65e7b9bf5380269e238faaff6c93/href</a></iframe><p>You can follow the link if you want to run elasticsearch as daemon and get more insights on configurations: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html</a></p><p>Next step is getting started with snapshot life cycle management (SLM)</p><p>This demonstration is to automatically back up Elasticsearch indices using the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html">snapshots</a> every day at a particular time. Once these snapshots have been created, they are kept for a configured amount of time and then deleted per a configured retention policy.</p><p>Before starting, it’s important to understand the privileges that are needed when configuring SLM if you are using the security plugin. You can disable it in config/elasticsearch.yml for demo purpose by setting xpack.security.enabled is false. But recommended to enable this on production server.</p><pre>xpack.security.enabled: false</pre><p>Before setting up SLM policy we need to setup a snapshot repository where the snapshots will be stored. for this example we’ll use a shared file system repository. Cloud storage service like Amazon service S3 is recommended for production use.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3f9c2f35d53947e4fda3c4f49c6022d/href">https://medium.com/media/e3f9c2f35d53947e4fda3c4f49c6022d/href</a></iframe><p>Now we created a repository in place, we can create a SLM policy to automatically manage the snapshots. The policies are well defined in JSON. When configuring a policy, retention can also optionally be configured. We can use PUT API to create the policy.</p><p>We can define in JSON:</p><ul><li>When the snapshot should be taken, using cron syntax</li><li>Naming of each snapshots using date math to include the current date in the name of snapshot</li><li>The repository the snapshot should be stored in what we created already</li><li>Configuration to be used for the snapshots requests contains which indices should be in the snapshots, in this case everything.</li><li>Optional retention configuration includes snapshots expiry after how many days, always keep minimum number of snapshots, keep no more than maximum number of snapshots , even if there is less than 30days old.</li></ul><p>Now we can set up 12.12 AM UTC automatic snapshot creating time on daily basis and name the snapshot prefixed with “my-snap”+ current date. then added the repository name as “my_repository” we already created. then configured backup to take all the indices. after that added retention policy of 3 days and minimum snapshots count 1 and maximum snapshots count 30 days. policy name is “my-snapshots” and we can use it for further validation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cd0b134e9d06c8cda4c6b9105109f3c/href">https://medium.com/media/7cd0b134e9d06c8cda4c6b9105109f3c/href</a></iframe><p>While snapshots taken by SLM policies can be viewed through the standard snapshot API, SLM also keeps track of policy successes and failures in ways that are a bit easier to use to make sure the policy is working.</p><p>Instead of waiting for our policy to run, let’s tell SLM to take a snapshot as using the configuration from our policy right now instead of waiting for 12:12 AM.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a4b57f41e46711fb4b6703b9dad8da1/href">https://medium.com/media/1a4b57f41e46711fb4b6703b9dad8da1/href</a></iframe><p>Then we will get a response something like if it is successful:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/165657fbadf893f8e1930742843a131b/href">https://medium.com/media/165657fbadf893f8e1930742843a131b/href</a></iframe><p>The policy will continue to run on its configured schedule after this execution of the policy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f544c1c3504a90e597a64afd7320999/href">https://medium.com/media/5f544c1c3504a90e597a64afd7320999/href</a></iframe><p>This request will return a response that includes the policy, as well as information about the last time the policy succeeded and failed, as well as the next time the policy will be executed, and also the number of snapshots taken and other stats .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7135bcc6039a364ae0e72ea47559298/href">https://medium.com/media/d7135bcc6039a364ae0e72ea47559298/href</a></iframe><p>NOTE: Use Cloud storage instead of system storage in production. I will explain how to setup and configure Elasticsearch backup on AWS S3 on Next.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8268366553a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>