<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/rss.xsl" type="text/xsl" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Docker | Bacardi55&#39;s Web Cave</title>
    <link>https://bacardi55.io/tags/docker/</link>
    <description>Recent content in Docker on Bacardi55&#39;s Web Cave</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>bac@rdi55.pl (bacardi55)</managingEditor>
    <webMaster>bac@rdi55.pl (bacardi55)</webMaster>
    <copyright>2010-2025 bacardi55</copyright>
    <lastBuildDate>Sun, 11 Apr 2021 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://bacardi55.io/tags/docker/index.xml" rel="self" type="application/rss+xml" />
    <item>
      
      <title>Using multiple traefik middlewares using docker labels</title><link>https://bacardi55.io/2021/04/11/using-multiple-traefik-middlewares-using-docker-labels/</link><pubDate>Sun, 11 Apr 2021 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/04/11/using-multiple-traefik-middlewares-using-docker-labels/</guid><description>&lt;p&gt;Quick post today just to highlight how to use multiple middlawares in a traefik configuration. I realized that I haven&amp;rsquo;t posted about it and all example I gave always used 1 middleware to redirect http to https. Today, let&amp;rsquo;s use more :).&lt;/p&gt;&#xA;&lt;p&gt;For this example, I&amp;rsquo;m going to install &lt;a href=&#34;https://github.com/bastienwirtz/homer&#34;&gt;homer&lt;/a&gt; (the very simplistic personal dashboard page). I used to have &lt;a href=&#34;https://heimdall.site&#34;&gt;Heimdall&lt;/a&gt; installed on my cluster before &lt;a href=&#34;https://bacardi55.io/2021/03/07/rca-of-my-homelab-cluster-downtime/&#34;&gt;the crash&lt;/a&gt;, but I never really used it. That&amp;rsquo;s because I thought it was too heavy for my need to be honest.&lt;/p&gt;&#xA;&lt;p&gt;I decided to switch to homer because it is very lightweight and simple&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; but this is not the goal of this post.&lt;/p&gt;&#xA;&lt;p&gt;If I take the previous configuration shown, the &amp;ldquo;default&amp;rdquo; docker-compose would be:&lt;/p&gt;&#xA;&lt;p&gt;Quick post today just to highlight how to use multiple middlawares in a&#xA;traefik configuration. I realized that I haven&amp;rsquo;t posted about it and all&#xA;example I gave always used 1 middleware to redirect http to https.&#xA;Today, let&amp;rsquo;s use more :).&lt;/p&gt;&#xA;&lt;p&gt;For this example, I&amp;rsquo;m going to install &lt;a href=&#34;https://github.com/bastienwirtz/homer&#34;&gt;homer&lt;/a&gt; (the very simplistic&#xA;personal dashboard page). I used to have &lt;a href=&#34;https://heimdall.site&#34;&gt;Heimdall&lt;/a&gt; installed on my cluster before&#xA;&lt;a href=&#34;https://bacardi55.io/2021/03/07/rca-of-my-homelab-cluster-downtime/&#34;&gt;the crash&lt;/a&gt;, but I never really used it. That&amp;rsquo;s because I thought it was too&#xA;heavy for my need to be honest.&lt;/p&gt;&#xA;&lt;p&gt;I decided to switch to homer because it is very lightweight and&#xA;simple&lt;sup id=&#34;fnref1:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; but this is not the goal of this post.&lt;/p&gt;&#xA;&lt;p&gt;If I take the previous configuration shown, the &amp;ldquo;default&amp;rdquo; docker-compose&#xA;would be:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#34;3&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      homer:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: b4bz/homer&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - traefik-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        environment:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - PUID=1000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - PGID=1000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/containers-data/homer/data:/www/assets&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          labels:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.enable=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.services.dashboard-service.loadbalancer.server.port=8080&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard.rule=Host(`homer.domain.tld`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard.entrypoints=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # For https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.rule=Host(`homer.domain.tld`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.entrypoints=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.tls.certresolver=le&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.dashboard-redirect-dashboard-secure.redirectscheme.scheme=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard.middlewares=dashboard-redirect-dashboard-secure&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == worker&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      traefik-net:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        external: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But this only use one middle. To use multiple ones, we need to use a&#xA;middleware chain instead of just a declared middleware.&lt;/p&gt;&#xA;&lt;p&gt;In this example, I&amp;rsquo;m just going to add a basic http authentication. But&#xA;this works the same if you added more like rate limiting and such.&lt;/p&gt;&#xA;&lt;p&gt;Before editing the docker-compose file, we need to generate a&#xA;user/password for the basic auth. Obviously, it is better to use a file&#xA;to manage the credential (if you have more than one user at least), but&#xA;for the sake of example, it is simpler that way.&lt;/p&gt;&#xA;&lt;p&gt;To create the user/password information, use this command line (from the&#xA;traefik documentation). You need &lt;code&gt;apache2-utils&lt;/code&gt; for the &lt;code&gt;htpasswd&lt;/code&gt;&#xA;command on debian like distribution.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    echo &lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;htpasswd -nb user password&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt; | sed -e s/&lt;span style=&#34;color:#ae81ff&#34;&gt;\\&lt;/span&gt;$/&lt;span style=&#34;color:#ae81ff&#34;&gt;\\&lt;/span&gt;$&lt;span style=&#34;color:#ae81ff&#34;&gt;\\&lt;/span&gt;$/g&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The sed part is to double the &lt;code&gt;$&lt;/code&gt; sign as traefik needs it.&lt;/p&gt;&#xA;&lt;p&gt;Then, edit the deploy part of the docker-compose file like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          labels:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.enable=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.services.dashboard-service.loadbalancer.server.port=8080&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard.rule=Host(`homer.domain.tld`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard.entrypoints=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # For https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.rule=Host(`homer.domain.tld`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.entrypoints=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.tls.certresolver=le&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.dashboard-redirect-dashboard-secure.redirectscheme.scheme=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # We don&amp;#39;t declare just a middleware here.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            #- traefik.http.routers.dashboard.middlewares=dashboard-redirect-dashboard-secure&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # HTTP auth:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # This is were you need to paste the result of the command above:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - &amp;#34;traefik.http.middlewares.dashboard-auth.basicauth.users=&amp;lt;user&amp;gt;:&amp;lt;GeneratedPasswordAbove&amp;gt;&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Declaring the middleware chain:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.dashboard-secure.middlewares=secured&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Add all middlewares in the chain:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.secured.chain.middlewares=dashboard-redirect-dashboard-secure,dashboard-auth&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you need to add more, just add to the chain middlewares last line all&#xA;the middlewares needed.&lt;/p&gt;&#xA;&lt;p&gt;And voilà! As said, very short example of using a chain middlewares :).&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;And if I&amp;rsquo;m not mistaken, the main developer is someone I used to&#xA;work with and appreciate^^.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref1:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>Managing your gemini feeds with Comitium and docker</title><link>https://bacardi55.io/2021/04/08/managing-your-gemini-feeds-with-comitium-and-docker/</link><pubDate>Thu, 08 Apr 2021 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/04/08/managing-your-gemini-feeds-with-comitium-and-docker/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;If you read this blog before, you know that I&amp;rsquo;ve become a big fan of the&#xA;&lt;a href=&#34;https://gemini.circumlunar.space/&#34;&gt;gemini space&lt;/a&gt; and that I do run&#xA;&lt;a href=&#34;&#34;&gt;a capsule&lt;/a&gt; with specific content on there&#xA;:). I&amp;rsquo;ve been enjoying reading many gemlog over the past months and the&#xA;list is growing :).&lt;/p&gt;&#xA;&lt;p&gt;As for the web, following every capsules is hard to do &amp;ldquo;manually&amp;rdquo; and as&#xA;for the web, having a feed reader is very useful :). Until now, I have&#xA;been using the built-in capability of&#xA;&lt;a href=&#34;https://github.com/makeworld-the-better-one/amfora&#34;&gt;amfora gemini&#xA;browser&lt;/a&gt; to subscribe to feeds and it has worked flawlessly (I love&#xA;this browser :)). But the issue I have with it is that it is link to my&#xA;laptop and the local installation of amfora. If I browse the gemini&#xA;space on my phone, I still need to see what&amp;rsquo;s new in the capsule I&#xA;follow. I won&amp;rsquo;t write more about this, this is the same idea of having a&#xA;web rss feed like &lt;a href=&#34;https://www.freshrss.org&#34;&gt;freshrss&lt;/a&gt; or&#xA;&lt;a href=&#34;https://miniflux.app/&#34;&gt;miniflux&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I won&amp;rsquo;t talk about how much I love following gemlogs at the moment and&#xA;how it reminds me of the early days of following bloggers online as it&#xA;will be the goal of a dedicated gemlog post^^.&lt;/p&gt;&#xA;&lt;p&gt;There are multiple feed readers for gemini, like&#xA;&lt;a href=&#34;https://sr.ht/~sircmpwn/gemreader/&#34;&gt;Gemreader&lt;/a&gt;,&#xA;&lt;a href=&#34;https://sr.ht/~callum/gmisub/&#34;&gt;Gmisub&lt;/a&gt;,&#xA;&lt;a href=&#34;https://github.com/kensanata/moku-pona&#34;&gt;Moku-Pona&lt;/a&gt;,&#xA;&lt;a href=&#34;https://git.nytpu.com/comitium/about/&#34;&gt;comitium&lt;/a&gt;, and probably&#xA;others&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;I selected comitium in the end, as it seemed very simple to install and&#xA;manage. And it does exactly what I need :]. So far, it has worked for a&#xA;couple of days quite nicely :).&lt;/p&gt;&#xA;&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;&#xA;&lt;p&gt;So first thing first, as you know, I manage everything in docker in my&#xA;self hosted environment. As always, I&amp;rsquo;m not saying this is the right way&#xA;of doing it, just a way I enjoy ^^.&lt;/p&gt;&#xA;&lt;p&gt;Anyway, no need to deploy a swarm stack for comitium, I just need to run&#xA;it every X hours to refresh the feeds. I could have installed comitium&#xA;on one of the node, but I didn&amp;rsquo;t want to install go locally on the host.&#xA;So let&amp;rsquo;s use a very simple image to create the gmi files. Comitium will&#xA;generate files to deploy to your gemini server. More on that later.&lt;/p&gt;&#xA;&lt;h3 id=&#34;image-creation&#34;&gt;Image Creation&lt;/h3&gt;&#xA;&lt;p&gt;No public image yet to reuse, but as you know I like having my own built&#xA;images. I have my &amp;ldquo;preprod&amp;rdquo; rpi with my local registry on it as&#xA;explained&#xA;&lt;a href=&#34;https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This is an example of an extremely simple Dockerfile:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    FROM golang:1.15&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    RUN \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       git clone https://git.sr.ht/~sircmpwn/scdoc &amp;amp;&amp;amp; cd scdoc &amp;amp;&amp;amp; \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       make &amp;amp;&amp;amp; make install &amp;amp;&amp;amp; cd ..&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    RUN \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       git clone https://git.nytpu.com/comitium &amp;amp;&amp;amp; cd comitium &amp;amp;&amp;amp; \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       make &amp;amp;&amp;amp; make install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;No entrypoint or command as we will have to use different commands&#xA;(add/remove/refresh).&lt;/p&gt;&#xA;&lt;p&gt;Then, build the image:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build .&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If it works, you can tag the image:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build . -t registry.local:5000/b55-comitium:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, you can do a test run:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker run -it --rm -v /home/pi/testdir/comitium/data/:/data registry.local:5000/b55-comitium:latest comitium add &amp;lt;GeminiFeedUrl&amp;gt; -d /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It should generate files in the data directory (&lt;code&gt;feeds.gmi&lt;/code&gt;,&#xA;&lt;code&gt;subscriptions.gmi&lt;/code&gt;, &lt;code&gt;comitium.json&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;h3 id=&#34;usage-on-the-cluster&#34;&gt;Usage on the cluster&lt;/h3&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s deploy it on the cluster. Ssh to one of the node and:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull registry.local:5000/b55-comitium:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Should pull the image from the registry. Adapt to your url/port.&lt;/p&gt;&#xA;&lt;p&gt;Create the data where the files needs to be generated. It could be in a&#xA;directory of your servers or anywhere. In my case, I prefer generating&#xA;it in a dedicated directory and then &lt;code&gt;rsync&lt;/code&gt; it in the right directory&#xA;for the server.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir /path/to/comitium/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then you can add a feed to test. Same command as on &lt;code&gt;freeza&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker run -it --rm -v /path/to/comitium/data/:/data registry.local:5000/b55-comitium:latest comitium add &amp;lt;GeminiFeedUrl&amp;gt; -d /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It should generate the files as said above.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: You can customize the header of the page by providing a&#xA;&lt;code&gt;header.gmi&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;In my case, I simply use a &lt;code&gt;header.gmi&lt;/code&gt; file containing (with the empty&#xA;line at the end):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    # Bacardi55&amp;#39;s gemini feed subscriptions&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    =&amp;gt; https://git.nytpu.com/comitium/ This page is generated with comitium&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To refresh the data, this command could be used:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker run -it --rm -v /path/to/comitium/data/:/data registry.local:5000/b55-comitium:latest comitium refresh -d /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, because I make comitium create this files not in the server&#xA;directory, I need to &lt;code&gt;rsync&lt;/code&gt; the files to the right directory:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    rsync -avzhP /path/to/comitium/data/ /path/to/server/feed/data/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, what I&amp;rsquo;d like is running comitium on its own hostname, not inside&#xA;my current capsule. In my case, I run it publicly on&#xA;&lt;code&gt;gemini://feeds.gmi.bacardi55.io&lt;/code&gt;. You can have a look at it if you&#xA;want. So I need to copy the &lt;code&gt;feeds.gmi&lt;/code&gt; file as an &lt;code&gt;index.gmi&lt;/code&gt; file so&#xA;it is delivered automatically by the server.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    cp /path/to/server/feed/data/feeds.gmi /path/to/server/feed/data/index.gmi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now that&amp;rsquo;s cool, but adding and removing feeds with the long docker&#xA;command, the cp and then running rsync is quite boring&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;To simplify this, I created 2 bash functions in my &lt;code&gt;bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    comitium-add&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      docker run --rm -v /path/to/comitium/data/:/data registry.local:5000/b55-comitium:latest comitium add &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$1&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; -d /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      rsync -avzhP /path/to/comitium/data/ /path/to/server/feed/data/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      cp /path/to/server/feed/data/feed.gmi /path/to/server/feed/data/index.gmi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    comitium-remove&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      docker run --rm -v /path/to/comitium/data/:/data registry.local:5000/b55-comitium:latest comitium remove &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$1&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; -d /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      rsync -avzhP /path/to/comitium/data/ /path/to/server/feed/data/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      cp /path/to/server/feed/data/feed.gmi /path/to/server/feed/data/index.gmi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And now, simply running &lt;code&gt;comitium-add &amp;lt;FeedUrl&amp;gt;&lt;/code&gt; and&#xA;&lt;code&gt;comitium-remove &amp;lt;FeedUrl&amp;gt;&lt;/code&gt; to manage feeds.&lt;/p&gt;&#xA;&lt;p&gt;Now, that&amp;rsquo;s great but what we need to finish the setup is a cronjob to&#xA;refresh the feeds. The simpler is instead of a bash function create a&#xA;simple shell script that will do the necessary commands. Create the&#xA;&lt;code&gt;comitium-refresh.sh&lt;/code&gt; file with the following content:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;#!/bin/bash&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker run --rm -v /path/to/comitium/data/:/data registry.local:5000/b55-comitium:latest comitium refresh -d /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    rsync -avzhP /path/to/comitium/data/ /path/to/server/feed/data/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    cp /path/to/server/feed/data/feed.gmi /path/to/server/feed/data/index.gmi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make it executable:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    chmod +x /path/to/comitium-refresh.sh&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then &lt;code&gt;crontab -e&lt;/code&gt; to add the job:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    30 */6 * * * /path/to/comitium-refresh.sh &amp;gt; /tmp/cr.log 2&amp;gt;&amp;amp;1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And that should be it. Yes, I only update it every 6 hours, that is&#xA;enough for me.&lt;/p&gt;&#xA;&lt;p&gt;Configure your server to run the files as wished. In my case, I just&#xA;added a second hostname in&#xA;&lt;a href=&#34;https://git.sr.ht/~sircmpwn/gmnisrv&#34;&gt;gmnisrv&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    [gmi.bacardi55.io]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    root=/data/gmi.bacardi55.io&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    [feeds.gmi.bacardi55.io]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    root=/data/feeds.gmi.bacardi55.io&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And that should be it (:.&lt;/p&gt;&#xA;</description></item>
    <item>
      
      <title>Moving gmnisrv to my swarm cluster</title><link>https://bacardi55.io/2021/04/04/moving-gmnisrv-to-my-swarm-cluster/</link><pubDate>Sun, 04 Apr 2021 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/04/04/moving-gmnisrv-to-my-swarm-cluster/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Based on my previous post about&#xA;&lt;a href=&#34;https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/&#34;&gt;managing&#xA;a local docker registry&lt;/a&gt;, as promised let&amp;rsquo;s use it to create a useful&#xA;image and deploy it on &lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;my swarm&#xA;cluster homelab&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For this example, I&amp;rsquo;ve decided to use the latest image I&amp;rsquo;ve created:&#xA;&lt;a href=&#34;https://git.sr.ht/~sircmpwn/gmnisrv&#34;&gt;gmnisrv&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Wait what? Gmnisrv running on a docker swarm? Why??&lt;/p&gt;&#xA;&lt;p&gt;There are no real good reason to have the gemini server as a docker&#xA;service&amp;hellip; So why? Well the real reasons? Because: - I can :p; - I have&#xA;this docker swarm working very smoothly, so let&amp;rsquo;s use it; - I could have&#xA;just installed it directly on one of the node, but that made not much&#xA;sens; - I can manage it as all the other services^^.&lt;/p&gt;&#xA;&lt;p&gt;Last week, I made the change from the local installation on a test pi to&#xA;the cluster, smoothly from what I&amp;rsquo;ve seen, without certificate change.&#xA;But that&amp;rsquo;s not the point of this article^^ (and TBH, I failed&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; the&#xA;weekend before :D).&lt;/p&gt;&#xA;&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;&#xA;&lt;h3 id=&#34;creating-the-image-for-the-cluster&#34;&gt;Creating the image for the cluster&lt;/h3&gt;&#xA;&lt;p&gt;So first thing first, we need to create the image on the registry before&#xA;being able to use it on the cluster. Feel free to refer to my post about&#xA;&lt;a href=&#34;https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/&#34;&gt;managing&#xA;a local docker registry&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On the registry (in my case named &lt;code&gt;freeza&lt;/code&gt;), let&amp;rsquo;s create the image.&#xA;Let&amp;rsquo;s create a working directory:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir ~/dockerfiles/gmnisrv &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; cd ~/dockerfiles/gmnisrv&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, create the very simple &lt;code&gt;Dockerfile&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    FROM alpine:3.12&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    RUN apk add --no-cache git make scdoc openssl-dev build-base mailcap &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        cd /tmp &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        git clone https://git.sr.ht/~sircmpwn/gmnisrv &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        cd gmnisrv &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        mkdir build &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        cd build &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        ../configure --prefix&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;/usr &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        make &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        make install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    CMD &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;gmnisrv&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-C&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/config/gmnisrv.ini&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Very simple :-).&lt;/p&gt;&#xA;&lt;p&gt;Then, let&amp;rsquo;s try and build the image:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build .&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If this works correctly, you can tag the image (I always prefix their&#xA;name with &lt;code&gt;b55-&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build . -t registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Adapt with your registry hostname and port.&lt;/p&gt;&#xA;&lt;p&gt;Push the image to the directory:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker push registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To test the image, you can either use &lt;code&gt;docker run&lt;/code&gt; or &lt;code&gt;docker-compose&lt;/code&gt;.&#xA;Because I&amp;rsquo;m will use a docker-compose file on my cluster, I prefer&#xA;testing it with a docker-compose file, buit this doesn&amp;rsquo;t matter.&lt;/p&gt;&#xA;&lt;p&gt;In my case, the local docker-compose.yml file is:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gmnisrv:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 1965:1965&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/testdir/gmnisrv/data/:/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/testdir/gmnisrv/config/:/config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/testdir/gmnisrv/certs:/certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then the usual &lt;code&gt;docker-compose up&lt;/code&gt; to see if this works correctly (be&#xA;sure to create the volumes if you want to try with it).&lt;/p&gt;&#xA;&lt;p&gt;If you want to run a full test before deploying on your cluster, you can&#xA;create a simple .gmi file in the &lt;em&gt;data&lt;/em&gt; directory, create a dev host in&#xA;the gmnisrv config file (and edit your host file).&lt;/p&gt;&#xA;&lt;h3 id=&#34;deploying-it-to-the-cluster&#34;&gt;Deploying it to the cluster&lt;/h3&gt;&#xA;&lt;p&gt;If everything work, we can use it on the cluster. Adapt a bit the docker&#xA;file to have:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      server:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;1965:1965&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.hostname == ptitcell2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/containers-data/gmnisrv/data/:/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/containers-data/gmnisrv/certs/:/certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/services-config/gmnisrv/config/:/config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Main difference the placement constraints to a specific node of the&#xA;cluster. I could have use &lt;a href=&#34;https://traefik.io/traefik/&#34;&gt;traefik&lt;/a&gt; for&#xA;load balancing the entry like I do for all services&amp;hellip; But I didn&amp;rsquo;t^^. I&#xA;didn&amp;rsquo;t see the point of adding load to traefik and the node manager for&#xA;gmnisrv that works on a port that will only be used by gmnisrv. Gmnisrv&#xA;support multi hosts anyway if I want to add capsules in the future (I&amp;rsquo;m&#xA;planing to have a feed type of capsule).&lt;/p&gt;&#xA;&lt;p&gt;So, long story short, I force the container to only work on the&#xA;&lt;code&gt;ptitcell2&lt;/code&gt; node. And I forward the 1965 port on my router to the&#xA;&lt;code&gt;ptitcell2&lt;/code&gt; node. I thus save a bit on the manager.&lt;/p&gt;&#xA;&lt;p&gt;If you don&amp;rsquo;t care by recreating new certs (if your capsule wasn&amp;rsquo;t live&#xA;yet), you can just start it like this, otherwise just copy/paste the&#xA;certificates in the right folder before starting the stack with&#xA;&lt;code&gt;docker stack deploy gmnisrv -c /path/to/services-config/gmnisrv/docker-compose.yml&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And voilà :] Granted that I have close to no reader on my capsule, I can&#xA;still say it has worked perfectly since then!&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;In reality I failed for multiple reasons, but also discovered a&#xA;bug in the latest version of gmnisrv. I fixed it with the help of&#xA;&lt;a href=&#34;https://drewdevault.com&#34;&gt;Drew Devault&lt;/a&gt;. Since then my patch&#xA;has been accepted so even if what I wrote was the&#xA;&lt;a href=&#34;https://git.sr.ht/~sircmpwn/gmnisrv/commit/8b65e303b01fc573cb1c40a365fb5db166146a37&#34;&gt;simplest&#xA;patch&lt;/a&gt; in the history of patch, I&amp;rsquo;m still happy about it^^.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>Home Lab part 8: Create a local docker registry to manage your own images</title><link>https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/</link><pubDate>Mon, 29 Mar 2021 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/</guid><description>&lt;h2 id=&#34;why-a-local-registry&#34;&gt;Why a local registry?&lt;/h2&gt;&#xA;&lt;p&gt;This is a good question and there are many answers to this. But for me&#xA;the main reasons is that I like be &amp;ldquo;in control&amp;rdquo; of some of the&#xA;containers I&amp;rsquo;m running. I don&amp;rsquo;t create my own images for everything at&#xA;all, but I do use a mix of both. For very well known applications like&#xA;traefik, nginx, mariadb, postgresql, &amp;hellip; I usually use public images.&#xA;Sometimes, for specific services/applications I either don&amp;rsquo;t find an&#xA;offical arm images (Needed for rpi), or sometimes I may not like how&#xA;these official images are built.&lt;/p&gt;&#xA;&lt;p&gt;As I said many times in previous post, you should always be very aware&#xA;of how the containers you use are built and configured. And when in&#xA;doubt or need, build your own and keep the whole thing under control&#xA;:-). I use only public images in my posts mainly for simplicity (and&#xA;because I don&amp;rsquo;t publish my images outside my private registry).&lt;/p&gt;&#xA;&lt;p&gt;In this post, I&amp;rsquo;ll explain how to setup a registry on my local network&#xA;for reuse on my cluster. In the next one, I&amp;rsquo;ll show a real use case I&amp;rsquo;m&#xA;using. In a later post, I&amp;rsquo;ll talk about automation around image&#xA;creation.&lt;/p&gt;&#xA;&lt;h2 id=&#34;creating-a-local-docker-registry&#34;&gt;Creating a local docker registry&lt;/h2&gt;&#xA;&lt;h3 id=&#34;my-choices&#34;&gt;My choices&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Only available on my local network, which is why:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I won&amp;rsquo;t add (for now at least) HTTP authentication;&lt;/li&gt;&#xA;&lt;li&gt;I use a self-signed certificate (and not letsencrypt or others);&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Setup on a dedicated &amp;ldquo;non prod&amp;rdquo; raspberry pi (named &lt;code&gt;freeza&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Only ARM containers (not multi architecture&amp;hellip; yet).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Assumptions&lt;/strong&gt;: This article assume you already have a server setup with&#xA;docker installed. And in my case, on a rpi not in the swarm cluster.&lt;/p&gt;&#xA;&lt;h3 id=&#34;creating-the-registry&#34;&gt;Creating the registry&lt;/h3&gt;&#xA;&lt;p&gt;First, add your domain to &lt;code&gt;/etc/host&lt;/code&gt; if you are using a fake domain&#xA;(and no local dns server). In this example, I&amp;rsquo;m using &lt;code&gt;registry.local&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then create the working directory, here I named it &lt;code&gt;docker-registry&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir docker-registry &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; cd docker-registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create the &lt;code&gt;docker-compose.yml&lt;/code&gt; file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      registry55:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        restart: always&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: registry:2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;5000:5000&amp;#34; # ChangeMe&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        environment:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.local.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - REGISTRY_HTTP_TLS_KEY=/certs/registry.local.key&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - ./registry:/var/lib/registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - ./registry-config/config.yml:/etc/docker/registry/config.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - ./certs:/certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - registry-ui-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Configure the registry by creating the &lt;code&gt;registry-config/config.yml&lt;/code&gt;&#xA;file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: 0.1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    log:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fields:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        service: registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    storage:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      delete:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        enabled: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      cache:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        blobdescriptor: inmemory&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      filesystem:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        rootdirectory: /var/lib/registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    http:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      addr: :5000 # ChangeMe&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      headers:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        X-Content-Type-Options: [nosniff]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Changed the port if you wish.&lt;/p&gt;&#xA;&lt;p&gt;Then, create the directory for the certiticats and the registry:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;certs,registry&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For other servers to leverage your local registry, it needs to work via&#xA;HTTPS, so we need to create the certificate:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/registry.local.key -x509 -days &lt;span style=&#34;color:#ae81ff&#34;&gt;365&lt;/span&gt; -out certs/registry.local.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the FQDN, use the domain set above in the &lt;code&gt;docker-compose.yml&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h4 id=&#34;testing&#34;&gt;Testing&lt;/h4&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s test with a simple alpine image. We&amp;rsquo;ll see in the next post a real&#xA;use case.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull alpine:3.13&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s tag the image now. When the first part of the tag is a hostname&#xA;and port, Docker interprets this as the location of a registry, when&#xA;pushing.&lt;/p&gt;&#xA;&lt;p&gt;For my local images, I always start their name with &lt;code&gt;b55-&lt;/code&gt;, but this is&#xA;just my own convention :).&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker tag alpine:3.13 registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Push the image to the local registry running at &lt;code&gt;registry.local:5000&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker push registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Remove the locally-cached alpine image, so that you can test pulling the&#xA;image from your registry. This does not remove the registry.local:5000/&#xA;image from your registry.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker image remove alpine:3.13&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker image remove registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then pull the image from the registry to see if it&amp;rsquo;s working.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It should pull the image :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;using-images-from-the-local-registry-on-others-servers&#34;&gt;Using images from the local registry on others servers&lt;/h3&gt;&#xA;&lt;p&gt;Now, to pull images from the registry on others servers, we will need to&#xA;add the certificate to these servers. This is because we are using a&#xA;self-signed certificate. But to be honest, for a local service, I don&amp;rsquo;t&#xA;see the point of the hassle of getting one from letsencrypt or others.&lt;/p&gt;&#xA;&lt;p&gt;We just need to add the certificate to the docker configuration.&lt;/p&gt;&#xA;&lt;p&gt;To do so, copy the created crt file above to the other servers that will&#xA;need it (via &lt;code&gt;scp&lt;/code&gt; for example). Place the file in&#xA;&lt;code&gt;/etc/docker/certs.d/registry.local:5000&lt;/code&gt;. Adapt with the right hostname&#xA;and ports.&lt;/p&gt;&#xA;&lt;p&gt;Be Careful, the files needs to be named &lt;code&gt;ca.crt&lt;/code&gt;!&lt;/p&gt;&#xA;&lt;p&gt;You may need to create the &lt;code&gt;certs.d&lt;/code&gt; directory if it doesn&amp;rsquo;t exist yet.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir -p /etc/docker/certs.d/registry.local:5000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    scp user@server:/path/to/registry.local.crt /etc/docker/certs.d/registry.local:5000/ca.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You now need to restart docker:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo systemctl restart docker.service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: You need to add the certificate to all your docker swarm nodes.&#xA;As any of the nodes could need to pull one of the local registry&#xA;images&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, you can try pulling the image, with as usual:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And it should pull the image :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;registry-ui&#34;&gt;Registry UI?&lt;/h3&gt;&#xA;&lt;p&gt;There are many docker registry web UI available. Seems that the most&#xA;maintained and popular one is&#xA;&lt;a href=&#34;https://github.com/Joxit/docker-registry-ui&#34;&gt;Joxit&amp;rsquo;s one&lt;/a&gt;. I let you&#xA;test it because on my end I don&amp;rsquo;t care about a web UI for my registry,&#xA;and instead I prefer a CLI app:&#xA;&lt;a href=&#34;https://github.com/Joxit/docker-registry-ui&#34;&gt;reg&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Reg is very nice and light. I installed it on my laptop but I could have&#xA;installed it directly on the rpi managing the registry. I might do it to&#xA;so I always have it where the registry is. But in the meantime, the&#xA;installation was very fast. Just download the right release and make the&#xA;binary executable (and available in your &lt;code&gt;$PATH&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Only drawback of using reg is that there is no way of ignoring TLS&#xA;validation, so when using a self-signed tls certificate like me, it&#xA;means you need to add the certificate to your system configuration. So&#xA;on the machine you are using reg, you need to add the crt file in&#xA;&lt;code&gt;/usr/share/ca-certificates/&lt;/code&gt; and then run (as root or sudo)&#xA;&lt;code&gt;update-ca-certificates&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then a simple &lt;code&gt;reg ls registry.local:5000&lt;/code&gt; will list the available&#xA;images. &lt;code&gt;reg -h&lt;/code&gt; to see all available commands, and voilà!&lt;/p&gt;&#xA;&lt;p&gt;In the next post, I&amp;rsquo;ll show some useful example and usage on the cluster&#xA;:).&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;This is the villain before &lt;code&gt;cell&lt;/code&gt; in the manga Dragon Ball.&#xA;Because my cluster nodes are named cell (manager) and ptitcellX&#xA;(workers), I decided to named the preprod node with the name of&#xA;the previous villain&amp;hellip;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;As always, &lt;code&gt;tmux&lt;/code&gt; and its &lt;code&gt;synchronize-panes&lt;/code&gt; is really helpful&#xA;:).&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>RCA of my homelab cluster downtime</title><link>https://bacardi55.io/2021/03/07/rca-of-my-homelab-cluster-downtime/</link><pubDate>Sun, 07 Mar 2021 00:00:00 +0100</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/03/07/rca-of-my-homelab-cluster-downtime/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;For the few readers of this blog, or my flew follower on Mastodon, you&#xA;may have saw a very long downtime for this blog last week (and other&#xA;services less visible).&lt;/p&gt;&#xA;&lt;p&gt;Indeed, my cluster was down from last Tuesday morning (±8am from what I&#xA;could saw from logs and my&#xA;&lt;a href=&#34;https://bacardi55.io/2020/04/28/my-home-lab-2020-part-5-external-application-status-with-statping/&#34;&gt;statping&#xA;dashboard&lt;/a&gt;). And it was down until sometime in the middle of the night&#xA;between Friday and Saturday (I think around 2am).&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-issue&#34;&gt;The issue&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;TLDR;&lt;/strong&gt; the memory card of the manager node of the cluster died&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Ok, a little more details:&lt;/p&gt;&#xA;&lt;p&gt;So on tuesday morning, seeing the alert from statping, I did a quick&#xA;check to load the blog locally. It was not working&amp;hellip; Ok I thoughts,&#xA;what are the status of all worker nodes (As the blog container is placed&#xA;only on workers)?&lt;/p&gt;&#xA;&lt;p&gt;All worker nodes seemed ok, having some containers running well on them.&#xA;Hmm, maybe the traefic containers was down on the manager? Trying&#xA;connecting via ssh to my manager (&lt;code&gt;cell&lt;/code&gt;) took a long time for some&#xA;reasons&amp;hellip; I was connected quickly but the prompt took forever to get&#xA;displayed.&lt;/p&gt;&#xA;&lt;p&gt;Looking at the logs, a shit tone of errors in there, I understood that&#xA;something was more wrong than usual&amp;hellip; Being already time to start&#xA;working, I had to do something fast. At this point I thought a quick&#xA;reboot would fix this and that I would have time to investigate later.&#xA;Well that didn&amp;rsquo;t go as planned.&lt;/p&gt;&#xA;&lt;p&gt;A reboot later, I ssh to &lt;code&gt;cell&lt;/code&gt; again, and, first it took a long time&#xA;for the node to be accessible again, and two, it took as long as before&#xA;the reboot to get back a prompt to work on&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Looking at the services running (&lt;code&gt;docker services ls&lt;/code&gt;), I saw that all&#xA;containers that needed to run on workers nodes were working, but no&#xA;containers was running on the manager (too bad when the manager needs to&#xA;handle the entry connection through traefic for all web services^^).&lt;/p&gt;&#xA;&lt;p&gt;I tried running some commands but quickly realized that the system was&#xA;in read-only&amp;hellip; Well, that explains that nothing run correctly here&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Knowing the classic issue of microSD card sometime failing, I stopped&#xA;the manager, removed the card and tried running fsck on it. I didn&amp;rsquo;t&#xA;save the results of fsck, but basically failed. I tried dd the image&#xA;from the card to my laptop but dd also crashed with some errors&amp;hellip; Ok,&#xA;this is bad I thought&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Thanks to &lt;a href=&#34;https://social.nah.re/@alex&#34;&gt;Alex&lt;/a&gt; advices on IRC, I tried&#xA;&lt;a href=&#34;https://doc.ubuntu-fr.org/ddrescue&#34;&gt;ddrescue&lt;/a&gt; to save the data. I&#xA;started it Tuesday at lunch time hoping to save it.&lt;/p&gt;&#xA;&lt;p&gt;Now, in the end, what did I want to save? All data are stored on my NAS&#xA;and mounted via SSHFS as&#xA;&lt;a href=&#34;https://bacardi55.io/2021/02/04/moving-away-from-glusterfs-to-a-shared-folder-mounted-via-sshfs-for-my-cluster-storage/&#34;&gt;explained&#xA;here&lt;/a&gt; so in reality, it was mainly to save the system to avoid&#xA;reinstalling a new node manager.&lt;/p&gt;&#xA;&lt;p&gt;Well, it didn&amp;rsquo;t go as planned and thus the long downtime&amp;hellip; But more on&#xA;this later.&lt;/p&gt;&#xA;&lt;p&gt;So, I ran ddrescue for quite some time! At first at I was optimistic and&#xA;based on IRC logs this was the progress:&#xA;&lt;code&gt;IRC logs run time: 1h50 - read errors 14 run time: 6h45 - pct rescued: 86% run time: 8h15 - pct rescued: 95,17% # (400+ errors at this point) # At this point, it started the second pass to try accessing data run time: 10h20 - pct rescued: 98,04% run time: 12h - pct rescued 98,27%&lt;/code&gt;&#xA;Was more than 2 am at this point so I went to sleep&amp;hellip; In the morning, I&#xA;check and it was still around 98.39%, 5th passed. Seemed that ±400MB (on&#xA;a 32GB card) couldn&amp;rsquo;t be retrieved&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Well, lost for lost, I still tried mounting the generated image. And it&#xA;worked and everything seemed there&amp;hellip; I was not much confident but still&#xA;copied the generated image with dd on a new card I had laying around,&#xA;put it in the raspberry pi and booted it crossing most my fingers (not&#xA;easy to type with crossed fingers btw :p).&lt;/p&gt;&#xA;&lt;p&gt;And&amp;hellip; The pi booted and I could ssh it! I didn&amp;rsquo;t believe at first, but&#xA;the system was running, and not in read only! And was responding fast!&#xA;In a parallel dimension, most probably an alternative version of me&#xA;started to dance&amp;hellip; Maybe^^.&lt;/p&gt;&#xA;&lt;p&gt;Anyway, so I was on the system that seems to work, so first thing, I&#xA;checked if containers were running&amp;hellip; But as before the issue, nothing&#xA;was running on the manager. I tried manually starting simple containers&#xA;on the manager, with or without swarm, but I couldn&amp;rsquo;t make it work. I&#xA;did insist a bit and fix part of it but after 1h of having something not&#xA;really working (but a bit more than 1h ago!), I decided to stop. To be&#xA;honest, it was more a game of finding what happened and if I could fix&#xA;it. But in reality, I couldn&amp;rsquo;t trust the system anymore being corrupted&#xA;with data lost.&lt;/p&gt;&#xA;&lt;p&gt;So this is at that point that I faced reality: I needed to reinstall&#xA;completely at least the manager node. Did it took me the whole week to&#xA;fix it? Not at all, just priority management.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-to-do&#34;&gt;What to do?&lt;/h2&gt;&#xA;&lt;p&gt;At that point, I had in mind the following choices: - Promote a worker&#xA;as a node manager. I wasn&amp;rsquo;t 100% if doable while the main manager was&#xA;down to be honest and didn&amp;rsquo;t check because I didn&amp;rsquo;t want to go that&#xA;road - Reinstall quickly the manager. I wasn&amp;rsquo;t 100% sure either if I&#xA;could reinstall the pi as is. I would probably have needed to reinit a&#xA;new swarm cluster anyway. I didn&amp;rsquo;t go that road either - Reinstall and&#xA;improve&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;As a good nerd, I decided to leverage this as an opportunity to improve&#xA;the cluster. What did I do? I bought a new pi4 to replace the pi2 that&#xA;was way to weak anyway, most swarm services containers were configured&#xA;to not used the pi2. I also changed the &amp;ldquo;cluster rack&amp;rdquo;. The old one was&#xA;failing a bit (I did purchase a cheap one the first time I admit) so I&#xA;thought why not.&lt;/p&gt;&#xA;&lt;p&gt;I decided not to fix anything until the week end when I could do all in&#xA;one (change cluster rack, replace pi2 with pi4) and as well reinstall&#xA;all the pi anyway after checking the integrity of their microSD card.&lt;/p&gt;&#xA;&lt;h2 id=&#34;friday-night-cluster-clinic&#34;&gt;Friday Night Cluster Clinic&lt;/h2&gt;&#xA;&lt;p&gt;So on Friday, after receiving the new cluster box, the new pi and a&#xA;couple of new microSD card, I started the operation &amp;ldquo;Cluster revival&amp;rdquo;!&lt;/p&gt;&#xA;&lt;h3 id=&#34;the-plan&#34;&gt;The plan&lt;/h3&gt;&#xA;&lt;p&gt;The plan was very easy:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Install new hardware (new cluster with new pi). This basically took&#xA;me the most time!&lt;/li&gt;&#xA;&lt;li&gt;Check all SD cards with fsck (fixed a couple of errors on 1 other&#xA;card);&lt;/li&gt;&#xA;&lt;li&gt;Reinstall latest debian on all SD Card (including hostname, hosts and&#xA;ssh);&lt;/li&gt;&#xA;&lt;li&gt;Start all pis, check and fix if needed IP addresses given by my&#xA;router. Had to change the mac address of the old pi2 to the new pi4&#xA;to get the same IP for new node;&lt;/li&gt;&#xA;&lt;li&gt;System updates (and remove MS VsCode repo&amp;hellip;) and basic install (vim,&#xA;tmux, htop, docker, docker-compose, sshfs, &amp;hellip;)&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Mount files from NAS (containers config and data);&lt;/li&gt;&#xA;&lt;li&gt;Recreate and configure swarm cluster;&lt;/li&gt;&#xA;&lt;li&gt;Restart containers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;drinking-your-own-champagne&#34;&gt;Drinking your own champagne&lt;/h3&gt;&#xA;&lt;p&gt;As the CMO of my company would say, I decided to &amp;ldquo;drink my own&#xA;champagne&amp;rdquo;, which is a classy way of the saying &amp;ldquo;eating your own dog&#xA;food&amp;rdquo; and only follow my &lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;cluster related blog&#xA;posts&lt;/a&gt; to reinstall everything&amp;hellip; And it went better than I expected!&lt;/p&gt;&#xA;&lt;p&gt;I went through the&#xA;&lt;a href=&#34;https://bacardi55.io/2020/03/27/my-home-lab-2020-part-3-docker-swarm-setup/&#34;&gt;docker swarm&#xA;setup&lt;/a&gt; and&#xA;&lt;a href=&#34;https://bacardi55.io/2020/03/30/my-home-lab-2020-part-4-running-services-over-https-with-traefik/&#34;&gt;running&#xA;services with traefic&lt;/a&gt; and everything was in there except 1 command to&#xA;create the external &lt;code&gt;traefic-net&lt;/code&gt; network. I then added it to the post&#xA;as well.&lt;/p&gt;&#xA;&lt;p&gt;To be honest, I do think having done this writing helped me first&#xA;understand better what I was doing back then, but also helped me reset&#xA;my cluster very fast! That&amp;rsquo;s why I write this blog, as I explained a&#xA;while back in &lt;a href=&#34;https://bacardi55.io/2020/04/25/why-do-i-write-on-this-blog/&#34;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Everything is back to normal now (hopefully :))!&lt;/p&gt;&#xA;&lt;h2 id=&#34;further-thoughts&#34;&gt;Further thoughts&lt;/h2&gt;&#xA;&lt;p&gt;I&amp;rsquo;m still unsure if I would need to declare another manager in the&#xA;cluster. That would be helpful if the problem happen another time. I&#xA;would just need to change the IP of the NAT redirection from the old to&#xA;new manager&amp;hellip; That would be an easy thing to do. I would then just need&#xA;to update docker-compose file to not avoid manager but just avoid the&#xA;main manager (&lt;code&gt;hostname =&lt;/code&gt; cell= in the deploy/placement area).&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ll write later about this if I decide that this is the goal to take.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m also thinking that maybe I should have some full images (dd) backups&#xA;of the 4 nodes but that feel a bit overkilled. As said, all data are on&#xA;the NAS anyway. But we&amp;rsquo;ll see what I&amp;rsquo;ll do in the future about that!&lt;/p&gt;&#xA;&lt;p&gt;Also: Don&amp;rsquo;t trust microSD card ;).&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;Using tmux &lt;code&gt;:set synchronize-panes&lt;/code&gt; to do everything on the 4&#xA;rpis at the same time!&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>Receive alerts when new images are available for your docker swarm cluster with Diun</title><link>https://bacardi55.io/2020/05/05/receive-alerts-when-new-images-are-available-for-your-docker-swarm-cluster-with-diun/</link><pubDate>Tue, 05 May 2020 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/05/05/receive-alerts-when-new-images-are-available-for-your-docker-swarm-cluster-with-diun/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Today, a quick post about &lt;a href=&#34;https://github.com/crazy-max/diun&#34;&gt;Diun&lt;/a&gt;, a&#xA;nice tool that alerts you when new docker images are available for your&#xA;services. It works with docker hub (obviously) but also with alternate /&#xA;private docker registry (eg: if you have automation for building&#xA;images).&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m in a middle of a bigger article about keeping your cluster up to&#xA;date that will talk about my usage of&#xA;&lt;a href=&#34;https://github.com/crazy-max/diun&#34;&gt;Diun&lt;/a&gt;, but I thought I would first&#xA;write about the installation and usage before going into the bigger&#xA;picture of having an up to date cluster.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: I know there are great tools like&#xA;&lt;a href=&#34;https://containrrr.github.io/watchtower/&#34;&gt;WatchTower&lt;/a&gt; that will not&#xA;only check for new version of containers&amp;rsquo; images but also update them&#xA;automatically. But I don&amp;rsquo;t like this solution as I prefer choosing&#xA;myself when and how to upgrade (and what to backup first :)). That also&#xA;allows me to potentially test on another environment first before&#xA;running it on my production.&lt;/p&gt;&#xA;&lt;h2 id=&#34;diun&#34;&gt;Diun&lt;/h2&gt;&#xA;&lt;p&gt;As stated above, Diun is a simple yet powerful tool that will check&#xA;every defined period (configurable) if new versions of the images you&#xA;are using exist and then alert you in a lot of possible way.&lt;/p&gt;&#xA;&lt;h3 id=&#34;docker-swarm-service&#34;&gt;Docker swarm service&lt;/h3&gt;&#xA;&lt;p&gt;Diun can work in a docker container too and is compatible with bare&#xA;docker or docker swarm :-). So as usual, we&amp;rsquo;re going to create a docker&#xA;swarm service for it. First, create the directory structure. If you&#xA;follow mine&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir /mnt/cluster-data/&lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;services-config,containers-data&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;/diun/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir /mnt/cluster-data/containers-data/diun/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, create the service definition file&#xA;&lt;code&gt;/mnt/cluster-data/services-config/diun/docker-compose.yml&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#34;3.2&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      diun:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: crazymax/diun:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;/mnt/cluster-data/containers-data/diun/data:/data&amp;#34; # Adapt if needed.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;/mnt/cluster-data/containers-data/diun/diun.yml:/diun.yml:ro&amp;#34; # Read Only on config file.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;/var/run/docker.sock:/var/run/docker.sock&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        environment:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;TZ=Europe/Paris&amp;#34; # Adapt.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;LOG_LEVEL=info&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;LOG_JSON=false&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == manager&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;Nota&lt;/em&gt;: Usual warning: When using containers, you should either build&#xA;your own or at least have a very good understanding of how the public&#xA;image you use is built and what it does before using it. Using unknown&#xA;containers on your platform is a security risk!&lt;/p&gt;&#xA;&lt;h3 id=&#34;configuration&#34;&gt;Configuration&lt;/h3&gt;&#xA;&lt;p&gt;Before actually running the service, we need to create the configuration&#xA;file. If you didn&amp;rsquo;t change the above &lt;code&gt;docker-compose.yml&lt;/code&gt;, create the&#xA;file &lt;code&gt;/mnt/cluster-data/containers-data/diun/diun.yml&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    db:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      path: diun.db&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    watch:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      workers: 4&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      schedule: &amp;#34;0 * * * *&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      first_check_notif: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    notif:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #  mail:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    enable: false&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    host: localhost&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    port: 25&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    ssl: false&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    insecure_skip_verify: false&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    username:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    password:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    from:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    #    to:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      webhook:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        enable: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        endpoint: http://&amp;lt;IPNodeRed&amp;gt;:&amp;lt;PortNodered&amp;gt;/api/cluster/update&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        method: GET&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        headers:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          Content-Type: application/json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        timeout: 10&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    providers:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      swarm:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        # Watch all services on local Swarm cluster&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        swarm55:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          watch_by_default: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&#34;https://github.com/crazy-max/diun/blob/master/doc/configuration.md&#34;&gt;Look&#xA;at the documentation&lt;/a&gt; for additional details, but in a nutshell:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;db&lt;/code&gt;: indicate the path to diun.db (in the end will be in the data&#xA;containers we created above)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;watch&lt;/code&gt;: define how many workers can run at the same time (here 4) and&#xA;when to run the checks. It is a&#xA;&lt;a href=&#34;https://godoc.org/github.com/robfig/cron#hdr-CRON_Expression_Format&#34;&gt;cron&#xA;expression&lt;/a&gt; so should be easy to understand :). In this example, it&#xA;runs every hours.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;notif&lt;/code&gt;: Tell diun how to tell you a new image is ready. The simplest&#xA;way is to use emails or telegram, that&amp;rsquo;s why I left the email config&#xA;part here. I use the webhook system only, as part of my&#xA;&lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;home automation&lt;/a&gt; so that diun send an alert to&#xA;&lt;a href=&#34;https://nodered.org/&#34;&gt;NodeRed&lt;/a&gt; that will then include that in my&#xA;more global flow of releases check, but more on that in the next post&#xA;:).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;providers&lt;/code&gt;: This is where you tell diun to listen to the swarm&#xA;cluster and look at all images updates (&lt;code&gt;watch_by_default: true&lt;/code&gt;). If&#xA;you want to explicitly tell diun which images to check, set the&#xA;watch_by_default to false and then use labels in service definition&#xA;(docker-compose.yml) as described&#xA;&lt;a href=&#34;https://github.com/crazy-max/diun/blob/master/doc/providers/docker.md#configuration&#34;&gt;here&lt;/a&gt;.&#xA;I&amp;rsquo;m lazy so I just check everything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Again, I strongly recommend to look at the&#xA;&lt;a href=&#34;https://github.com/crazy-max/diun/blob/master/doc/configuration.md&#34;&gt;configuration&#xA;documentation&lt;/a&gt; for additional details, as all options are explained&#xA;explicitly :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;start-the-service&#34;&gt;Start the service&lt;/h3&gt;&#xA;&lt;p&gt;As usual, quite simple:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack deploy diun -c /mnt/cluster-data/services-config/diun/docker-compose.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you kept the &lt;code&gt;first_check_notif: true&lt;/code&gt;, you should receive&#xA;notification if any services is not using the latest images available.&#xA;If you didn&amp;rsquo;t get any alert, check the logs, maybe everything is up to&#xA;date:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker service logs -f diun_diun &lt;span style=&#34;color:#75715e&#34;&gt;# Adapt service name if needed.&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And to stop the service:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack rm diun&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;That&amp;rsquo;s it for now, we&amp;rsquo;ll see in the next post how I use Diun and other&#xA;tools to stay alerted of new version of the software I use.&lt;/p&gt;&#xA;&lt;p&gt;You can follow all posts about my Home Lab on the&#xA;&lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;dedicated page&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://bacardi55.io/posts/2020/03/27/my-home-lab-2020-part-3-docker-swarm-setup/&#34;&gt;this post&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>My Home Lab 2020, part 7: Keeping containers&#39; log in rotation with logrotate</title><link>https://bacardi55.io/2020/05/02/my-home-lab-2020-part-7-keeping-containers-log-in-rotation-with-logrotate/</link><pubDate>Sat, 02 May 2020 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/05/02/my-home-lab-2020-part-7-keeping-containers-log-in-rotation-with-logrotate/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Today, a quick and very simple post about managing the logs of my&#xA;&lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;home lab&lt;/a&gt; containers :) The goal is to ensure that&#xA;logs file generated by docker are not growing in size too much as docker&#xA;by default will keep storing all logs in a log file per container.&lt;/p&gt;&#xA;&lt;p&gt;There are multiple ways of doing it, and I will use the simplest one by&#xA;leveraging logrotate (already installed by default in most&#xA;distribution!) :). As logrotate man page&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;logrotate - rotates, compresses, and mails system logs&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you want a centralized log management solution where you can access&#xA;all logs from containers in a single interface, with filter, search and&#xA;sprinkles, then you should look at the&#xA;&lt;a href=&#34;https://www.elastic.co/what-is/elk-stack&#34;&gt;ELK&lt;/a&gt; stack&lt;/p&gt;&#xA;&lt;h2 id=&#34;configuring-logrotate&#34;&gt;Configuring Logrotate&lt;/h2&gt;&#xA;&lt;p&gt;First, we just need to tell logrotate to look at all log files generated&#xA;by containers. By default, docker will generate log files in&#xA;&lt;code&gt;/var/lib/docker/containers/&amp;lt;containerID&amp;gt;/&amp;lt;containerID&amp;gt;-json.log&lt;/code&gt;. This&#xA;means that we need to tell logrotate to check for all files finishing by&#xA;&lt;code&gt;.log&lt;/code&gt; in all subdirectory of &lt;code&gt;/var/lib/docker/containers/&lt;/code&gt;. To do so,&#xA;create a new file in logrotate configuration directory called docker&#xA;(&lt;code&gt;/etc/logrotate.d/docker&lt;/code&gt;) with the following:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    /var/lib/docker/containers/*/*.log {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      rotate 12&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      daily&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      compress&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      size=100M&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      missingok&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      delaycompress&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      copytruncate&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Explaination&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;rotate 12&lt;/code&gt;: Keep 12 months of logs&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;daily&lt;/code&gt;: Run rotation daily&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;compress&lt;/code&gt;: compress log file with gzip&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;delaycompress&lt;/code&gt;: Wait for next rotation to compress&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;size=100M&lt;/code&gt;: Max file size 100M. So rotation happens daily or when log&#xA;file reach 100M.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;missingok&lt;/code&gt;: Keep going in case of error&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;copytruncate&lt;/code&gt;: Truncate the original log file to zero size in place&#xA;after creating a copy, instead of moving the old log file and&#xA;optionally creating a new one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;More information on &lt;a href=&#34;https://linux.die.net/man/8/logrotate&#34;&gt;logrotate&#xA;documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To test that everything works correctly:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo logrotate -v /etc/logrotate.d/docker&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;-v&lt;/code&gt; is for a more verbose output of the command. You should get a&#xA;long output telling you it worked! You can check by looking at the log&#xA;files with &lt;code&gt;ls /var/lib/docker/containers/*/*.log*&lt;/code&gt;. You should see&#xA;rotation log file now (name &lt;code&gt;&amp;lt;containerID&amp;gt;-log-&amp;lt;number&amp;gt;.gz&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;h2 id=&#34;reading-logs&#34;&gt;Reading logs&lt;/h2&gt;&#xA;&lt;p&gt;Logrotate is only helping with log file size to avoid having logs files&#xA;of multiple GB that will pollute your disk. If you need to access the&#xA;logs, you have multiple solution:&lt;/p&gt;&#xA;&lt;p&gt;Use docker command line to see the logs of a swarm service:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker services logs -f servicename_containername&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or you can use docker manager UI to access them like&#xA;&lt;a href=&#34;https://www.portainer.io/&#34;&gt;portainer&lt;/a&gt; or&#xA;&lt;a href=&#34;https://swarmpit.io/&#34;&gt;swarmpit&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Finally, you could also use &lt;a href=&#34;https://github.com/amir20/dozzle&#34;&gt;dozzle&lt;/a&gt;&#xA;to access all logs from all containers in real time in once place. It is&#xA;not made for log storage or search, it is simply displaying all&#xA;containers logs in a single web page. As it can be very handy for&#xA;debugging, I have a docker-compose.yml defining a dozzle swarm stack&#xA;ready for it any time, so maybe have a look at it :)&lt;/p&gt;&#xA;&lt;p&gt;Just FYI, this is the docker-compose file for dozzle:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#34;3&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      dozzle:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: amir20/dozzle:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /var/run/docker.sock:/var/run/docker.sock&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 8080:8080 # To change&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == manager&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;Nota&lt;/em&gt;: Same warning as usual, you should either build your own docker&#xA;images and deeply inspect the build file of the community containers you&#xA;are using! :).&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;As said above, this is really the simplest thing to do (but still&#xA;important to avoid filling up your disk with huge uncompressed log files&#xA;:) The next step if you want a centralized place, look at ELK or&#xA;equivalent. I don&amp;rsquo;t need that level of complexity, so for me it does the&#xA;job :) But evolving that later on is always an option.&lt;/p&gt;&#xA;&lt;p&gt;You can follow all posts about my Home Lab on the&#xA;&lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;dedicated page&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;*[ELK]: ElasticSearch Logstach Kibana&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://linux.die.net/man/8/logrotate&#34;&gt;https://linux.die.net/man/8/logrotate&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>My Home Lab 2020, part 5: External application status with Statping</title><link>https://bacardi55.io/2020/04/28/my-home-lab-2020-part-5-external-application-status-with-statping/</link><pubDate>Tue, 28 Apr 2020 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/04/28/my-home-lab-2020-part-5-external-application-status-with-statping/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Today, a new article for my &lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;Home Lab 2020 series&lt;/a&gt;&#xA;to talk about &amp;ldquo;external application status&amp;rdquo;. What I mean by that, is&#xA;having a simple tool that will check if your applications are responding&#xA;by doing a simple http request to the applications.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Attention&lt;/strong&gt;, this is not really a monitoring tool per say. It doesn&amp;rsquo;t&#xA;check each servers of the cluster resources or availability or any&#xA;specific server check. It just send a simple http request to an endpoint&#xA;and check if the service is still available.&lt;/p&gt;&#xA;&lt;p&gt;In the case of a swarm cluster like me, having all services available&#xA;does not mean that everything is working correctly on the cluster. For&#xA;example, a non manager node (&lt;code&gt;ptitcell{1,2,3}&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;) could be down but&#xA;all services still running. So while having that kind of external&#xA;application monitoring is very important (simulate a user request), this&#xA;is definitely not enough for a real monitoring of your cluster, this is&#xA;why there will be a dedicated post about monitoring later on.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Attention2&lt;/strong&gt;: To be effective, this verification should be done from a&#xA;server that is not hosting the said services (Otherwise, if the cluster&#xA;fails, the check won&amp;rsquo;t happen and you won&amp;rsquo;t receive alerts)! If you are&#xA;selfhosting in your house like me, you should definitely think about&#xA;hosting this tool outside of your network for better relevance (if not,&#xA;there are multiple use cases where the check will be positive even&#xA;though the apps are not reachable from the outside). # Which tool or&#xA;services?&lt;/p&gt;&#xA;&lt;p&gt;There are multiple tools available online SaaS solution to do so&#xA;(eg:&lt;a href=&#34;https://pingdom.com&#34;&gt;pingdom.com&lt;/a&gt;). But as you may have guessed,&#xA;I also want a tool that can be self hosted and is of course opensource.&#xA;My requirements are dead simple:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Opensource and can be selfhosted&lt;/li&gt;&#xA;&lt;li&gt;Check every X minutes my different applications&lt;/li&gt;&#xA;&lt;li&gt;Alert me when one goes down (or is up again)&lt;/li&gt;&#xA;&lt;li&gt;Provides a simple status page&lt;/li&gt;&#xA;&lt;li&gt;Provides some statistics (nice to have)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;statping&#34;&gt;Statping&lt;/h2&gt;&#xA;&lt;p&gt;I found the perfect tool for my use case:&#xA;&lt;a href=&#34;https://statping.com/&#34;&gt;statping&lt;/a&gt;! Check the website for more&#xA;information but it did answer my main requirements and more. With it, I:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Have a dedicated status page showing status and some statistics of my&#xA;services uptime&lt;/li&gt;&#xA;&lt;li&gt;Get an email alert when a service change status (up or down) (You can&#xA;also configure other channel like telegram)&lt;/li&gt;&#xA;&lt;li&gt;Have a configurable health check, as I don&amp;rsquo;t want to spam my server&#xA;but just make sure regularly that the services are working&lt;/li&gt;&#xA;&lt;li&gt;Bonus: it checks the ssl certificate as well (useful when using&#xA;letsencrypt to ensure they are still valid)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;installation&#34;&gt;Installation&lt;/h3&gt;&#xA;&lt;p&gt;As said above, it is better to install such a tool outside the &amp;ldquo;hosting&#xA;network&amp;rdquo;. Ideally, you could find a friend that agree to host your&#xA;statping instance (and you could do the same for him) or use a hosting&#xA;provider for that, some of them can be quite cheap. In my case, I&#xA;already had a &lt;a href=&#34;https://www.digitalocean.com/&#34;&gt;digital ocean&lt;/a&gt; droplet&#xA;with docker running on it (for some services still not self hosted) so I&#xA;used it to install statping.&lt;/p&gt;&#xA;&lt;p&gt;As this existing server of mine is not part of a swarm cluster, the&#xA;installation will be different than usual for the home lab containers.&#xA;In this case, I&amp;rsquo;m using docker-compose to run the containers and nginx&#xA;as reverse proxy (as this is the existing reverse proxy on that server).&lt;/p&gt;&#xA;&lt;h4 id=&#34;service-definition&#34;&gt;Service definition&lt;/h4&gt;&#xA;&lt;p&gt;First, as usual, create the&#xA;&lt;code&gt;/var/containers-data/statping/config/docker-compose.yml&lt;/code&gt;&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#34;3&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      statping:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        container_name: statping&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: hunterlong/statping:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        restart: always&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 8080:8080 #todo: changeme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /var/containers-data/statping/data:/app&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        environment:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          DB_CONN: sqlite&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Don&amp;rsquo;t forget to create the volume directory, if you haven&amp;rsquo;t change the&#xA;docker-compose above:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir -p /var/containers-data/statping/data/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;nginx-configuration&#34;&gt;Nginx configuration&lt;/h4&gt;&#xA;&lt;p&gt;I won&amp;rsquo;t go in this post into the global nginx configuration, just the&#xA;setup of this particular rule. For this I created a new configuration&#xA;file in &lt;code&gt;/etc/nginx/sites-enabled/&lt;/code&gt; called &lt;code&gt;statping.domain.com.conf&lt;/code&gt;&#xA;(adapt for your domain of course :)) with the following content:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    upstream statping {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        server 127.0.0.1:8080; # change according to docker-compose.yml file.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    map $http_upgrade $connection_upgrade {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      default upgrade;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &amp;#39;&amp;#39;      close;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    # Listen on http:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    server {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      listen 80;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      listen [::]:80;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      server_name statping.domain.com; # changeme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      # For Let&amp;#39;s encrypt:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      location /.well-known/acme-challenge {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        root /var/www/html/letsencrypt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        index index.html;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      # Redirection to https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      location / {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        return 301 https://$host$request_uri;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    # Listen on https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    server {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      listen 443 ssl;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      listen [::]:443 ssl;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      server_name statping.domain.com; # changeme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl on;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_certificate /etc/letsencrypt/live/statping.domain.coms/fullchain.pem; # changeme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_certificate_key /etc/letsencrypt/live/statping.domain.com/privkey.pem; # changeme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_trusted_certificate /etc/letsencrypt/live/statping.domain.com/chain.pem; # changeme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_protocols TLSv1.2;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_ciphers EECDH+AESGCM:EECDH+AES;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_ecdh_curve prime256v1;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_prefer_server_ciphers on;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ssl_session_cache shared:SSL:10m;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      keepalive_timeout    70;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      sendfile             on;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      client_max_body_size 0;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip on;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_disable &amp;#34;msie6&amp;#34;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_vary on;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_proxied any;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_comp_level 6;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_buffers 16 8k;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_http_version 1.1;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      location / {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        proxy_pass         http://statping;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        proxy_redirect     off;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        proxy_set_header   Host $host;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        proxy_set_header   X-Real-IP $remote_addr;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        proxy_set_header   X-Forwarded-Host $server_name;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      location /.well-known/acme-challenge {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        root /var/www/html/letsencrypt/;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        index index.html;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can then restart nginx:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo systemctrl restart nginx.service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then generate the SSL certificate. If like me you are using certbot:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo certbot certonly --webroot -n -m your@email.com --agree-tos -w /var/www/html/letsencrypt/ -d statpint.domain.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;start-stop-the-service&#34;&gt;Start/Stop the service&lt;/h4&gt;&#xA;&lt;p&gt;Then, inside the &lt;code&gt;/var/containers-data/statping/config/&lt;/code&gt; directory, run:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    cd /var/containers-data/statping/config/ &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker-compose up -d&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and restart nginx:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo systemctrl restart nginx.service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If everything worked smoothly, you should be able to access statping&#xA;from the url: &lt;code&gt;https://statping.domain.com&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To stop the service:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    cd /var/containers-data/statping/config/ &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker-compose down&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, you can go to &lt;code&gt;status.domain.com&lt;/code&gt; and should see the statping page.&#xA;Connect with &lt;code&gt;admin/admin&lt;/code&gt; and change the login and password right away&#xA;before configuring anything else :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;configuration&#34;&gt;Configuration&lt;/h3&gt;&#xA;&lt;p&gt;First, go to the settings page to change the global settings like the&#xA;page name, description, domain, &amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;If like me, only one message is enough to tell me a service is down (and&#xA;not a message every X minutes telling me it is still down&amp;hellip;), configure&#xA;the notification for &amp;ldquo;updates only&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;Then you can configure the notification system, I personally chose email&#xA;for now, but I may switch to telegram at some point, as my&#xA;&lt;a href=&#34;https://bacardi55.io/categories/homeautomation/&#34;&gt;home automation&lt;/a&gt; system is based a lot&#xA;around telegram as well&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;After that, all you need is to configure Services (that can be grouped&#xA;if needed for visibility). For example for testing this blog:&lt;/p&gt;&#xA;&lt;figure&gt;&lt;img src=&#34;https://bacardi55.io/images/posts/2020/04/28/homelabp5/statpingservice.png&#34;&#xA;    alt=&#34;Figure 1: Statping service config&#34;&gt;&lt;figcaption&gt;&#xA;      &lt;p&gt;&lt;span class=&#34;figure-number&#34;&gt;Figure 1: &lt;/span&gt;Statping service config&lt;/p&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;p&gt;Then you can enjoy a nice dashboard with some stats (uptime and response&#xA;time):&lt;/p&gt;&#xA;&lt;figure&gt;&lt;img src=&#34;https://bacardi55.io/images/posts/2020/04/28/homelabp5/statpingdashboard.png&#34;&#xA;    alt=&#34;Figure 2: Statping dashboard&#34;&gt;&lt;figcaption&gt;&#xA;      &lt;p&gt;&lt;span class=&#34;figure-number&#34;&gt;Figure 2: &lt;/span&gt;Statping dashboard&lt;/p&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;figure&gt;&lt;img src=&#34;https://bacardi55.io/images/posts/2020/04/28/homelabp5/statpingdashboard2.png&#34;&#xA;    alt=&#34;Figure 3: Statping dashboard blog&#34;&gt;&lt;figcaption&gt;&#xA;      &lt;p&gt;&lt;span class=&#34;figure-number&#34;&gt;Figure 3: &lt;/span&gt;Statping dashboard blog&lt;/p&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;That&amp;rsquo;s it for now, I will write followup posts for &amp;ldquo;internal monitoring&amp;rdquo;&#xA;(servers and containers) as well as backups, as this series is not over&#xA;yet! :-)&lt;/p&gt;&#xA;&lt;p&gt;You can follow all posts about my Home Lab setup on the&#xA;&lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;dedicated page&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;*[SaaS]: Software as a Service&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;See my cluster &lt;a href=&#34;https://bacardi55.io/posts/2020/03/27/my-home-lab-2020-part-3-docker-swarm-setup/&#34;&gt;setup&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;Same warning as usual: either really understand the container&#xA;your using by looking at the build file or build your own and&#xA;manage your own docker registry!&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>Manage your personal project todos with Kanboard and Docker Swarm</title><link>https://bacardi55.io/2020/04/03/manage-your-personal-project-todos-with-kanboard-and-docker-swarm/</link><pubDate>Fri, 03 Apr 2020 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/04/03/manage-your-personal-project-todos-with-kanboard-and-docker-swarm/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Today, a quick post a about &lt;a href=&#34;https://kanboard.org&#34;&gt;kanboard&lt;/a&gt;, a simple yet powerful&#xA;&lt;a href=&#34;https://en.wikipedia.org/wiki/Kanban_(development)&#34;&gt;Kanban&lt;/a&gt; tool. It is not per say part of my &lt;a href=&#34;https://bacardi55.io/categories/homelab/&#34;&gt;home lab&lt;/a&gt; series but&#xA;is linked as the idea is to explain my config for running it on my&#xA;docker swarm cluster. I&amp;rsquo;m planning to do small posts like this to&#xA;basically create a &lt;a href=&#34;https://bacardi55.io/categories/swarmservice/&#34;&gt;list of &amp;ldquo;recipes&amp;rdquo;&lt;/a&gt; of how I run my apps on&#xA;&lt;a href=&#34;http://localhost:8000/posts/2020/03/21/my-home-lab-2020-part-1-context-and-architecture-choices/&#34;&gt;my raspberry pi cluster&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Quoting wikipedia, a &lt;a href=&#34;https://en.wikipedia.org/wiki/Kanban_(development)&#34;&gt;Kanban&lt;/a&gt; is:&#xA;&amp;gt; Kanban (Japanese 看板, signboard or billboard) is a lean method to&#xA;manage and improve work across human systems.[&amp;hellip;]&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Work items are visualized to give participants a view of progress and&#xA;process, from start to finish&amp;mdash;usually via a Kanban board.[&amp;hellip;]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;!--quoteend--&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In knowledge work and in software development, the aim is to provide a&#xA;visual process management system which aids decision-making about&#xA;what, when, and how much to produce.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In simplified term (too simplified), it is a project management&#xA;methodology that consists of using a visual boards (physic or virtual)&#xA;to manage the different tasks of a projects and track their status.&lt;/p&gt;&#xA;&lt;p&gt;You manage the different tasks status in column and then create items&#xA;and move them from column to column when working on them.&lt;/p&gt;&#xA;&lt;p&gt;There are a lot of way of using the kanban methodology in projects,&#xA;specially when using &lt;a href=&#34;https://en.wikipedia.org/wiki/Agile_software_development&#34;&gt;Agile methodology&lt;/a&gt;. I don&amp;rsquo;t want to go in details about this here as this is&#xA;clearly not the goal of this post.&lt;/p&gt;&#xA;&lt;p&gt;At a personal level, I&amp;rsquo;m using Kanboard to simply manage my personal&#xA;projects todo and tasks. I have for example a «devops / Home automation»&#xA;project with all the things I need to do or another for writing blog&#xA;posts. (I&amp;rsquo;ve also linked &lt;a href=&#34;https://nodered.org/&#34;&gt;nodered&lt;/a&gt; with &lt;a href=&#34;https://docs.kanboard.org/en/latest/api/index.html&#34;&gt;kanboard api&lt;/a&gt; to&#xA;automate some tasks creation, but more on that later when I&amp;rsquo;ll write&#xA;about my home automation system :-)).&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s see a quick screenshot of my dashboard:&lt;/p&gt;&#xA;&lt;figure&gt;&lt;img src=&#34;https://bacardi55.io/images/posts/2020/04/03/kanboard/myboard-small-ano.png&#34;&#xA;    alt=&#34;Figure 1: My kanboard for devops &amp;amp; home automation&#34;&gt;&lt;figcaption&gt;&#xA;      &lt;p&gt;&lt;span class=&#34;figure-number&#34;&gt;Figure 1: &lt;/span&gt;My kanboard for devops &amp;amp; home automation&lt;/p&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;p&gt;Here we can see the backlog of ideas on the left, the tasks ready to be&#xA;started (column ready), the list of bugs and enhancement (I prefer&#xA;separating them from the new things in the ready column), items i&amp;rsquo;m&#xA;currently working on and the finished tasks. For me, this is a great way&#xA;of managing and keeping track of things that needs to be done (or are&#xA;already done). I&amp;rsquo;m using it in its most simplistic way and you could&#xA;obviously working with it in teams and leverage a lot more features than&#xA;me :-). Each project can have a different configuration, so my blog&#xA;posts kanboard have only the following column: backlog, work in&#xA;progress, proof reading, to be published and published. This is really a&#xA;great tool, it works for simple or complex kanban flows and teams and&#xA;don&amp;rsquo;t see a better way (&lt;strong&gt;for me!&lt;/strong&gt;) to manage my ideas and projects tasks&#xA;:).&lt;/p&gt;&#xA;&lt;p&gt;I let you read the &lt;a href=&#34;https://kanboard.org&#34;&gt;website&lt;/a&gt; and the &lt;a href=&#34;https://docs.kanboard.org/en/latest/&#34;&gt;documentation&lt;/a&gt; to get a better&#xA;understanding of what you can do with it!&lt;/p&gt;&#xA;&lt;h2 id=&#34;configuration&#34;&gt;Configuration&lt;/h2&gt;&#xA;&lt;p&gt;If you follow my &lt;a href=&#34;https://bacardi55.io/categories/homelab/&#34;&gt;homelab setup&lt;/a&gt;, you are familiar with the&#xA;&lt;a href=&#34;https://bacardi55.io/posts/2020/03/24/my-home-lab-2020-part-2-glusterfs-setup/&#34;&gt;Gluster shared volume&lt;/a&gt; and the directory structure for my cluster.&lt;/p&gt;&#xA;&lt;p&gt;Configuration directory is &lt;code&gt;/mnt/cluster-data/services-config/kanboard/&lt;/code&gt;&#xA;and data directory is &lt;code&gt;/mnt/cluster-data/containers-data/kanboard/&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Create the file&#xA;&lt;code&gt;/mnt/cluster-data/services-config/kanboard/docker-compose.yml&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      kanboard:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: kanboard/kanboard&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         - /mnt/cluster-data/containers-data/kanboard/data:/var/www/app/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         - /mnt/cluster-data/containers-data/kanboard/plugins:/var/www/app/plugins&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - traefik-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          labels:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.enable=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.services.kanboard-service.loadbalancer.server.port=80&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard.rule=Host(`kanboard.domain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard.entrypoints=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # For https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard-secure.rule=Host(`kanboard.domain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard-secure.entrypoints=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard-secure.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard-secure.tls.certresolver=le&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.kanboard-redirect-kanboard-secure.redirectscheme.scheme=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.kanboard.middlewares=kanboard-redirect-kanboard-secure&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == worker&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      traefik-net:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        external: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: In this case, I&amp;rsquo;m using the official docker image from the&#xA;kanboard project. When using an image that you did not create yourself,&#xA;you must look into the docker build files&#xA;(&lt;a href=&#34;https://github.com/kanboard/kanboard/blob/master/Dockerfile&#34;&gt;here for kanboard&lt;/a&gt;) before using it! It is even better to generate your own&#xA;images instead of using custom non trusted one (for now I often use my&#xA;own with my own registry but don&amp;rsquo;t publish the build files, &lt;em&gt;yet&lt;/em&gt; :-)).&lt;/p&gt;&#xA;&lt;p&gt;As usual:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack deploy kanboard -c /mnt/cluster-data/services-config/kanboard/docker-compose.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then go to &lt;code&gt;https://kanboard.domain.com&lt;/code&gt; and you should see the kanboard&#xA;page, follow the instruction and read the documentation if needed :).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;NOTA&lt;/strong&gt;: As usual, before deploying your stack, make sure the selected&#xA;domain DNS (in this example kanboard.domain.org) are correctly&#xA;configured so that the letsencrypt challenge can be completed and your&#xA;TLS certificate generated. You can check by going to the domain from&#xA;outside your home network (if you are selfhosting). You should get a 404&#xA;from your traefik container. If you start the container without the&#xA;domain DNS configured, then you will get banned from letsencrypt for 1h.&lt;/p&gt;&#xA;&lt;p&gt;And stopping it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack rm kanboard&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;Looks pretty similar as the template defined in my&#xA;&lt;a href=&#34;https://bacardi55.io/posts/2020/03/30/my-home-lab-2020-part-4-running-services-over-https-with-traefik/&#34;&gt;homelab blog post part 4&lt;/a&gt; :)&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>My Home Lab 2020, part 4: Running Services over https with Traefik</title><link>https://bacardi55.io/2020/03/30/my-home-lab-2020-part-4-running-services-over-https-with-traefik/</link><pubDate>Mon, 30 Mar 2020 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/03/30/my-home-lab-2020-part-4-running-services-over-https-with-traefik/</guid><description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;h3 id=&#34;context-reminder&#34;&gt;Context Reminder&lt;/h3&gt;&#xA;&lt;p&gt;New post about &amp;ldquo;&lt;a href=&#34;https://bacardi55.io/categories/homelab/&#34;&gt;homelab&lt;/a&gt;&amp;rdquo; setup as promised &lt;a href=&#34;https://bacardi55.io/posts/2020/03/29/Simple-load-testing-using-siege/&#34;&gt;yesterday&lt;/a&gt; :).&#xA;You can read about &lt;a href=&#34;https://bacardi55.io/posts/2020/03/21/my-home-lab-2020-part-1-context-and-architecture-choices/&#34;&gt;the architecture choices in part 1&lt;/a&gt;. In&#xA;&lt;a href=&#34;https://bacardi55.io/posts/2020/03/24/my-home-lab-2020-part-2-glusterfs-setup/&#34;&gt;part 2&lt;/a&gt; I wrote about creating a shared storage via&#xA;&lt;a href=&#34;https://www.gluster.org&#34;&gt;GlusterFS&lt;/a&gt; for our cluster and in &lt;a href=&#34;https://bacardi55.io/posts/2020/03/27/my-home-lab-2020-part-3-docker-swarm-setup/&#34;&gt;part 3&lt;/a&gt; I explained how to create the&#xA;&lt;a href=&#34;https://docs.docker.com/engine/swarm/&#34;&gt;docker swarm&lt;/a&gt; cluster.&lt;/p&gt;&#xA;&lt;h3 id=&#34;assumptions&#34;&gt;Assumptions&lt;/h3&gt;&#xA;&lt;p&gt;For this post, you should understand what are containers and have basic&#xA;&lt;a href=&#34;https://docs.docker.com/engine/swarm/&#34;&gt;docker swarm&lt;/a&gt; concepts&#xA;knowledge. It would also be better if you have an understanding of&#xA;docker-compose.&lt;/p&gt;&#xA;&lt;h3 id=&#34;ok-so-what-now&#34;&gt;Ok, So what now?&lt;/h3&gt;&#xA;&lt;p&gt;The goal of this post is to be able to run containers on our cluster,&#xA;behind https with a &lt;a href=&#34;https://letsencrypt.org/&#34;&gt;letsencrypt&lt;/a&gt; certificate.&lt;/p&gt;&#xA;&lt;p&gt;To run containers on a docker swarm cluster, you can just create&#xA;docker-compose.yml files like the example given in the &lt;a href=&#34;https://bacardi55.io/posts/2020/03/24/my-home-lab-2020-part-2-glusterfs-setup/&#34;&gt;part 2&lt;/a&gt;&#xA;and start them with&#xA;&lt;code&gt;docker stack &amp;lt;serviceName&amp;gt; deploy -c &amp;lt;/path/to/docker-compose.yml&amp;gt;&lt;/code&gt; and&#xA;that&amp;rsquo;s it&amp;hellip; But this would means running services on different port andaccessing them directly with the IP address like we did for our&#xA;visualizer (&lt;code&gt;http://&amp;lt;IpOfManagerNode&amp;gt;:8080&lt;/code&gt;). This is because is just&#xA;made to run the containers themselves, so containers needs to run and&#xA;expose different ports. This is clearly not ideal to say the least :)&lt;/p&gt;&#xA;&lt;p&gt;What we want instead, is the ability to run multiple containers, access&#xA;them via (sub)domain(s) directly on port 443 (https) or 80 (http with a&#xA;forced redirection to https). For example, I&amp;rsquo;m running this blog&#xA;accessible at &lt;a href=&#34;https://bacardi55.io&#34;&gt;https://bacardi55.io&lt;/a&gt; and &lt;a href=&#34;https://gogs.io&#34;&gt;gogs&lt;/a&gt; for&#xA;my git repository at &lt;a href=&#34;https://git.bacardi55.io&#34;&gt;https://git.bacardi55.io&lt;/a&gt;, both running on this&#xA;docker swarm cluster.&lt;/p&gt;&#xA;&lt;p&gt;To do so, we basically need a router that will map incoming requests to&#xA;the running containers&amp;hellip; Enters &lt;a href=&#34;https://docs.traefik.io/&#34;&gt;traefik 2&lt;/a&gt;&#xA;:)&lt;/p&gt;&#xA;&lt;h2 id=&#34;installing-and-configuring-traefik&#34;&gt;Installing and configuring Traefik&lt;/h2&gt;&#xA;&lt;h3 id=&#34;why-traefik-2&#34;&gt;Why Traefik 2&lt;/h3&gt;&#xA;&lt;p&gt;The reason I chose traefik was it simplicity and its native compliance&#xA;with Docker Swarm. The &amp;ldquo;native compliance&amp;rdquo; means that by simply entering&#xA;some configurations (&lt;code&gt;container labels&lt;/code&gt;) in your docker-compose.yml&#xA;files for the services you want to run, traefik will be automatically&#xA;configured to route the requests accordingly! Isn&amp;rsquo;t that great?&lt;/p&gt;&#xA;&lt;p&gt;Obviously I over simplifying here on purpose, I suggest you read&#xA;&lt;a href=&#34;https://docs.traefik.io&#34;&gt;traefik documentation&lt;/a&gt; (at least the &lt;a href=&#34;https://docs.traefik.io/providers/docker/&#34;&gt;docker provider overview&lt;/a&gt;)&#xA;to understand more the concepts :)&lt;/p&gt;&#xA;&lt;h3 id=&#34;configuration&#34;&gt;Configuration&lt;/h3&gt;&#xA;&lt;p&gt;Ok, so let&amp;rsquo;s start by configuring traefik!&lt;/p&gt;&#xA;&lt;p&gt;First, I created&#xA;&lt;code&gt;/mnt/cluster-data/services-config/traefik/docker-compose.yml&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      reverse-proxy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: traefik&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        command:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          ###                          ###&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Traefik Global Configuration #&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          ###                          ###&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Enable DEBUG logs, change this to INFO after initial successfull setup.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --log.level=DEBUG # DEBUG, INFO, etc...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --ping=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Enable api access without authentification (only GET route so it only possible to get IPs)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --api.insecure=true # You can insecure here, because It accessible only in the container if you didn&amp;#39;t open the port.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Set the provider to Docker&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --providers.docker=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Set to docker swarm cluster&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --providers.docker.swarmMode=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # If False : Do not expose containers to the web by default&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --providers.docker.exposedByDefault=false&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Default rule to service-name.example.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --providers.docker.defaultRule=Host(`{{ trimPrefix `/` .Name }}.youdomain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Default https port&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --entrypoints.https.address=:443&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          #- --entrypoints.https.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Default http port&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --entrypoints.http.address=:80&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # Enable let&amp;#39;s encrypt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --certificatesresolvers.le.acme.httpchallenge=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --certificatesresolvers.le.acme.httpchallenge.entrypoint=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --certificatesresolvers.le.acme.email=&amp;lt;your@email.com&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # For testing:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          #- --certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - traefik-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # The HTTP port&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 80:80&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # The HTTPS port&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 443:443&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # The Web UI (enabled by --api.insecure=true)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 8080:8080 # Remove it once you&amp;#39;ve tested everything&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          # So that Traefik can listen to the Docker events&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /var/run/docker.sock:/var/run/docker.sock&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /mnt/cluster-data/containers-data/traefik/acme.json:/letsencrypt/acme.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == manager&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      traefik-net:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        external: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The comments included should help you configure your docker-compose&#xA;file. The important part are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;The Network&lt;/strong&gt;: The is very important, all services that will need to&#xA;be expose via traefik will need to use this network. Network needs to&#xA;be external. To create the network, this simple command will do:&#xA;&lt;code&gt;docker network create -d overlay --attachable traefik-net&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;--providers.docker.defaultRule=Host(={{ trimPrefix =/&lt;/code&gt; .Name&#xA;}}.youdomain.com=)= allow to automatically create rules so that if you&#xA;create an exposed service called &lt;code&gt;blog&lt;/code&gt; for example, traefik will&#xA;automatically create the ssl certificate for &lt;code&gt;blog.yourdomain.com&lt;/code&gt; and&#xA;expose the service at this address.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you use the same configuration for letsencrypt storage as above, you&#xA;will need to create the file&#xA;&lt;code&gt;/mnt/cluster-data/containers-data/traefik/acme.json&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; and then put&#xA;the right permission on it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir -p /mnt/cluster-data/containers-data/traefik/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    touch /mnt/cluster-data/containers-data/traefik/acme.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    chmod &lt;span style=&#34;color:#ae81ff&#34;&gt;600&lt;/span&gt; /mnt/cluster-data/containers-data/traefik/acme.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;start-traefik&#34;&gt;Start Traefik&lt;/h3&gt;&#xA;&lt;p&gt;Now we can simply start traefik by deploying this stack:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack deploy traefik -c /mnt/cluster-data/services-config/traefik/docker-compose.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To make sure it is working correctly, go to&#xA;&lt;code&gt;http://&amp;lt;ManagerNodeIpAddress:8080&lt;/code&gt; (or adapt if you change the port).&#xA;You should see traefik dashboard. If that&amp;rsquo;s the case, it means it was&#xA;launched successfully. If not, you can look at the logs:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker service logs -f traefik_reverse-proxy&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If there is no log, check that a container is actually running:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker service ps traefik_reverse-proxy --no-trunc&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;Nota&lt;/em&gt;: Don&amp;rsquo;t forget to remove the Web UI port so it stay secure once&#xA;everything works fine. We&amp;rsquo;ll see in another post how to use it in a&#xA;secure manner. Once everything works fine, you should also move to a&#xA;INFO log level.&lt;/p&gt;&#xA;&lt;h2 id=&#34;installing-our-first-service&#34;&gt;Installing our first service&lt;/h2&gt;&#xA;&lt;p&gt;Ok, so now we have traefik running and acting as a router and SSL&#xA;provider for our services&amp;hellip; But we still don&amp;rsquo;t have any services&#xA;running (except traefik but that doesn&amp;rsquo;t do much yet)&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;So we will start simply by creating a service running nginx serving html&#xA;files (eg: for a static blog like this one).&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m planing to write about services I manage and thus have a library of&#xA;services ready to use for the different tools I&amp;rsquo;m running.&lt;/p&gt;&#xA;&lt;p&gt;So for this first service, we will have a simple nginx server that will&#xA;serve a static site over http (&amp;ldquo;internally&amp;rdquo; in our cluster network). It&#xA;will also configure traefik to listen (externally) to http and https&#xA;requests, http requests will be automatically redirected to https that&#xA;will have a valid ssl/tls certificate obtained via letsencrypt. Requests&#xA;recieved for this service will be redirected automatically internally to&#xA;our nginx container on port 80.&lt;/p&gt;&#xA;&lt;p&gt;And all this will be done simply via the &lt;code&gt;docker-compose.yml&lt;/code&gt; file :)&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m keeping my usual structure for files:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir /mnt/cluster-data/services-config/myWebSite &lt;span style=&#34;color:#75715e&#34;&gt;# Create the directory for the docker-compose.yml file.&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir /mnt/cluster-data/containers-data/myWebSite &lt;span style=&#34;color:#75715e&#34;&gt;# Create the directory that will contain the html.&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don&amp;rsquo;t have a static site to use, you can create a simple&#xA;&lt;code&gt;index.html&lt;/code&gt; file (inside the &lt;code&gt;…/containers-data/myWebSite&lt;/code&gt; directory)&#xA;with some simple basic html and content in it. Otherwise, just copy your&#xA;site (using &lt;code&gt;scp&lt;/code&gt; or other) in the directory.&lt;/p&gt;&#xA;&lt;p&gt;Now we need to define our service, so create the file&#xA;&lt;code&gt;/mnt/cluster-data/services-config/myWebSite/docker-compose.yml&lt;/code&gt; with&#xA;the following content:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      web:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: nginx&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          labels:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.enable=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web.rule=host(`domain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web.entrypoints=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.services.web-service.loadbalancer.server.port=80&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # for https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.rule=host(`domain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.entrypoints=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.tls.certresolver=le&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.web-redirect-web-secure.redirectscheme.scheme=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web.middlewares=web-redirect-web-secure&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == worker&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - traefik-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /mnt/cluster-data/containers-data/myWebSite/:/usr/share/nginx/html/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      traefik-net:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        external: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;deploy&lt;/code&gt; part of the configuration of the service allow you to&#xA;specify configuration related to the deployment and run of your&#xA;service&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;placement&lt;/code&gt; configuration allows to define rules to where&#xA;container(s) needs to be deployed&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;. In this case, I want it to be&#xA;deployed on a worker node (meaning in my setup, not on the manager&#xA;&lt;code&gt;cell&lt;/code&gt;, but on any of the &lt;code&gt;ptitcell{1,2,3}&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;labels&lt;/code&gt; allow to specify labels for the service. In our case, this&#xA;is how we can give instruction to configure traefik accordingly. Let&amp;rsquo;s&#xA;see in more details (read the comments):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      web:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          labels:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Tell traefik that this containers will be available through traefik.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.enable=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Indicates condition in which the request should be send to this container.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # In this case base on the domain[^4].&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web.rule=host(`domain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Accept http (port 80) requests&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web.entrypoints=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Tells traefik that this container (nginx) listen on port 80,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # so traefik can send the request accordingly.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.services.web-service.loadbalancer.server.port=80&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # for https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Same as for http, rules to match the request for this service.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.rule=host(`domain.com`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Accept https (port 443) requests&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.entrypoints=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Enable https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Indicates that letsencrypt ssl provider (certresolver)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # will be used (defined in our traefik configuration).&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web-secure.tls.certresolver=le&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Define a middleware[^5] to redirect http requests (router `web`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # traefik to https (router `web-secure`).&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.web-redirect-web-secure.redirectscheme.scheme=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # Indicate traefik to use the middleware when http requests (on routers `web`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # are recieved.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.web.middlewares=web-redirect-web-secure&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And don&amp;rsquo;t forget to link the traefik network so the containers can talk&#xA;to each other:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      web:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - traefik-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      traefik-net:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        external: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So now, all we need is to deploy the stack on our cluster, for this, a&#xA;simple command will do:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack deploy website -c /mnt/cluster-data/services-config/myWebSite/docker-compose.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;*/! Watch out /! *: You need to make sure before deploying the stack&#xA;that your domain DNS is configure correctly (as your network router to&#xA;redirect http and https traefik to your cluster). If you don&amp;rsquo;t configure&#xA;your DNS before, traefik will fail generating the SSL certificate&#xA;(multiple times in a row) and you&amp;rsquo;ll end up being banned by letsencrypt&#xA;(for 1h) for too many failed attempt (so test before and make sure you&#xA;get a 404 from your cluster - meaning the domain is rightly configure to&#xA;point to your cluster - before starting the service!).&lt;/p&gt;&#xA;&lt;p&gt;If everything works correctly, you should be able to go to&#xA;&lt;a href=&#34;https://domain.com&#34;&gt;https://domain.com&lt;/a&gt; and see your website.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: If you don&amp;rsquo;t use a local dns server (like dnsmasq - prefered&#xA;option) or a VPN, you might not be able to reach domain.com from the&#xA;local network, in this case, add an entry in your host file &lt;code&gt;/etc/hosts&lt;/code&gt;&#xA;with the IP of your cluster manager and the domain, eg:&#xA;&lt;code&gt;10.0.0.200  domain.com&lt;/code&gt;. If you choose the last option and edit your&#xA;hosts file, you will need to remove this line once testing from an&#xA;external network (try it while sharing your phone connection for example&#xA;:)).&lt;/p&gt;&#xA;&lt;p&gt;And if you want to stop it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack rm website&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;a-quick-skeleton&#34;&gt;A quick skeleton&lt;/h2&gt;&#xA;&lt;p&gt;You can use this skeleton when creating new services that you want&#xA;expose to the world via your traefik reverse proxy:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      web:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: &amp;lt;image&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          labels:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.enable=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;.rule=host(`&amp;lt;domain&amp;gt;`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;.entrypoints=http&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.services.&amp;lt;service&amp;gt;-service.loadbalancer.server.port=&amp;lt;port&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            # for https:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;-secure.rule=host(`&amp;lt;domain&amp;gt;`)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;-secure.entrypoints=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;-secure.tls=true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;-secure.tls.certresolver=le&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.middlewares.&amp;lt;service&amp;gt;-redirect-&amp;lt;service&amp;gt;-secure.redirectscheme.scheme=https&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - traefik.http.routers.&amp;lt;service&amp;gt;.middlewares=&amp;lt;service&amp;gt;-redirect-&amp;lt;service&amp;gt;-secure&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == worker&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - traefik-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          -&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      traefik-net:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        external: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By using this, I can then quickly search and replace the different&#xA;&lt;code&gt;&amp;lt;config&amp;gt;&lt;/code&gt; to change (&lt;code&gt;&amp;lt;domain&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;image&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;service&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;port&amp;gt;&lt;/code&gt;)&#xA;and have my service configured for traefik. Quick and easy :-) !.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Nota&lt;/em&gt;: This is a very basic and simple configuration, we could add more&#xA;stuff but that is enough for now :). &lt;em&gt;Nota2&lt;/em&gt;: We&amp;rsquo;ll see in a future blog&#xA;post how to automate the deployment of a static site instead of just&#xA;doing a scp :).&lt;/p&gt;&#xA;&lt;h2 id=&#34;to-be-continued-dot-dot-dot&#34;&gt;To be Continued&amp;hellip; :-)&lt;/h2&gt;&#xA;&lt;p&gt;That&amp;rsquo;s it for now, we have our site running over https thanks to traefik&#xA;and letsencrypt. All that done only via creating docker-compose.yml&#xA;files :-). We&amp;rsquo;ll see in future posts other services that I host and&#xA;share the docker-compose.yml files associated.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;I split configuration files and data into 2 directory. I could&#xA;have inside each services directory a config and a data folder&#xA;but I prefer like this.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://docs.docker.com/compose/compose-file/#deploy&#34;&gt;https://docs.docker.com/compose/compose-file/#deploy&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:3&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://docs.docker.com/compose/compose-file/#labels-1&#34;&gt;https://docs.docker.com/compose/compose-file/#labels-1&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>My Home Lab 2020, part 3: Docker Swarm setup</title><link>https://bacardi55.io/2020/03/27/my-home-lab-2020-part-3-docker-swarm-setup/</link><pubDate>Fri, 27 Mar 2020 00:00:00 +0100</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/03/27/my-home-lab-2020-part-3-docker-swarm-setup/</guid><description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;h3 id=&#34;context-reminder&#34;&gt;Context reminder&lt;/h3&gt;&#xA;&lt;p&gt;Today, a new part of my &lt;a href=&#34;https://bacardi55.io/categories/homelab/&#34;&gt;homelab posts serie&lt;/a&gt;&#xA;:). In the first post, I&amp;rsquo;ve explained&#xA;&lt;a href=&#34;https://bacardi55.io/posts/2020/03/21/my-home-lab-2020-part-1-context-and-architecture-choices/&#34;&gt;my&#xA;architecture choices for my 4 Raspberry Pi cluster&lt;/a&gt;. In the second,&#xA;I&amp;rsquo;ve setup a&#xA;&lt;a href=&#34;https://bacardi55.io/posts/2020/03/24/my-home-lab-2020-part-2-glusterfs-setup/&#34;&gt;GlusterFS&#xA;replicated volumes&lt;/a&gt; on all my servers in order to have a shared folders&#xA;between them (so you don&amp;rsquo;t care where containers are created).&lt;/p&gt;&#xA;&lt;p&gt;In this post, I&amp;rsquo;ll talk about the initial&#xA;&lt;a href=&#34;https://docs.docker.com/engine/swarm/&#34;&gt;docker swarm&lt;/a&gt; setup.&lt;/p&gt;&#xA;&lt;h3 id=&#34;assumptions&#34;&gt;Assumptions&lt;/h3&gt;&#xA;&lt;p&gt;I have 4 Raspberry Pi, all having a &lt;code&gt;/mnt/cluster-data&lt;/code&gt;&#xA;&lt;a href=&#34;http://gluster.org/&#34;&gt;GlusterFS&lt;/a&gt; volume mounted so that any files in&#xA;there will be replicated on all Pis.&lt;/p&gt;&#xA;&lt;p&gt;As a reminder, my 4 Raspberry Pi are named&#xA;&lt;code&gt;cell, ptitcell1, ptitcell2, ptitcell3&lt;/code&gt;. For GlusterFS, they all have&#xA;the same roles, but not for our docker swarm cluster, so pay attention&#xA;to the servers name :).&lt;/p&gt;&#xA;&lt;p&gt;For the rest of the article, you should have an understanding of what&#xA;docker, containers or a cluster are. You should also know your way a&#xA;little navigating in a linux terminal. If not, go read some&#xA;documentation first :).&lt;/p&gt;&#xA;&lt;h2 id=&#34;docker-swarm-setup&#34;&gt;Docker Swarm setup:&lt;/h2&gt;&#xA;&lt;h3 id=&#34;definition&#34;&gt;Definition&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;Docker Swarm&lt;/strong&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;: &amp;gt; A swarm consists of multiple Docker hosts which&#xA;run in swarm mode and act as managers (to manage membership and&#xA;delegation) and workers (which run swarm services). A given Docker host&#xA;can be a manager, a worker, or perform both roles.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Docker Swarm Node(s)&lt;/strong&gt;&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;: &amp;gt; A node is an instance of the Docker&#xA;engine participating in the swarm.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Docker Swarm Manager(s)&lt;/strong&gt;&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;: &amp;gt; Dispatches units of work called tasks&#xA;to worker nodes.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Docker Swarm Worker(s)&lt;/strong&gt;&lt;sup id=&#34;fnref:4&#34;&gt;&lt;a href=&#34;#fn:4&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;: &amp;gt; Receive and execute tasks dispatched&#xA;from manager nodes.&lt;/p&gt;&#xA;&lt;h3 id=&#34;my-choices&#34;&gt;My choices&lt;/h3&gt;&#xA;&lt;p&gt;I decided to setup a cluster with 1 manager node and 3 workers nodes.&#xA;You can choose a different setup with multiple manager if you want but&#xA;in this case adapt the following steps to your situation. I might later&#xA;on change this, it isn&amp;rsquo;t complex to add a new manager or workers later&#xA;on if needed.&lt;/p&gt;&#xA;&lt;h3 id=&#34;installation&#34;&gt;Installation&lt;/h3&gt;&#xA;&lt;p&gt;Ok, let&amp;rsquo;s go then :)&lt;/p&gt;&#xA;&lt;p&gt;First, install docker on all the pi&lt;sup id=&#34;fnref:5&#34;&gt;&lt;a href=&#34;#fn:5&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    curl -sSL https://get.docker.com | sh;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo usermod -aG docker pi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, on the manager node (&lt;code&gt;cell&lt;/code&gt; in my case):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker swarm init --advertise-addr &amp;lt;CellIpAddress&amp;gt; --default-addr-pool 10.10.0.0/16&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Replace &lt;code&gt;&amp;lt;CellIpAddress&amp;gt;&lt;/code&gt; by the local IP address of your node manager.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;--default-addr-pool&lt;/code&gt; is optional and is needed only if it conflicts&#xA;with other network&lt;sup id=&#34;fnref:6&#34;&gt;&lt;a href=&#34;#fn:6&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On all the other nodes of our cluster (for me: &lt;code&gt;ptitcell{1,2,3}&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker swarm join --token &amp;lt;token&amp;gt; &amp;lt;CellIpAddress&amp;gt;:2377&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Replace &lt;code&gt;&amp;lt;CellIpAddress&amp;gt;&lt;/code&gt; by the local IP address of your node manager.&lt;/p&gt;&#xA;&lt;p&gt;And that should do it for basic setup, it&amp;rsquo;s that simple :)&lt;/p&gt;&#xA;&lt;h3 id=&#34;testing&#34;&gt;Testing&lt;/h3&gt;&#xA;&lt;p&gt;Now, let&amp;rsquo;s start a simple container to see if this is working as&#xA;expected. Let&amp;rsquo;s start a very simple container that create a simple&#xA;webpage to visualize our containers. For this, we will use&#xA;&lt;a href=&#34;https://github.com/alexellis/docker-swarm-visualizer&#34;&gt;alexellis2/visualizer-arm&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker service create &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;      --name viz &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;      --publish 8080:8080 &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;      --constraint node.role&lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt;manager &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;      --mount type&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;bind,src&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;/var/run/docker.sock,dst&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;/var/run/docker.sock &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;      alexellis2/visualizer-arm:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you can open a browser and go to &lt;code&gt;http://&amp;lt;CellIpAddress&amp;gt;:8080&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Finally, let&amp;rsquo;s transform this in a &lt;code&gt;docker-compose.yml&lt;/code&gt; as this will be&#xA;the format I will use to define all my services later on.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m saving all my services config files (&lt;code&gt;docker-compose.yml&lt;/code&gt;) in&#xA;&lt;code&gt;/mnt/cluster-data/services-config/&amp;lt;nameOfTheService&amp;gt;&lt;/code&gt;, so in this case,&#xA;I&amp;rsquo;m creating a&#xA;&lt;code&gt;/mnt/cluster-data/services-config/vizualizer/docker-compose.yml&lt;/code&gt; with&#xA;the following content:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#34;3&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      viz:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: alexellis2/visualizer-arm:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;/var/run/docker.sock:/var/run/docker.sock&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;8080:8080&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.role == manager&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And start it with the following command:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack deploy viz -c /mnt/cluster-data/services-config/visualizer/docker-compose.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you can go back to &lt;code&gt;http://&amp;lt;CellIpAddress&amp;gt;:8080&lt;/code&gt; to check if&#xA;everything is still working!&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            - node.role == manager&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;↑ This part is to force the container to be started on the docker swarm&#xA;manager node.&lt;/p&gt;&#xA;&lt;p&gt;If everything is working fine, you now have a docker swarm cluster setup&#xA;and ready to manage services! We&amp;rsquo;ll go through this in our next post. In&#xA;the meantime, you can stop and remove the &lt;code&gt;viz&lt;/code&gt; stack:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker stack rm viz&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;to-be-continued-dot-dot-dot&#34;&gt;To be Continued&amp;hellip; :-)&lt;/h2&gt;&#xA;&lt;p&gt;Now we have a very basic docker swarm setup working and ready to manage&#xA;stack, services and containers :) &amp;hellip; But that will be in my next blog&#xA;post where we&amp;rsquo;ll start managing real services, with&#xA;&lt;a href=&#34;https://docs.traefik.io&#34;&gt;traefik 2&lt;/a&gt; as a reverse proxy with automated&#xA;redirection to https and automatic ssl via&#xA;&lt;a href=&#34;https://letsencrypt.org&#34;&gt;letsencrypt&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;in-this-blog-posts-serie&#34;&gt;In this blog posts serie:&lt;/h2&gt;&#xA;&lt;p&gt;You can follow all posts about my Home Lab setup on the&#xA;&lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;dedicated page&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the Home Lab setup series:&lt;/p&gt;&#xA;&lt;h2 id=&#34;to-do&#34;&gt;To Do&lt;/h2&gt;&#xA;&lt;p&gt;To be writen: Monitoring, Backups, Tests environment, &amp;hellip;&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://docs.docker.com/engine/swarm/key-concepts/&#34;&gt;Docker swarm documentation&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://docs.docker.com/engine/swarm/key-concepts/&#34;&gt;Docker swarm documentation&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:3&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://docs.docker.com/engine/swarm/key-concepts/&#34;&gt;Docker swarm documentation&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:4&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://docs.docker.com/engine/swarm/key-concepts/&#34;&gt;Docker swarm documentation&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:4&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:5&#34;&gt;&#xA;&lt;p&gt;Remember the tip using tmux synchronize-panes in [[][my previous&#xA;blog post]] to launch commands on all servers at once :)&amp;#160;&lt;a href=&#34;#fnref:5&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:6&#34;&gt;&#xA;&lt;p&gt;In my case, to avoid conflicts with my wifi network IPs.&amp;#160;&lt;a href=&#34;#fnref:6&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>My Home Lab 2020, part 1: Context and Architecture choices</title><link>https://bacardi55.io/2020/03/18/my-home-lab-2020-part-1-context-and-architecture-choices/</link><pubDate>Wed, 18 Mar 2020 00:00:00 +0100</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2020/03/18/my-home-lab-2020-part-1-context-and-architecture-choices/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;At the end of last year, I decided to rebuild my home self hosting and&#xA;home automation setup. The main reason was that it was starting to get&#xA;old and was really becoming a mess due to creating it bit by bit and on&#xA;the fly^^.&lt;/p&gt;&#xA;&lt;p&gt;I had stopped hosting my services at home for some time (as I moved&#xA;everything to digitalocean), but always wanted to switch back. I was a&#xA;bit familiar with docker as this is what I use on my DO servlets but I&#xA;had never used Docker Swarm or Kubernetes before and wanted to learn&#xA;more one of them (to at least better grasp the concepts).&lt;/p&gt;&#xA;&lt;p&gt;On the home automation part, it became way too complicated, mostly&#xA;because I was learning at the time and was building it little by little.&#xA;I had a old rpi2 B with &lt;a href=&#34;https://github.com/domoticz/domoticz&#34;&gt;domoticz&lt;/a&gt;, a rpi3 with &lt;a href=&#34;https://kalliope-project.github.io/&#34;&gt;kalliope&lt;/a&gt; and&#xA;&lt;a href=&#34;https://nodered.org/&#34;&gt;nodered&lt;/a&gt;, &amp;hellip; For those reading my blog back&#xA;then, you are familiar with the voice assistant &lt;a href=&#34;https://kalliope-project.github.io/&#34;&gt;Kalliope&lt;/a&gt; that was the brain of&#xA;my home and I was actively participating. One thing though&amp;hellip; I noticed&#xA;that I don&amp;rsquo;t like to talk to a software, that I prefer an easy to access&#xA;interface (web, app, cli, &amp;hellip;) to do the action I wanted&amp;hellip; And that I&#xA;was more into automation than voice control.&lt;/p&gt;&#xA;&lt;p&gt;Of course, this meant moving from a voice assistant centric architecture&#xA;to an automation centric architecture&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Because my home automation system mostly sit on my &amp;ldquo;home lab&amp;rdquo; system&#xA;that I wanted to redo, I&amp;rsquo;ve redone everything during end of December and&#xA;January. The first part was setting up the home lab and will be split in&#xA;a series of blog posts that you can follow &lt;a href=&#34;https://bacardi55.io/categories/homelab/&#34;&gt;here&lt;/a&gt; about the basics setup :).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: Don&amp;rsquo;t get me wrong, I love &lt;a href=&#34;https://kalliope-project.github.io/&#34;&gt;Kalliope&lt;/a&gt; and was using it quite&#xA;extensively for a while&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;. But I must admit my needs and&#xA;requirements has changed&amp;hellip; Hence the re-architecture.&lt;/p&gt;&#xA;&lt;h2 id=&#34;my-architecture-choices&#34;&gt;My Architecture choices&lt;/h2&gt;&#xA;&lt;p&gt;As said, I&amp;rsquo;ve been using docker for some time now, but very &amp;ldquo;manually&amp;rdquo;&#xA;or &amp;ldquo;handmade&amp;rdquo;&amp;hellip; Meaning myself playing docker compose command on&#xA;multiple hosts. I wanted to go to the next level during this reset and&#xA;use my favorite hardware: raspberry pis :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;hardware-raspberry-pi-3-and-4&#34;&gt;Hardware: Raspberry Pi 3 and 4&lt;/h3&gt;&#xA;&lt;p&gt;As said above, the hardware is based on raspberry pis. I&amp;rsquo;m using 1&#xA;raspberry 3 and 3 raspberry pi 4 (4gb RAM) for my cluster (though it&#xA;might be easier if you only 1 type of architecture, as the rpi 4 differ&#xA;from the 3).&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve also bought 4 fast USB keys for the cluster storage.&lt;/p&gt;&#xA;&lt;p&gt;And to push the nerdgasm to the limit, I purchased&#xA;&lt;a href=&#34;https://www.amazon.com/GeeekPi-Cluster-Raspberry-Heatsink-Stackable/dp/B07MW24S61/ref=sr_1_5&#34;&gt;this cluster case for 4 raspberry pis&lt;/a&gt; to tidy up the installation. They are&#xA;all connected via short ethernet cables to my Netgear router :-).&lt;/p&gt;&#xA;&lt;h3 id=&#34;software-selection&#34;&gt;Software selection&lt;/h3&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve decided to go with the following stack:&lt;/p&gt;&#xA;&lt;h4 id=&#34;os-raspbian&#34;&gt;OS: Raspbian&lt;/h4&gt;&#xA;&lt;p&gt;I selected (as usual) &lt;a href=&#34;https://www.raspbian.org/&#34;&gt;raspbian&lt;/a&gt; as the OS for my raspberry pis (3 and 4s).&lt;/p&gt;&#xA;&lt;p&gt;For a headless installation of raspbian, see my old post&#xA;&lt;a href=&#34;https://bacardi55.io/posts/2017/11/5/headless-raspberrypi-installation/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I won&amp;rsquo;t talk about how the post installation of raspbian for a server,&#xA;there are plenty of guide on the internet for this :).&lt;/p&gt;&#xA;&lt;h4 id=&#34;containers-orchestration-docker-swarm&#34;&gt;Containers orchestration: Docker Swarm&lt;/h4&gt;&#xA;&lt;p&gt;This is where I spend most time thinking between &lt;a href=&#34;https://kubernetes.io/&#34;&gt;Kubernetes&lt;/a&gt; and &lt;a href=&#34;https://docs.docker.com/engine/swarm/&#34;&gt;Docker Swarm&lt;/a&gt;&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;The &amp;ldquo;obvious&amp;rdquo; choice, if I wanted to have an architecture as close as&#xA;what most advance containers users are doing, was &lt;a href=&#34;https://kubernetes.io/&#34;&gt;Kubernetes&lt;/a&gt; (or its lighter version&#xA;&lt;a href=&#34;https://k3s.io/&#34;&gt;k3s&lt;/a&gt; perfect for raspberry pis :-)). But the reality&#xA;is that I don&amp;rsquo;t really need that level of complexity for what i&amp;rsquo;m doing&#xA;and I&amp;rsquo;m not a devops / sysadmin&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; at my job so it wouldn&amp;rsquo;t help on&#xA;my day to day job either to learn it.&lt;/p&gt;&#xA;&lt;p&gt;The other choice was &lt;a href=&#34;https://docs.docker.com/engine/swarm/&#34;&gt;Docker Swarm&lt;/a&gt;, which after reading about it seemed so much simpler than&#xA;Kubernetes. It also seems that it is not that much use in big or complex&#xA;architecture (at least not at K8s scale) but seems to do more than the&#xA;job for my small and limited use case of homemade selfhoster :-).&lt;/p&gt;&#xA;&lt;p&gt;So I made the choice of Docker Swarm last December&amp;hellip;&lt;/p&gt;&#xA;&lt;h4 id=&#34;shared-file-system-glusterfs&#34;&gt;Shared File System: GlusterFS&lt;/h4&gt;&#xA;&lt;p&gt;Of course, the main issue when you talk about containers architecture is&#xA;storage. When I was doing it the poorsman&amp;rsquo;s way&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt; (aka, containers&#xA;started via docker-compose command on the host directly), it was easy to&#xA;bypass this issue by just using the local storage.&lt;/p&gt;&#xA;&lt;p&gt;When you move to a real cluster architecture, meaning multiple servers,&#xA;then you need to have a shared storage between these servers. And it&amp;rsquo;s&#xA;better if the storage is on a dedicated drive&amp;hellip; This is why I purchased&#xA;4 100GB usb keys, to use them as a shared storage.&lt;/p&gt;&#xA;&lt;p&gt;Now for the technology itself, I went with&#xA;&lt;a href=&#34;https://www.gluster.org/&#34;&gt;GlusterFS&lt;/a&gt;: &amp;gt; Gluster is a free and open&#xA;source software scalable network filesystem.&lt;/p&gt;&#xA;&lt;p&gt;By using Gluster, I can create a shared folder (so all the usb keys will&#xA;have a copy of it) and make sure that data are up to date on all&#xA;raspberry pis :).&lt;/p&gt;&#xA;&lt;p&gt;I use it both to store services definition (&lt;code&gt;docker-compose.yml&lt;/code&gt;) and&#xA;services data.&lt;/p&gt;&#xA;&lt;h2 id=&#34;to-be-continued-dot-dot-dot&#34;&gt;To be Continued&amp;hellip; :-)&lt;/h2&gt;&#xA;&lt;p&gt;To avoid having way too long blog post, I&amp;rsquo;ll stop here for now that we&#xA;have an idea of what will be the setup of my home lab! Next we&amp;rsquo;ll go to&#xA;actual setup of docker, docker-compose, docker-swarm and glusterFS.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;A good proof ot that is the &lt;a href=&#34;https://kalliope-project.github.io/neurons_marketplace.html&#34;&gt;number of neuron&lt;/a&gt; I&amp;rsquo;ve created for &lt;a href=&#34;https://kalliope-project.github.io/&#34;&gt;Kalliope&lt;/a&gt; over time :)&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;I&amp;rsquo;m just an enthusiast selfhoster as a hobby, not a professional,&#xA;which explains why I really don&amp;rsquo;t know what I&amp;rsquo;m talking about&#xA;:-).&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:3&#34;&gt;&#xA;&lt;p&gt;Not meant in a wrong way, but the way I was doing it was more the&#xA;level 1 of managing docker container. I&amp;rsquo;m not saying I moved to&#xA;10 and achieve perfection, but I feel I&amp;rsquo;m more at 4 or 5 now :P&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>What have I been up to lately</title><link>https://bacardi55.io/2017/05/16/what-have-i-been-up-to-lately/</link><pubDate>Tue, 16 May 2017 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2017/05/16/what-have-i-been-up-to-lately/</guid><description>&lt;h2 id=&#34;still-alive&#34;&gt;Still alive ?&lt;/h2&gt;&#xA;&lt;p&gt;Yes! I know I&amp;rsquo;ve posted a lot in January / February and disappeared a&#xA;bit after that ^^. I have been busy at work and at home, and to be&#xA;honest I started working on another topic of my &amp;ldquo;todo geek list&amp;rdquo; :&#xA;Reinstalling my servers where I host my application and retake ownership&#xA;of my data.&lt;/p&gt;&#xA;&lt;p&gt;I also wanted to switch for manual installing all software on my servers&#xA;and leveraging docker to put the app within container (and also improve&#xA;a bit my knowledge in this area^^)&lt;/p&gt;&#xA;&lt;p&gt;Here is what I have setup so far (all on docker containers):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;At home (on a RaspberryPi 3):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://gogs.io/&#34;&gt;Gogs&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://github.com/drone/drone&#34;&gt;DroneCI&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://wallabag.org&#34;&gt;Wallabag&lt;/a&gt; to save article for later,&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://github.com/shaarli/Shaarli&#34;&gt;Shaarli&lt;/a&gt; to save interesting links,&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://lut.im/&#34;&gt;Lutim&lt;/a&gt; to share images,&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://prometheus.io/&#34;&gt;Prometheus&lt;/a&gt; and&#xA;&lt;a href=&#34;https://grafana.com/&#34;&gt;Grafana&lt;/a&gt; for monitoring&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://wiki.nginx.org/&#34;&gt;Nginx&lt;/a&gt; to manage all the app behind it on the same ports 80/443&lt;/li&gt;&#xA;&lt;li&gt;HTTPS everywhere (via &lt;a href=&#34;https://letsencrypt.org&#34;&gt;letysencprypt&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;On a Digital Ocean droplet:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My &lt;a href=&#34;https://github.com/tootsuite/mastodon&#34;&gt;mastodon&lt;/a&gt; instance and a &lt;a href=&#34;https://feed2toot.readthedocs.io/en/latest/&#34;&gt;feed2toot&lt;/a&gt; bot&lt;/li&gt;&#xA;&lt;li&gt;A &lt;a href=&#34;https://about.mattermost.com/&#34;&gt;Mattermost&lt;/a&gt; chat (opensource slack)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://prometheus.io/&#34;&gt;Prometheus&lt;/a&gt; for monitoring (link to my RPI Grafana)&lt;/li&gt;&#xA;&lt;li&gt;HTTPS everywhere (via &lt;a href=&#34;https://letsencrypt.org&#34;&gt;letysencprypt&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As you can see, i have been busy (with this, work, my life and of course&#xA;starcraft2 ^^&amp;quot;), but unfortunately, I&amp;rsquo;m not done yet^^&lt;/p&gt;&#xA;&lt;p&gt;My todolist still contains:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Migrate all my repos from github to Gogs (at least mirroring)&lt;/li&gt;&#xA;&lt;li&gt;Add mattermost bots (hubot and RSS)&lt;/li&gt;&#xA;&lt;li&gt;Monitoring alerts via email (?)&lt;/li&gt;&#xA;&lt;li&gt;Redo mail server&lt;/li&gt;&#xA;&lt;li&gt;Backup automated policy&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;ok-dot-dot-dot-that-s-cool-but-why&#34;&gt;Ok&amp;hellip; That&amp;rsquo;s cool, but why ?&lt;/h2&gt;&#xA;&lt;p&gt;Well, since a long time now, I&amp;rsquo;m trying to advocate for data privacy,&#xA;self hosting a trying to stop feeding (too much) the GAFAM. I&amp;rsquo;m hosting&#xA;my own server mail since 10 years as well as my websites (like this&#xA;blog), but i wanted to go further and take ownership again of my data.&lt;/p&gt;&#xA;&lt;p&gt;For those who speaks french and didn&amp;rsquo;t see it (old from 2007&amp;hellip; but&#xA;still so true), i recommend this great video of Benjamin Bayart:&#xA;&lt;a href=&#34;https://www.fdn.fr/actions/confs/internet-libre-ou-minitel-2-0/&#34;&gt;Internet or minitel 2.0&lt;/a&gt; (For non French people, look up online what Minitel was&#xA;:)).&lt;/p&gt;&#xA;&lt;p&gt;From what I read on mastodorn, it seems B. Bayart might do a new version&#xA;of that talk :). I don&amp;rsquo;t really want to explain why you should care&#xA;about your data, there are a lot of good articles online.&lt;/p&gt;&#xA;&lt;h2 id=&#34;sounds-cool-i-want-to-do-it&#34;&gt;Sounds cool, i want to do it!&lt;/h2&gt;&#xA;&lt;p&gt;I&amp;rsquo;m planing to transform this experience into a series of blog posts:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Continuous integration setup: Gogs , DroneCI and automatic builds when&#xA;a push happens. Bonus: push notification on a private channel of my&#xA;mattermost instance.&lt;/li&gt;&#xA;&lt;li&gt;Mastodon and feed2toot bot (will be an update of my previous post&#xA;about feed2toot as I don&amp;rsquo;t plan to rewrite the good installation doc)&lt;/li&gt;&#xA;&lt;li&gt;Cool / useful apps selfhosted apps on RaspberryPi: Wallabag, Shaarli&#xA;and Lutim&lt;/li&gt;&#xA;&lt;li&gt;Mattermost and Hubot&lt;/li&gt;&#xA;&lt;li&gt;Monitoring, graph and alerts&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I&amp;rsquo;ll update this post to add the link to the post series.&lt;/p&gt;&#xA;&lt;p&gt;Talk to you soon!&lt;/p&gt;&#xA;</description></item>
    <item>
      
      <title>Running feed2toot in a docker container</title><link>https://bacardi55.io/2017/04/22/running-feed2toot-in-a-docker-container/</link><pubDate>Sat, 22 Apr 2017 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2017/04/22/running-feed2toot-in-a-docker-container/</guid><description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;Today, a very quick blog post on a how to install &lt;a href=&#34;https://gitlab.com/chaica/feed2toot&#34;&gt;feed2toot&lt;/a&gt; in a docker&#xA;container. Feed2toot is a python application that will send toot on&#xA;Mastodon for each item of an RSS feed.&lt;/p&gt;&#xA;&lt;p&gt;If you want to install Mastodon, I suggest you read here:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Docker-Guide.md&#34;&gt;Offical documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://hackernoon.com/deploying-mastodon-on-digital-ocean-f54b94c7f5b8&#34;&gt;Intall guide for Digital ocean&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://psychedeli.cat/mastodon/&#34;&gt;French intall guide on Debian&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;if you want to install &lt;a href=&#34;https://gitlab.com/chaica/feed2toot&#34;&gt;feed2toot&lt;/a&gt; in a container to be&#xA;able to create toot from an RSS feed, then keep reading :).&lt;/p&gt;&#xA;&lt;h2 id=&#34;create-the-docker-image&#34;&gt;Create the docker image&lt;/h2&gt;&#xA;&lt;h3 id=&#34;get-the-files&#34;&gt;Get the files&lt;/h3&gt;&#xA;&lt;p&gt;You can start with my repo as a base:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    git clone https://git.bacardi55.org/bacardi55/docker-feed2toot.git&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;build-the-container-image&#34;&gt;Build the container image&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    cd docker-feed2toot&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build -t b55/feed2toot .&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;You can change the tag name :)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;configure-feed2toot&#34;&gt;Configure feed2toot&lt;/h2&gt;&#xA;&lt;p&gt;Edit the &lt;code&gt;conf/feed2toot.ini&lt;/code&gt;, &lt;code&gt;conf/rsslinks.txt&lt;/code&gt; and&#xA;&lt;code&gt;conf/hashtags.txt&lt;/code&gt; files as describe in the [[][official&#xA;documentation]]&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The current release needs a hashtags file, even empty! It will become&#xA;optional in the next release&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;run&#34;&gt;Run&lt;/h2&gt;&#xA;&lt;h3 id=&#34;get-your-credential-first&#34;&gt;Get your credential first&lt;/h3&gt;&#xA;&lt;p&gt;Then, register your application with your mastodon account:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker run --rm -v &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;pwd&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;/conf:/etc/feed2toot -it b55/feed2toot register_feed2toot_app&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It will ask your password (but won&amp;rsquo;t save it) to generate token files.&lt;/p&gt;&#xA;&lt;h3 id=&#34;test-the-first-run&#34;&gt;Test the first run&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker run --rm -v &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;pwd&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;/conf:/etc/feed2toot b55/feed2toot&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Go to your user mastodon page, you should see the toot generated :)&lt;/p&gt;&#xA;&lt;h3 id=&#34;automate&#34;&gt;Automate&lt;/h3&gt;&#xA;&lt;p&gt;To avoid launching the app manually, let&amp;rsquo;s put a simple task in our&#xA;crontab:&lt;/p&gt;&#xA;&lt;p&gt;Open the crontab file: &lt;code&gt;crontab -e&lt;/code&gt; and insert this line:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    @hourly docker run --rm -v /path/to/conf:/etc/feed2toot b55/feed2toot&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And you should be good to go!&lt;/p&gt;&#xA;</description></item>
  </channel>
</rss>
