<?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 Matteo Codogno on Medium]]></title>
        <description><![CDATA[Stories by Matteo Codogno on Medium]]></description>
        <link>https://medium.com/@matteocodogno?source=rss-1c3ab6bcfb9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kwh5RT8xZwz5EfcX.jpeg</url>
            <title>Stories by Matteo Codogno on Medium</title>
            <link>https://medium.com/@matteocodogno?source=rss-1c3ab6bcfb9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:17:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matteocodogno/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[Chat with your commits: AI + 1Password + Terminal]]></title>
            <link>https://medium.com/welld-tech/chat-with-your-commits-ai-1password-terminal-cd252761f81b?source=rss-1c3ab6bcfb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd252761f81b</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Matteo Codogno]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 12:09:45 GMT</pubDate>
            <atom:updated>2025-12-22T10:18:47.494Z</atom:updated>
            <content:encoded><![CDATA[<p>Writing good commit messages is a small task that adds up. I live in my terminal, so I wanted a fast, reliable way to produce <a href="https://www.conventionalcommits.org/en/v1.0.0/">Conventional Commits</a> without leaving <a href="https://iterm2.com/">iTerm</a> — and without fighting quoting, hooks, or secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_pP1qy5bKIuuQRUFL5P3Qw.png" /><figcaption>A digital graphic styled as a retro terminal screen, showing the execution of the ‘git ca’ command and a generated Conventional Commit message.</figcaption></figure><p>This is the story of how I wired 1Password, <a href="https://direnv.net/">direnv</a>, and the <a href="https://github.com/simonw/llm">llm CLI</a> to auto‑generate clean messages from the staged diff, with hard rules (72‑char subject, no backticks), all from a simple alias or script.</p><h3>Why bother?</h3><p>When you’re deep in flow, message quality slides. IDE helpers exist, but the terminal is where I move fastest. I wanted:</p><ul><li>Conventional Commits by default</li><li>“Why” over “what” in bodies, wrapped at 72 cols</li><li>Zero friction: one command, then commit</li><li>Secret‑safe: no hard‑coded API keys</li></ul><h3>The setup</h3><p>I started from a DEV post that pipes git diff to a non‑interactive LLM client and returns a commit message. Then I adapted it for my stack:</p><ul><li>llm CLI as the model runner (Gemini default)</li><li>1Password for secrets + SSH commit signing</li><li>direnv to inject LLM_GEMINI_KEY / GEMINI_API_KEY</li><li>A robust Bash script to avoid shell quoting bugs</li></ul><h3>The prompt</h3><p>I learned that models “love” Markdown, so you must tell them not to. Here’s the essence of the system prompt I use:</p><pre>Generate a Conventional Commits message from the staged diff.<br><br>Output exactly:<br>&lt;type&gt;(&lt;optional scope&gt;): &lt;short description&gt;<br><br>&lt;optional body&gt;<br><br>&lt;optional footer&gt;<br><br>Rules:<br>- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.<br>- Short description: max 72 characters, imperative mood, sentence case, no trailing period.<br>- Type and scope are lower-case; scope is optional.<br>- Body: explain the why and key changes; use simple dash bullets; wrap all lines at 72 characters.<br>- Footer: include references (e.g., Closes #123) and BREAKING CHANGE: if applicable.<br>- Do not use markdown formatting, code fences, or the backtick character. Avoid quotes and emojis.<br>- Return only the commit message. No extra text, prefixes, or formatting.</pre><h3>The command</h3><p>Once the llm CLI is installed and the Gemini plugin is configured, the simplest version is:</p><p>git commit -m “$(git diff –cached | llm -s ‘’)”</p><p>This works for small diffs and when quoting isn’t hostile. But I hit a few landmines.</p><h4>The landmines I hit — and solved</h4><ul><li>Triple backticks in output: the model formatted as Markdown inside a Git alias. Fix: forbid backticks in the prompt and strip any that slip through.</li><li>Quoting hell with -m: newlines and special characters get misinterpreted. Fix: write the message to a temp file and commit with -F.</li><li>“1Password: Could not connect to socket”: this popped up at commit time, usually because hooks/signing spawn a separate process without the agent socket. Fix: either export SSH_AUTH_SOCK in the script or disable signing for the test; the -F flow helps because no LLM calls run during commit itself.</li></ul><p>The script that made it boring — in a good way<br> I ended up with a small Bash script wired to a git alias. It:</p><ol><li>Reads the staged diff</li><li>Sends it to the model with the strict prompt</li><li>Strips any accidental backticks</li><li>Commits via -F using a temp file</li></ol><p><strong>Result</strong>: stable behavior, no escaping drama, and clean Conventional Commits every time.</p><p>Here’s the Bash script that wires the alias and avoids quoting issues:</p><pre># ~/bin/git-ca.sh<br>#!/usr/bin/env bash<br>set -euo pipefail<br><br># Generate message from staged diff with strict prompt<br>PROMPT=&#39;<br>Generate a Conventional Commits message from the staged diff.<br><br>Output exactly:<br>&lt;type&gt;(&lt;optional scope&gt;): &lt;short description&gt;<br><br>&lt;optional body&gt;<br><br>&lt;optional footer&gt;<br><br>Rules:<br>- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.<br>- Short description: max 72 characters, imperative mood, sentence case, no trailing period.<br>- Type and scope are lower-case; scope is optional.<br>- Body: explain the why and key changes; use simple dash bullets; wrap all lines at 72 characters.<br>- Footer: include references (e.g., Closes #123) and BREAKING CHANGE: if applicable.<br>- Do not use markdown formatting, code fences, or the backtick character. Avoid quotes and emojis.<br>- Return only the commit message. No extra text, prefixes, or formatting.<br>&#39;<br><br>diff=&quot;$(git diff --cached)&quot;<br>[ -z &quot;$diff&quot; ] &amp;&amp; echo &quot;No staged changes.&quot; &gt;&amp;2 &amp;&amp; exit 1<br><br>msg=&quot;$(printf &#39;%s\n&#39; &quot;$diff&quot; | llm -s &quot;$PROMPT&quot;)&quot;<br>echo &quot;$msg&quot;<br><br># Strip any accidental backticks or code fences<br>msg=&quot;$(echo &quot;$msg&quot; | sed &#39;s/`//g&#39; | sed &#39;s/```//g&#39;)&quot;<br><br>tmp=&quot;$(mktemp)&quot;<br>printf &#39;%s\n&#39; &quot;$msg&quot; &gt; &quot;$tmp&quot;<br>git commit -F &quot;$tmp&quot;<br>rm -f &quot;$tmp&quot;<br><br>git log --stat -1</pre><p>To execute the script via git ca, add the following Git alias:git config --global alias.ca &#39;!~/bin/git-ca.sh&#39; You should then find the new entry in your .gitconfig file.</p><pre>[alias]<br> ca = !~/bin/git-ca.sh</pre><h4>Environment and defaults</h4><ul><li>Install LLM plugin for gemini llm install llm-gemini</li><li>Set gemini as default model llm models default gemini-2.5-flash</li><li>direnv exports LLM_GEMINI_KEY (or GEMINI_API_KEY) from <a href="https://developer.1password.com/docs/cli/">1Password CLI</a>: export LLM_GEMINI_KEY=$(op read &quot;op://your_vault/item?key&quot;)<br>Optional: 1Password SSH commit signing — great when configured correctly; be mindful of the agent socket path if your hooks enforce signing</li></ul><h4>A note on “why” vs “what”</h4><p>Auto‑generated messages often describe “what”. You can nudge the “why” into the body through the prompt rules. In practice, I accept that perfect intent isn’t guaranteed; the important part is consistency, searchability, and low friction. When intent truly matters, write a few lines in the body.</p><h3>What’s next</h3><ul><li>Add a prepare‑commit hook to enforce the 72‑char subject and wrap the body</li><li>Capture outliers (empty diff, huge changes) and fall back to manual</li><li>Track quality with a simple like/dislike command in the terminal and tweak the prompt over time</li></ul><h3>Conclusion</h3><p>If you work terminal‑first, this approach keeps your workflow tight:</p><ul><li>One command to stage, generate, and commit</li><li>Conventional Commits enforced by the prompt</li><li>Secrets managed safely with 1Password + direnv</li><li>No Markdown fences, no quoting headaches</li></ul><p>It’s a small automation that saves minutes every day — and keeps your history readable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd252761f81b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/chat-with-your-commits-ai-1password-terminal-cd252761f81b">Chat with your commits: AI + 1Password + Terminal</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chat with your documentation]]></title>
            <link>https://medium.com/welld-tech/chat-with-your-documentation-58f76e456d65?source=rss-1c3ab6bcfb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/58f76e456d65</guid>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Matteo Codogno]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 11:39:26 GMT</pubDate>
            <atom:updated>2023-10-20T12:21:15.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLz2QlIRTOdV9SIQLQZVZw.jpeg" /></figure><p>Have you ever tried to find information across a large amount of documentation? It can be quite difficult, and we often rely on the search function to pinpoint what we’re searching for.</p><p>In our company, we maintain an internal wiki called wellD book, built with <a href="https://docusaurus.io/">docusaurus</a>. It serves as a central repository where we record tools, best practices, and guidelines that we should always have at hand.</p><p>In addition to that, our book also covers administrative processes such as how to request a day off or what the remote work policy is at wellD. However, many people tend to forget about the existence of the book and end up asking the same questions to our HR department.</p><p>Last but not least, we use Discord as a communication tool (chat) where employees can chat with each other and exchange information.</p><p>We are currently in the ChatGPT era, so there must be a way to connect all of these resources and streamline our processes, reducing repetitive tasks and making our lives easier!</p><h3>OpenAI + Supabase = 7docs</h3><p>I came across this amazing tool called <a href="https://github.com/7-docs/7-docs">7docs</a> which utilizes the OpenAI APIs to convert various file formats into text chunks and subsequently into embeddings (vectors) using the text-embedding-ada-002 model. Once we have the vectors, we store them in a vector database. 7docs offers integration with supabase, an alternative to Firebase based on PostgreSQL, which includes the <a href="https://github.com/pgvector/pgvector">pg_vector</a> extension.</p><p>7docs consists of two sub-projects. The first one is the “cli” used for ingesting documentation, and the second one is used for querying the dataset previously stored. But how does it extract information from the vector table based on a user’s question? Well, first, 7docs converts the question into a vector. Then, it measures the distances between this vector and the other vectors, returning the vectors that are more “similar” or closer to the question vector. The default similarity threshold is set to 0.78.</p><p>Once we have the question vector and some possible answers, we use the OpenAI gpt-3.5-turbo model to generate a coherent answer for the user.</p><p>The diagram below attempts to describe the functionality of our system upon completion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*xufhgIqwyiGwL55bzo7XeA.jpeg" /></figure><h3>🤖 Bot for the simpleness</h3><p>It seems that all the pieces are falling into place. We just need to write a Discord bot that will allow my colleagues to query our documentation. Discord offers excellent documentation (<a href="https://discordjs.guide/">https://discordjs.guide/</a>) that explains how to build a bot. It’s quite easy to do. We already have a Discord bot made with Bun (<a href="https://bun.sh/">https://bun.sh/</a>), but that’s another story or perhaps a future blog post. For now, we just need to add a new command that takes in a question as input and returns a response processed by the logic described above.</p><p>The result is quite impressive. I asked the bot if there was a way to sync IDE settings across laptops, and that’s the answer it provided!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLfNgUV7pd9AJ2WAoMtSlw.gif" /><figcaption>Bot in action!</figcaption></figure><p>AI retrieves information from this section of our internal wiki: <a href="https://book.welld.io/docs/tools/ide">https://book.welld.io/docs/tools/ide</a></p><p>On a<strong> side note</strong>, I initially thought it would be easy to instruct OpenAI to respond to the question only with the provided context. Otherwise, it should have responded with a “sorry” message. However, I ended up spending more time than planned. I had to write and rewrite my prompt several times to find the best fit for my use case. Additionally, I had to introduce a circuit break for cases where the SQL query does not extract any vectors from the database.</p><h3>Automate, automate everything!</h3><p>I must confess that I enjoy automating processes as much as possible. To achieve this, I created a Docker image that includes the 7docs CLI, which I utilized in the CI/CD pipeline for our wellD book site.</p><p>So, here’s the bit of the Dockerfile that I whipped up:</p><pre>FROM node:18.18 as node<br><br>RUN echo &quot;NODE Version:&quot; &amp;&amp; node --version<br>RUN echo &quot;NPM Version:&quot; &amp;&amp; npm --version<br><br>FROM python:3.11.4<br><br>COPY --from=node . .<br><br># Due to this issue: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2750<br># we need to use the root user to install 7-docs.<br>USER root<br><br>RUN npm install --global 7-docs@0.5.1</pre><p>Whenever a commit is pushed to the master branch and it includes at least one added or modified markdown file, the ai:ingestion job is triggered, updating the vectors on Supabase. This ensures that our Bot&#39;s knowledge remains synchronized with the wiki.</p><p>Here is the GitLab job definition:</p><pre>7docs:ingest:<br>  stage: ai<br>  retry: 1<br>  image:<br>    name: &lt;YOUR_DOCKER_REGISTRY&gt;/7docs:0.5.1-node18-v2<br>    entrypoint: [&quot;&quot;]<br>  allow_failure: false<br>  cache: {}<br>  needs:<br>    - job: npm:install<br>      optional: true<br>  variables:<br>    NAMESPACE: book-collection<br>  script:<br>    - 7d ingest --files &#39;docs/**/*.md&#39; --namespace $NAMESPACE<br>  rules:<br>    - if: $7DOCS_DISABLED<br>      when: never<br>    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH<br>    - if: $CI_COMMIT_TAG</pre><h3>👣 Next steps</h3><p>I have several new ideas to enhance this project, but the most important ones are:</p><ul><li>Adding like and dislike buttons under the bot’s answer to track its quality. This feature is extremely useful, as is the next one.</li><li>Storing questions and their corresponding answers in our database to prevent duplicate requests to OpenAI and save some money.</li></ul><h3>🎬 Conclusion</h3><p>Hey there, this blog post delves into the challenges we face when searching for information in large documentation. But fear not, because we have an amazing tool to the rescue: 7docs! Powered by the mighty OpenAI APIs and Supabase, 7docs breaks down those hefty files into text chunks and mind-blowing embeddings. And guess what? It uses the power of vector similarity to pinpoint the most relevant information. How cool is that?</p><p>But wait, there’s more! We also uncover the need for a Discord bot in our documentation quest. And to make things even more epic, we provide step-by-step instructions on how to automate the integration using Docker and a CI/CD pipeline. It’s like we’re summoning the forces of automation!</p><p>Now, what lies ahead on our geeky journey? We suggest adding feedback buttons to gauge the quality of our bot’s answers. And storing questions and answers in a database to save our precious resources.</p><p>So, gear up and dive into this mind-bending blog post.</p><h3>Useful Links</h3><ul><li><a href="https://docusaurus.io/">https://docusaurus.io/</a></li><li><a href="https://github.com/7-docs/7-docs">https://github.com/7-docs/7-docs</a></li><li><a href="https://github.com/pgvector/pgvector">https://github.com/pgvector/pgvector</a></li><li><a href="https://discordjs.guide/#before-you-begin">https://discordjs.guide/#before-you-begin</a></li><li><a href="https://bun.sh/">https://bun.sh/</a></li><li><a href="https://platform.openai.com/docs/guides/embeddings">https://openai.com/blog/new-and-improved-embedding-model</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58f76e456d65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/chat-with-your-documentation-58f76e456d65">Chat with your documentation</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Backups Unleashed: Fortify Your K8s Cluster]]></title>
            <link>https://medium.com/welld-tech/backups-unleashed-fortify-your-k8s-cluster-ce49421af496?source=rss-1c3ab6bcfb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce49421af496</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[velero]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[backup]]></category>
            <dc:creator><![CDATA[Matteo Codogno]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 10:12:39 GMT</pubDate>
            <atom:updated>2023-09-11T10:12:39.094Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>No Backups. I too like to live dangerously.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFurjxjfYtt1lN4SkGxiqQ.jpeg" /></figure><p>As I mentioned in a <a href="https://medium.com/welld-tech/kas-the-gitlab-kubernetes-agent-a81ebcb307e4">previous</a> blog post, <a href="https://welld.ch/">wellD</a>’s infrastructure is entirely hosted on GKE (Google Kubernetes Engine). Our Kubernetes clusters are configured with multiple node pools, each tailored to the specific resource requirements of our services. Furthermore, all of the node pools are configured to autoscale. Autoscaling enables the addition or removal of nodes from our pool based on the load of the node pool.</p><p>Ensuring that your Kubernetes cluster is backed up is essential for disaster recovery, migration, and more. However, the question remains: how can we effectively back up all of these dynamic nodes? Typically in GCP, we establish a snapshot policy for our VM instance disks. However, applying the same approach to GKE nodes is not feasible. Thankfully, Google provides a <a href="https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/concepts/backup-for-gke">backup tool</a> for GKE that allows to set up backup schedule, retention policy, namespaces, and more. Once configured, the backup tool provides a list of backups, restores, and restore plans.</p><p>Recently, one of our customers came up with a request to put in place a backup system for all of their K8s vanilla clusters. Here below, a description of how this need was addressed.</p><h3>How to Backup a Vanilla K8s cluster (but not only)</h3><p>Even though there are many solutions for backing up a K8s cluster, we were specifically looking for a tool that was tightly integrated with K8s and had the ability to backup and restore all objects in our clusters, including PersistentVolumes. Ideally, the tool would also allow us to create on-demand or scheduled backups and upload them to an object storage solution, such as AWS S3.</p><p>After conducting a thorough search and comparison on the web, we have chosen <a href="https://velero.io/">Velero</a> as our designated backup tool for Kubernetes.</p><p>Velero is an open-source tool that can help you safely backup and restore Kubernetes cluster resources and persistent volumes.</p><h3>How does it work?</h3><p>Velero is an open-source tool that uses the Kubernetes API to capture the state of cluster resources and restore them when necessary. Velero offers a wide range of operations, including on-demand backups, scheduled backups, as well as restores. Each Velero operation is a custom resource stored in etcd.</p><p>Velero consists of a Kubernetes deployment, the BackupController, which runs on our server, and a command-line interface used for creating Velero custom resource definitions.</p><p>The backup operation uploads a tarball of copied Kubernetes objects into cloud object storage and calls the cloud provider API to make disk snapshots of persistent volumes if specified. When you run velero backup create test-backup, the Velero client makes a call to the Kubernetes API server to create a Backup object. The BackupController notices the new Backup object and performs validation, then begins the backup process. It collects the data to back up by querying the API server for resources. The BackupController makes a call to the object storage service to upload the backup file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*4hb_GvFOBGYvQWHy.png" /><figcaption>from Velero official documentation</figcaption></figure><p>By default, velero backup create makes disk snapshots of any persistent volumes. Additional flags can be specified to adjust the snapshots, which can be disabled with the option --snapshot-volumes=false.</p><p>Velero supports various storage providers for storing backups, and it is possible to find a comprehensive list <a href="https://velero.io/docs/v1.12/supported-providers/">here</a>.</p><p>The official documentation explains how Velero works, and it is instead collected <a href="https://velero.io/docs/v1.12/how-velero-works/">here</a>.</p><h3>How we use it</h3><p>We set up Velero with <a href="https://github.com/vmware-tanzu/helm-charts/blob/main/charts/velero/README.md">Helm</a> and hooked it up to our <a href="https://fluxcd.io/">fluxcd</a> repository. Besides, we made sure Velero knew how to stash our backups on AWS using its <a href="https://github.com/vmware-tanzu/velero-plugin-for-aws#setup">plugin</a>.</p><p><em>The following YAML code blocks are a portion of the values.yaml file for the Velero deployment. You can find the complete at https://github.com/vmware-tanzu/helm-charts/blob/main/charts/velero/values.yaml.</em></p><pre>initContainers:<br>- name: velero-plugin-for-aws<br>  image: velero/velero-plugin-for-aws:v1.7.0<br>  imagePullPolicy: IfNotPresent<br>  volumeMounts:<br>  - mountPath: /target<br>    name: plugins</pre><p>Instead of using AWS S3 as object storage, we opted for <a href="https://wasabi.com/">Wasabi</a>, a cost-effective S3-compatible alternative. With Wasabi, you can get 1TB of storage for $6.99 per month.</p><pre>configuration:<br>  backupStorageLocation:<br>  - name: my-k8s-backup<br>    provider: aws<br>    bucket: k8s-backup-my<br>    prefix: papasmurf<br>    credential:<br>      name: wasabi-credentials<br>      key: cloud<br>    config:<br>      region: eu-central-2<br>      s3ForcePathStyle: true<br>      s3Url: &lt;https://s3.eu-central-1.wasabisys.com&gt;<br>  garbageCollectionFrequency: 24h<br>  defaultBackupTTL: 72h<br>  defaultBackupStorageLocation: my-k8s-backup<br>  uploaderType: restic<br>  logFormat: text<br>  logLevel: info<br>  namespace: velero</pre><p>Since most of our services are stateless and involve relatively few volumes, we have disabled the volume snapshot, by setting snapshotsEnabled to false.</p><p>Following this, the ultimate step involves configuring the backup schedule policy. This entails determining the desired backup frequency for our cluster, specifying the included namespaces, and establishing the retention duration for the backups.</p><pre>schedules:<br>  daily-backup:<br>    disabled: false<br>    schedule: &quot;0 0 * * *&quot;<br>    useOwnerReferencesInBackup: false<br>    template:<br>      ttl: &quot;72h&quot;<br>      storageLocation: my-k8s-backup<br>      include-cluster-scoped-resources: true<br>      include-namespaces:<br>      - &#39;*&#39;<br>      excludeNamespaces:<br>      - default<br>      - kube-system<br>      - kube-public<br>      - kube-node-lease<br>      - calico-apiserver<br>      - calico-system</pre><h3>Backup</h3><p><em>*** In the next section, I will use the Velero CLI. You can find the documentation to install it </em><a href="https://velero.io/docs/v1.3.0/basic-install/#install-the-cli"><em>here</em></a><em>.</em></p><p>Velero is configured to perform daily backup of our cluster at midnight. To verify this configuration, you can execute the following command:</p><pre>velero describe schedules</pre><p>The output will be:</p><pre>Name:         velero-daily-backup<br>...<br>Phase:  Enabled<br>Paused:  false<br>Schedule:  0 0 * * *<br>Backup Template:<br>  Namespaces:<br>    Included:  *<br>    Excluded:  &lt;none&gt;<br>  Resources:<br>    Included:        *<br>    Excluded:        &lt;none&gt;<br>    Cluster-scoped:  auto<br>  Label selector:  &lt;none&gt;<br>  Storage Location:  my-k8s-backup<br>  Velero-Native Snapshot PVs:  auto<br>  TTL:  72h0m0s<br>  CSISnapshotTimeout:    0s<br>  ItemOperationTimeout:  0s<br>  Hooks:  &lt;none&gt;<br>Last Backup:  &lt;never&gt;</pre><p>To check the backup history, simply execute the following command:</p><pre>velero backup get</pre><p>And that is the output:</p><pre>velero-daily-backup-20230509145227   Completed   0        0          2023-05-09 16:52:27 +0200 CEST   2d        my-k8s-backup      &lt;none&gt;</pre><p>You can obtain more information about the backup by running the following command:</p><pre>velero describe backup</pre><p>The output should be similar to this:</p><pre>Name:         velero-daily-backup-20230509145227<br>...<br>Phase:  Completed<br>Namespaces:<br>  Included:  *<br>  Excluded:  &lt;none&gt;<br>Resources:<br>  Included:        *<br>  Excluded:        &lt;none&gt;<br>  Cluster-scoped:  auto<br>Label selector:  &lt;none&gt;<br>Storage Location:  my-k8s-backup<br>Velero-Native Snapshot PVs:  auto<br>TTL:  72h0m0s<br>CSISnapshotTimeout:    10m0s<br>ItemOperationTimeout:  1h0m0s<br>Hooks:  &lt;none&gt;<br>Backup Format Version:  1.1.0<br>Started:    2023-05-09 16:52:27 +0200 CEST<br>Completed:  2023-05-09 16:52:53 +0200 CEST<br>Expiration:  2023-05-12 16:52:27 +0200 CEST<br>Velero-Native Snapshots: &lt;none included&gt;</pre><h3>Restore</h3><p>If a disaster occurs, you have the ability to restore your cluster to a prior state. To review the backup history, execute the following command:</p><pre>velero backup get</pre><p>Then you can restore the cluster by running the following command:</p><pre>velero restore create --from-backup &lt;backup-name&gt;</pre><p>The cluster will be restored to the state of the backup by retrieving the backup from the storage location, Wasabi in our case. Lastly, you can assess the status of the restoration process by executing the following command:</p><pre>velero restore get</pre><h3>Conclusion</h3><p>In this blog post, we have explored the essential steps that enable us to backup and restore our K8s clusters. This practice is not just recommended; it’s a critical safeguard against potential disasters. By following the procedures outlined here, you can ensure your cluster can be restored to its previous state.</p><p>But that’s not where the journey ends. Imagine migrating your cluster to another cloud provider or to another region of the same cloud provider. Velero empowers you to effortlessly, back up your cluster and restore it in a new location.</p><p>That’s all folks! 🐰<br>So long and thanks for all the fish. 🐟</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce49421af496" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/backups-unleashed-fortify-your-k8s-cluster-ce49421af496">Backups Unleashed: Fortify Your K8s Cluster</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KAS: the GitLab Kubernetes Agent]]></title>
            <link>https://medium.com/welld-tech/kas-the-gitlab-kubernetes-agent-a81ebcb307e4?source=rss-1c3ab6bcfb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a81ebcb307e4</guid>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <category><![CDATA[ci]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Matteo Codogno]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 16:37:24 GMT</pubDate>
            <atom:updated>2022-06-28T16:37:24.171Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vS_h3XBnA8HgNBal" /><figcaption>Photo by <a href="https://unsplash.com/@timelabpro?utm_source=medium&amp;utm_medium=referral">Timelab Pro</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>GitLabOps</h3><p>In this blog post series, I will show how it is possible to use GitLab to implement GitOps’ best practices. In this first article, we will focus on how to migrate from <strong>GitLab Kubernetes</strong> integration based on <strong>K8s API and cluster certificates</strong> to <strong>GitLab Kubernetes Agent Server</strong>.</p><p>This step becomes even more crucial as cluster certificate integration has been <strong>DEPRECATED</strong> with GitLab version 14.5.</p><h3>Starting point</h3><p>At <a href="https://www.welld.ch/">WellD</a> most of our software is deployed on K8s. We have a job template that leverages bitnami/kubectl docker image to <strong>apply</strong> K8s descriptors or <a href="https://kustomize.io/">kustomize</a> files against the K8s cluster. Authentication to the K8s cluster is performed via KUBE_URL and KUBECONFIG environment variables, that are automatically exposed.</p><pre>k8s_deploy:<br>  stage: deploy<br>  tags: [welld]<br>	image: bitnami/kubectl:latest<br>  retry: 2<br>  interruptible: true<br>  cache: {} # In this job we do not need cache.<br>  artifacts:<br>    paths: [environment_url.txt]<br>  script:<br>	  - upgrade_project_version || true<br>	  - install_dependencies<br>	  - persist_environment_url<br>	  - deploy<br>	rules:<br>    - if: $KUBE_DEPLOY_DISABLED<br>      when: never<br>    - if: $CI_PIPELINE_SOURCE == &quot;merge_request_event&quot;<br>      when: manual<br>      allow_failure: true<br>    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH<br>    - if: $CI_COMMIT_TAG</pre><p>We maintain a bash script that loads as default before_script for all jobs. This bash script contains all functions that we need in our CI/CD jobs.</p><h3>Security issues</h3><p>Why did GitLab deprecate this kind of integration with Kubernetes?</p><p>Direct integration with K8s API and cluster certificate has some security issues. First of all, anyone who can create a deployment job has direct access to the Kubernetes API. Furthermore, as most of the features within the integration require elevated privileges, we had to give cluster-admin rights to GitLab.</p><h3>GitOps</h3><p>The core idea of <strong>GitOps</strong> is having all infrastructure descriptors (<strong>IaC</strong> or Infrastructure as code) versioned in a git repository, aka Single Source Of Truth, and a process that maintains the infrastructure updated to the last commit.</p><p>The traditional way to deploy a new piece of infrastructure was called pushed-based deployments. In this deployment strategy, the infrastructure update is triggered by a codebase update and executed by the build pipeline. When new commits are pushed, the triggered pipeline will build artifacts (JAR, tarball, etc..), and container images, and eventually apply infrastructure descriptors. With this approach, our pipeline must have the credentials to update the target environment. An additional drawback of this deployment strategy is that the pipeline is triggered only when the git repository changes: if the environment does not match the desired state we do not have an automatic way to reconcile the state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42N8g7dVkz8TfPPyPzrHlQ.png" /><figcaption>pushed-based deployment</figcaption></figure><p>The preferred way to update the environment is called pulled-based deployments. With this approach, we need a operator that continuously compares the current state and the desired state of the infrastructure. Whenever a difference has noticed operator updates the infrastructure in order to match the desired state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7xJqPd3p_qwxk4hSy4roA.png" /><figcaption>pull-based deployment</figcaption></figure><p>In GitLab terms, this operator is called <strong>Agent</strong>.</p><h3>Setting up GitLab Agent</h3><p><strong>Installation</strong> of Gitlab Agent Server (A.K.A. KAS) is very simple: we just edited the gitlab.rb configuration file to add this line gitlab_kas[&#39;enable&#39;] = true. Then we launched the GitLab reconfiguration command gitlab-ctl reconfigure.</p><p>After that, we chose our <em>kube-infrastructure</em> git repository as a <strong>configuration repository</strong>. The configuration repository is the GitLab repository that holds the Agent configuration file. This file is located at this path .gitlab/agents/&lt;agent-name&gt;/config.yaml. We also had to grant other projects access to the Agent:</p><pre>ci_access:<br>  projects:<br>  - id: path/to/project</pre><p>At this point, from project sidebar <strong>Infrastructure &gt; Kubernetes clusters</strong>, we registered a new Agent: the modal that appears contains the registration token and helm instruction to install the Agent on the K8s cluster.</p><h3>Update CI/CD scripts</h3><p>As we already mentioned, we have CD scripts to deploy our kustomize files to the K8s cluster. It was then reasonable to find a way to reuse our centralized CD scripts. This turned out to be possible by adding this line kubectl config use-context path/to/agent-configuration-project:your-agent-name to the deploy job.</p><pre>deploy:<br>   image:<br>     name: bitnami/kubectl:latest<br>     entrypoint: [&quot;&quot;]<br>   script:<br>   - kubectl config use-context path/to/agent-configuration-project:your-agent-name<br>   - kubectl apply -k ...</pre><h3>Missing features</h3><p>While this new Agent-based approach overcomes security issues, it lacks a bunch of handy features that were included in the deprecated cluster certificates integration, namely:</p><ul><li>see pods log</li><li>connect to pod shell</li><li>see pods resources</li></ul><p>directly from the GitLab interface!</p><p>All these features are now deprecated, and the GitLab team is working to replace them with the new KAS integration. However, at the time of writing, those features are not available with KAS integration.</p><h3>Conclusion</h3><p>Migration from cluster certificate integration to KAS was not painful. KAS embraces GitOps <a href="https://www.weave.works/technologies/gitops/">principles</a> and we did not need to search for another tool (ArgoCD, Flux Gitkube, etc..) to implement GitOps workflows.</p><p>In the next blog post, we will connect GitLab Agent to our kube-infrastructure git repository, where we version our Kubernetes infrastructure.</p><h3>Useful links</h3><ul><li><a href="https://devops.com/an-inside-look-at-gitops/">What is GitOps</a></li><li><a href="https://www.gitops.tech/#">GitOps tech</a></li><li><a href="https://about.gitlab.com/blog/2021/10/21/gitops-with-gitlab/">GitOps with Gitlab</a></li><li><a href="https://about.gitlab.com/topics/gitops/infrastructure-as-code/">Infrastructure as code</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a81ebcb307e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/kas-the-gitlab-kubernetes-agent-a81ebcb307e4">KAS: the GitLab Kubernetes Agent</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go with the (git)flow, or die debating — IT]]></title>
            <link>https://medium.com/welld-tech/go-with-the-git-flow-or-die-debating-it-17ba7e0574dc?source=rss-1c3ab6bcfb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/17ba7e0574dc</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[branching-strategy]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Matteo Codogno]]></dc:creator>
            <pubDate>Thu, 21 Mar 2019 08:56:08 GMT</pubDate>
            <atom:updated>2019-03-21T08:57:10.603Z</atom:updated>
            <content:encoded><![CDATA[<h3>Go with the (git)flow, or die debating — IT</h3><p>Tutti quanti versioniamo le nostre <em>codebase</em> sfruttando uno dei sistemi di controllo di versione presenti sul mercato. Da quando ho iniziato a lavorare per <a href="https://www.welld.ch/?utm_source=Medium&amp;utm_medium=ContentMarketing&amp;utm_content=Gowiththegit">wellD</a> ne ho visti cambiare tre.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*i0KlFbEZ0xpJn3Ip1hy19g.png" /></figure><p><strong>All’inizio si usava <em>CVS</em></strong>, ma non essendo transazionale (<em>all or nothing</em>) c’era da divertirsi quando qualcosa si piantava a metà — per non parlare delle sue performance.<br><strong>Il passo successivo fu quindi <em>SVN</em></strong><em> (</em>si è scelto di non andare su <em>git</em> perché troppo <em>complicato</em>!) e ci siamo trovati con il mal di testa ogni volta che si doveva fare il merge tra due branch.<br><strong>Finalmente arrivò il tempo di <em>git</em></strong>, che sconvolse in positivo il modo di lavorare del team di sviluppo.</p><p>A differenza dei precedenti però, <em>git</em> richiede di definire delle <strong>modalità condivise</strong> di uso del sistema.</p><p>Una delle prime con le quali ci siamo scontrati è stata la necessità di adottare una <strong>strategia di gestione dei branch</strong>. I tre criteri che hanno guidato la nostra scelta sono: una <strong>Continuous Integration facile</strong> da integrare, <strong>rilasci frequenti</strong> e <strong>code review</strong> puntuale.</p><h3>Branching strategy</h3><p>Di seguito una <strong>panoramica delle branching strategy</strong> che abbiamo sperimentato direttamente o indirettamente, tenendo presente i criteri appena citati.</p><h4>Anarchy strategy</h4><p>Anche detta “no strategy”. In questo modello si da infatti la facoltà ad ogni sviluppatore del team di aprire branch <strong>senza rispettare alcuna convenzione</strong>sulla durata, nome e contenuto del branch.</p><p>Il vantaggio (apparente) è un kickoff rapido e l’indipendenza nello sviluppo. Il risultato (<em>ahimé</em> molto più tangibile) è che in poco tempo la situazione diventa <strong>ingestibile</strong>.</p><p>Il team spenderà del tempo per capire qual è il branch attivo di sviluppo, su quale deve sviluppare, in quale/i branch è contenuta una particolare feature o quale branch bisogna portare in produzione.</p><h4>Git Flow</h4><p>Per oltre un anno abbiamo abbracciato <em>git-flow</em>, che ci ha dato <strong>ordine</strong>, <strong>metodo</strong> e <strong>struttura</strong>, oltre che una CLI che ha ovviato ai problemi di naming convention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_e5-b3LhNblL1Sazhkhdw.png" /></figure><p>L’idea che c’è dietro a <em>git-flow</em> è abbastanza semplice:</p><ul><li>il branch master contiene i tag con tutte le versioni rilasciate</li><li>develop gli sviluppi aperti</li><li>i branch di feature le nuove funzionalità in fase di sviluppo</li><li>i branch di release le versioni dal nostro software candidate al rilascio</li><li>i branch di hotfix la correzioni dei bug segnalati dalla produzione</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*uLE1KkPSVYO4sOrV-h4nlQ.png" /></figure><p>Il problema più grande del <strong>GitFlow</strong> è la sua <strong>complessità</strong>. Tutto lo sviluppo non è più contenuto su master, default branch per molti tool, ma su develop,conmaster che viene utilizzato come contenitore dei rilasci.</p><p>Questo tipo di approccio renderà di fatto impossibile fare <strong>code review</strong> delle MR (merge request) aperte su master (obbligatorie in quanto protetto), perché conterranno gli sviluppi di settimane/mesi. Vi è comunque la possibilità di aprire MR dai feature branch su develop, ma tutto viene lasciato alla buona volontà dello sviluppatore in quanto non è necessaria una MR poiché develop non è protetto (quanto meno non di default).</p><p>Uno dei problemi maggiori che abbiamo riscontrato è <strong>la correzione di bug su versioni precedenti all’ultima rilasciata</strong>. Ipotizziamo di aver rilasciato la versione 2.X di un nostro software, e che un cliente ci segnali un problema sulla versione 1.Z. La cosa più ragionevole da fare è posizionarsi sumaster al tag 1.Z e aprire un branch di support per correggere il bug. Una volta corretto il bug come ci comportiamo? Da quale branch rilasciamo (support, master, altro?) la nostra correzione? Dove integriamo il nostro fix? Lo riportiamo su master? Su develop? O lasciamo il branch di support appena aperto unmerged per sempre?</p><p>La procedura di rilascio nel GitFlow può diventare davvero ostica. Le fasi che la compongono sono:</p><ul><li>aprire il branch di release da develop, con il comando git flow release start &lt;VERSION_NUMBER&gt;</li><li>aggiornare la <strong>code base</strong> (<strong>changelog</strong>, project version, readme etc..)</li><li>attendere che la CI (continuous integration) ci dia l’OK per chiedere la MR su master</li><li>unire il branch di release a master, git flow release finish &lt;VERSION_NUMBER&gt; <br>Alla fine di questa fase avremo integrato il branch di release su master e su develop, inoltre il commit di rilascio sarà taggato e noi ci troveremo nuovamente su develop</li><li>fare <strong>push</strong> di master, develop e del tag (N.B.git push --tags)</li><li><em>P.S.</em> aggiornare la versione del progetto sul branch di develop per la prossima iterazione e solo dopo fare <strong>push</strong>.</li></ul><p>In alcuni casi è davvero <em>overkill </em>eseguire questa procedura, e commettere un errore (<em>per esperienza</em>) è abbastanza facile.</p><h4>GitHub Flow</h4><p>Il GitHub Flow è <strong>semplice</strong> e <strong>pulito</strong>, si hanno solo 2 tipi di branch: il master e i branch di feature. Lo sviluppatore crea un branch dal repository e svilupperà su di esso la nuova <strong>feature</strong>, e una volta terminata aprirà una MR (sottoposta a code review) su master. Per aggiornare una MR basta fare un push sul proprio branch, e quando la MR sarà pronta ne verrà fatto il merge su master, dopodiché il branch di feature verrà eliminato.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sjfG1wKaWlZ57JLI3g_bEA.png" /></figure><p>Questa branching strategy fa però <strong>2 forti assunzioni</strong>:</p><ol><li>Che si possa andare in produzione in qualsiasi momento, cosa non sempre vera. Molti nostri clienti ci danno una finestra oraria di un giorno ben preciso per portare la nuova versione del software in produzione.</li><li>Il cliente installerà sempre l’ultima versione del nostro applicativo e quindi non ci sarà bisogno di fare <strong>supporto</strong> e <strong>bug fixing </strong>su rilasci antecedenti all’ultimo. 🤔</li></ol><h4>Gitlab Flow 🚀</h4><p>Partendo dal GitHub Flow è stata pensata una nuova strategia, che prevede <strong>un branch per ogni ambiente</strong>. Supponiamo di avere un ambiente di <strong>staging</strong>, uno di <strong>QA</strong> (Quality Assurance) e uno di <strong>Prod</strong> e che ognuno di essi venga aggiornato in maniera automatica da uno script di CI che punta al rispettivo branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*w91VImMZW6Ubf5cE.png" /></figure><p>In questo modo abbiamo tutti i vantaggi di MR piccole e puntuali su master, dove possiamo effettuare code review, e quando pronti possiamo portare i nostri cambiamenti sull’ambiente di QA (MR da mastera pre-production) e successivamente in Prod (MR da pre-productiona production).<br>Questo workflow ci assicura inoltre che tutti i commit siano testati su tutti gli ambienti.</p><p>Talvolta è necessario mantenere attivo lo sviluppo su più versioni del nostro software, per questo motivo si ricorre ai <strong>Release Branches</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*0AVVgZUsWRHj_UYX.png" /></figure><p>In questo caso ogni branch corrisponde ad una versione del nostro software (nel caso dell’immagine sopra una <em>minor</em>). Si tende a creare il branch di rilascio il più tardi possibile (<em>stable</em> nell’immagine), per evitare di dover applicare <strong>hotfix</strong> su più branch.</p><p>Quando viene riscontrata un’anomalia nel nostro software, la correzione viene fatta su branch di feature che poi viene integrato in master e successivamente viene fatto il cherry-pick del commit sui branch di rilascio. Questa tecnica, chiamata <strong>Upstream First</strong>, viene impiegata per evitare che ci si dimentichi di integrare l’hotfix su master e che quindi il problema si ripresenti su una futura release.</p><h4>Conclusione 🤓</h4><p>Uno dei concetti che più approvo della metodologia <a href="https://leankit.com/learn/lean/lean-methodology/"><strong>Lean</strong></a> è il continuo miglioramento, che viene perfettamente racchiuso in questa storiella:</p><blockquote>C’era il titolare di una grossa azienda americana che aveva deciso di ispirarsi alla <strong>Lean </strong>per migliorare la propria catena produttiva. Dopo alcuni mesi che era stata introdotta in azienda, invitò il proprietario di una fabbrica giapponese (dove da Lean era stata applicata da sempre) a visitare il proprio stabilimento.<br>Il giorno prefissato per l’appuntamento l’americano fa da cicerone al giapponese durante la gita alla fabbrica, mostrandogli le migliorie introdotte grazie alla Lean. Il giapponese guarda ma non si sbilancia in nessun commento.<br>Alla fine del tour l’americano chiede al giapponese: “Cosa ne pensa di come abbiamo riadattato lo stabilimento seguendo le vostre line guida? Siamo riusciti ad adottare in pieno la metodologia Lean?”<br>Il giapponese rispose: “Io questo non lo so, ieri non c’ero!”</blockquote><p>Questo per dire che ad oggi, partendo dal CVS, siamo arrivati al <strong>git </strong>e al <strong>Gitlab Flow</strong>, che al momento sembra soddisfare in modo abbastanza completo il nostro ciclo di sviluppo, ma siamo sempre pronti a sperimentare ed eventualmente adottare qualsiasi tool / strategia che migliori la vita del team di sviluppo.</p><h4>Riferimenti 🔗</h4><ul><li><a href="https://docs.gitlab.com/ee/workflow/gitlab_flow.html">https://docs.gitlab.com/ee/workflow/gitlab_flow.html</a></li><li><a href="https://datasift.github.io/gitflow/IntroducingGitFlow.html">https://datasift.github.io/gitflow/IntroducingGitFlow.html</a></li><li><a href="https://danielkummer.github.io/git-flow-cheatsheet/">https://danielkummer.github.io/git-flow-cheatsheet/</a></li><li>Esempio di GitLab Flow: <a href="https://github.com/spring-projects/spring-boot">https://github.com/spring-projects/spring-boot</a></li><li>Upstream first: <a href="https://www.chromium.org/chromium-os/chromiumos-design-docs/upstream-first">https://www.chromium.org/chromium-os/chromiumos-design-docs/upstream-first</a></li></ul><p>— <br><a href="https://twitter.com/teo1690">Matteo Codogno</a>, Technical Leader @<a href="https://medium.com/u/b219cc57bd86">WellD</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17ba7e0574dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/go-with-the-git-flow-or-die-debating-it-17ba7e0574dc">Go with the (git)flow, or die debating — IT</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go with the (git)flow, or die debating — EN]]></title>
            <link>https://medium.com/welld-tech/go-with-the-git-flow-or-die-debating-en-e4e71dcb5aff?source=rss-1c3ab6bcfb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e71dcb5aff</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[branching-strategy]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Matteo Codogno]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 10:00:42 GMT</pubDate>
            <atom:updated>2019-03-30T07:36:44.944Z</atom:updated>
            <content:encoded><![CDATA[<h3>Go with the (git)flow, or die debating</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*i0KlFbEZ0xpJn3Ip1hy19g.png" /></figure><p>We all version our codebase using one of the many version control systems (VCS) on the market. Since I started working for <a href="https://www.welld.ch/it/index.html?utm_source=Medium&amp;utm_medium=ContentMarketing&amp;utm_content=Gowiththegit">wellD</a>, we have changed three of them.</p><p><strong>In the beginning, we were using <em>CVS</em></strong>, but given its inability to be atomic–in an <em>all</em>-or-<em>nothing</em> sense–it really wasn’t fun when something got stuck halfway through. Let’s not even mention its performances.<br> <strong>Our next step was then to switch to<em> SVN</em></strong>; we<em> </em>chose not to go for <em>git</em> because it was too <em>complex</em>! As a result, merging two branches would always give us a headache.<br> <strong>Finally, it was <em>git</em>-time</strong>, which positively disrupted the way our developers’ team worked.</p><p>Unlike the first two VCSs, however, <em>git</em> forces users to define <strong>shared methodologies</strong> to use the system.</p><p>In this respect, one of the first challenges we faced was to agree on a shared <strong>branching strategy</strong>. To make our decision, we considered the following criteria: easy-to-integrate <strong>Continuous Integration </strong>(CI), <strong>frequent releases</strong>, and step-by-step <strong>code review</strong>.</p><h3>Branching strategy</h3><p>Keeping in mind the criteria we just mentioned, here is an <strong>overview of thebranching strategies</strong> we, directly and indirectly, experimented with.</p><h4>Anarchy strategy</h4><p>AKA “no-strategy.” This model empowers each developer to create branches <strong>without following any convention </strong>whatsoever<strong> </strong>with respect to a branch’s duration, name, and content.</p><p><em>Ideally</em>, this enables a quick kickoff and an independent development. But <em>alas</em>, a much more tangible result is that it doesn’t take long for the situation to become <strong>impossible to manage</strong>.</p><p>By adopting this strategy, the team will have to spend time trying to identify the active development branch, on which branch they should develop code, on which branch(es) a specific feature is located, or which branch should be pushed to production.</p><h4>Git Flow</h4><p>For over a year, we used <em>git-flow</em>, which provided us with an <strong>organized</strong>, <strong>methodical</strong>, and <strong>structured </strong>alternative, and a CLI that allowed us to avoid naming convention issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*aPXZJ1SUhjuB8KyCgueWQg.png" /></figure><p>The idea behind <em>git-flow</em> is pretty simple:</p><ul><li>The master branch includes all the tags for all released versions;</li><li>The develop branch is used for ongoing development processes;</li><li>Feature branches are dedicated to the new features that are being developed;</li><li>Release branches are for software versions that are candidates for release;</li><li>Hotfix branches are destined to bug fixes flagged by the production team.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*XpAbI8DN8h25wKmanaTIYA.png" /></figure><p>The biggest problem with <strong>GitFlow</strong> is its <strong>complexity</strong>. The whole development process doesn’t occur on the master branch–i.e. the default branch for many tools–rather on develop, while master is only used to store releases.</p><p>This kind of approach actually prevents developers from <strong>code reviewing</strong>pending<strong> </strong>merge requests (MR) on the master branch–which are required since this branch is protected–as these will include content developed in weeks, if not months. It is, however, possible to send MRs from feature branches to the develop branch. Yet this only depends on the developer’s commitment, because MRs are not required for the develop branch since it is not protected, or at least it is not so by default.</p><p>One of the greatest issues we had was <strong>to correct bugs in versions preceding the latest release</strong>.<strong> </strong>Let’s say we released version 2.X of a software and the client flags us an issue in version 1.Z. The wisest choice would be to go on the master branch and create a support branch for tag 1.Z to fix the bug. But what should we do after the bug fix? From which branch should our fix be released: the support branch, the master branch, or something else? Into what should we merge our fix? Should it be merged in the master branch or perhaps in the develop branch? Or, rather, should we just leave the supportbranch we created forever unmerged?</p><p>The release process in GitFlow can get really tough. Here are the steps involved:</p><ul><li>Use the command git flow release start &lt;VERSION_NUMBER&gt; to create the release branch from develop;</li><li>Update your <strong>codebase</strong> (<strong>changelog</strong>, project version, readme, etc.;)</li><li>Wait for the CI to green-light the creation of an MR on master;</li><li>Merge the release branch into master with the command git flow release finish &lt;VERSION_NUMBER&gt;. Once this step is done, the releasebranch will be merged into master and develop, and a tag will be created for the release commit. After that, we will be redirected to develop;</li><li><strong>push</strong> master, develop, and the tag (note: git push --tags)</li></ul><p>P.S.: First, update the project version on develop for the next iteration, then <strong>push</strong>.</p><p>Sometimes this process can be overkill, and experience has taught me that making a mistake is quite easy.</p><h4>GitHub Flow</h4><p>GitHub Flow relies on a <strong>clean </strong>and <strong>simple</strong> structure, with only 2 kinds of branches: the master branch and the feature branches. A developer creates a branch from the repository on which the new <strong>feature </strong>is developed. Once done, an MR (with code review) is sent to master. To update an MR, you simply need to push content on your branch, and when the MR is ready this will be merged in master. After that, the feature branch is removed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*gr9HebeZzALsZKQ8_Pt1qA.png" /></figure><p>This branching strategy, however, is based on <strong>2 strong assumptions</strong>:</p><ol><li>Developed contents can be pushed to production at any time, which is not always true. For many of our clients, we have a set time frame on a certain date to push a new software version to production.</li><li>Clients always install the last version of our app, so there is no need to <strong>support </strong>and <strong>fix bugs </strong>for older releases. 🤔</li></ol><h4>Gitlab Flow 🚀</h4><p>Starting from GitHub Flow, a new strategy came up, one that provides <strong>a branch for each environment</strong>. Let’s say we have a <strong>staging </strong>environment, a Quality Assurance (<strong>QA</strong>) environment, and a <strong>Prod</strong> environment. Each of them is updated automatically using a CI script pointing to the relevant branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*1bWdU3Wv2Qoi-vQ-CFt2RA.png" /></figure><p>Like this, we can benefit from small and exact MRs to master, which can be subject to code review. When we’re ready, we can push changes to the QA environment (sending MRs from the master to the pre-production branch) and then to the Prod environment (sending MRs from the pre-production to the production branch).<br> Thanks to this workflow, we can rest assured that all commits are tested in all environments.</p><p>Sometimes, there is the need to keep developing multiple versions of a software, in which case <strong>Release Branches </strong>come in handy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*iZhT_0XqYv1aytooZ9nUjA.png" /></figure><p>In this case, each branch corresponds to one version of our software (the image above depicts a <em>minor </em>version.) In order to avoid making <strong>hotfixes</strong> on multiple branches, the creation of the release branch (the <em>stable </em>branch in the picture) is delayed for as long as possible.</p><p>When an anomaly occurs in our software, the fix is made on a featurebranch, which is then merged into the master branch. After that, we cherry-pick the commit on the release branch. This technique, known as<strong> Upstream First</strong>, is used so that the developer doesn’t forget to merge a hotfix into master, preventing the problem from occurring in future releases.</p><h4>Conclusion 🤓</h4><p>One of the principles of <a href="https://leankit.com/learn/lean/lean-methodology/"><strong>Lean</strong></a> that I appreciate the most is continuous improvement, a concept that is perfectly depicted by this anecdote:</p><blockquote>There was once the owner of a big American company, who decided to adopt <strong>Lean</strong>to improve his production line. A couple of months after introducing it, he invited the owner of a Japanese factory–where Lean had been implemented since day one–to visit his factory.<br> On the day of the meeting, the American gave his Japanese guest a tour of his factory, showing him the improvements that had been made thanks to Lean. The Japanese watched but didn’t make any comments.<br> At the end of the tour, the host asked his guest: “What do you think of the way we reorganized our factory by following your guidelines? Have we managed to embrace Lean fully?”<br> The Japanese guest answered: “I do not know that. I was not here yesterday!”</blockquote><p>This is just to say that, starting from CVS, in time we have embraced <strong>git </strong>and <strong>Gitlab Flow</strong>, which currently seems to suit our development cycle well enough. Nonetheless, we are always open to experiment with and potentially adopt any tool or strategy that improves our developers’ team life.</p><h4>References 🔗</h4><ul><li><a href="https://docs.gitlab.com/ee/workflow/gitlab_flow.html">https://docs.gitlab.com/ee/workflow/gitlab_flow.html</a></li><li><a href="https://datasift.github.io/gitflow/IntroducingGitFlow.html">https://datasift.github.io/gitflow/IntroducingGitFlow.html</a></li><li><a href="https://danielkummer.github.io/git-flow-cheatsheet/">https://danielkummer.github.io/git-flow-cheatsheet/</a></li><li>GitLab Flow example: <a href="https://github.com/spring-projects/spring-boot">https://github.com/spring-projects/spring-boot</a></li><li>Upstream first: <a href="https://www.chromium.org/chromium-os/chromiumos-design-docs/upstream-first">https://www.chromium.org/chromium-os/chromiumos-design-docs/upstream-first</a></li></ul><p>— <br><a href="https://twitter.com/teo1690">Matteo Codogno</a>, Technical Leader @<a href="https://www.welld.ch/it/index.html?utm_source=Medium&amp;utm_medium=ContentMarketing&amp;utm_content=Gowiththegit">WellD</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4e71dcb5aff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/go-with-the-git-flow-or-die-debating-en-e4e71dcb5aff">Go with the (git)flow, or die debating — EN</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>