<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[rm -rf /]]></title><description><![CDATA[The coding journey through time and space]]></description><link>https://blog.petermartyniak.com/</link><image><url>https://blog.petermartyniak.com/favicon.png</url><title>rm -rf /</title><link>https://blog.petermartyniak.com/</link></image><generator>Ghost 3.0</generator><lastBuildDate>Fri, 04 Feb 2022 10:15:19 GMT</lastBuildDate><atom:link href="https://blog.petermartyniak.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Changing Kibana to listen on port 80 without running it as root]]></title><description><![CDATA[<p>As I'm tidying up my ELK setup I thought that accessing kibana via :5601 is not necessary, so I modified the <code>/etc/kibana/kibana.yml</code> server port to <code>80</code> just to be reminded, that on linux ports below 1024 are accessible only by root.</p><p>Running kibana as root is not</p>]]></description><link>https://blog.petermartyniak.com/changing-kibana-port-to-80-without-running-it-as-root/</link><guid isPermaLink="false">5f1b09b70dc04804b9058cb2</guid><category><![CDATA[kibana]]></category><category><![CDATA[elk]]></category><category><![CDATA[ufw]]></category><category><![CDATA[logging]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Fri, 24 Jul 2020 16:51:20 GMT</pubDate><content:encoded><![CDATA[<p>As I'm tidying up my ELK setup I thought that accessing kibana via :5601 is not necessary, so I modified the <code>/etc/kibana/kibana.yml</code> server port to <code>80</code> just to be reminded, that on linux ports below 1024 are accessible only by root.</p><p>Running kibana as root is not an option, so I looked at other solutions. The quickest one is to redirect the port 5601 to 80 using IPTABLES. As that VM only runs kibana and elasticsearch I will not have port clashes.</p><p>Next step is to open port 80 in UFW<br><code>sudo ufw allow 80/tcp</code></p><p>Having that sorted we can add redirect. UFW does not have commands to set it up, but it's quite easu to do it in config files</p><p>Execute <code>sudo vim /etc/ufw/before.rules</code> and just before  <code>*filter</code> add: </p><pre><code>*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -p tcp --dport 80 -j REDIRECT --to-poty 5601
COMMIT
</code></pre><p>Restart ufw <code>sudo ufw enable</code> and you should be all set</p><p></p><p>Links</p><pre><code>https://serverfault.com/questions/238563/can-i-use-ufw-to-setup-a-port-forward
https://serverfault.com/questions/112795/how-to-run-a-server-on-port-80-as-a-normal-user-on-linux</code></pre>]]></content:encoded></item><item><title><![CDATA[Docker on remote host && docker-compose]]></title><description><![CDATA[How to set up remote docker and docker-compose]]></description><link>https://blog.petermartyniak.com/remote-docker-host-docker-compose/</link><guid isPermaLink="false">5eb545cb5f7acd0654738cd2</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker-compose]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Fri, 08 May 2020 12:30:00 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2020/05/compose.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2020/05/compose.png" alt="Docker on remote host && docker-compose"><p>In my HomeLab I have two RancherOS hosts, and now I added 7 Raspberry Pi's and I'm planning on adding more hosts in the future. Initially I was just connecting via <code>ssh</code> and executing commands on the hosts. For Rancher running docker-compose is a little extra work, as it doesn't have it available. The quickest solution I have vor it is:</p><p><code>docker run --rm -it -v ${PWD}:/rx -v /var/run/docker.sock:/var/run/docker.sock -w /rx docker/compose up -d</code></p><p>This command:</p><ul><li> <code>docker run</code> gets docker-compose container from docker hub</li><li><code>--rm</code> removes the container after closing it, or after the command finishes</li><li><code>-it</code> launches interactive terminal</li><li><code>-v ${PWD}:/rx</code> mounts current directory as /rx on the container</li><li><code>-v /var/run/docker.sock:/var/run/docker.sock</code> mounts local docker socket, so that the compose container can control your docker instance</li><li><code>-w</code> sets the working directory</li><li><code>docker/compose</code> is the name of the image from docker hub</li><li><code>up -d</code> is the command we send to the container</li></ul><p>All this is equivalent to running <code>docker-compose up -d</code> but without having compose installed</p><p>This approach is not optimal for having multiple remote hosts, so I was researching how could I use my local docker engine and control the remote hosts.</p><p>The quickest way is to run <code>export DOCKER_HOST=ssh://username@&lt;machine.ip&gt;</code> , that makes docker use the remote HOST. There is a newer way using <code>docker context</code>. It allows you to set and use multiple configs and easily switch between them. </p><p>To list the existing contexts run <code>docker context ls</code></p><figure class="kg-card kg-image-card"><img src="https://blog.petermartyniak.com/content/images/2020/05/image.png" class="kg-image" alt="Docker on remote host && docker-compose"></figure><p>To create a new context run <code>docker context create &lt;context_name&gt; --docker "host=ssh://&lt;username&gt;@&lt;host or ip&gt;"</code></p><p>To use the newly created context you can either run <code>docker --context &lt;context_name&gt; command</code> for each command or run <code>docker context use &lt;context_name&gt;</code>. Important note is that if you set <code>DOCKER_HOST</code> variable it will override docker context, so make sure to unset it.</p><h2 id="docker-compose">docker-compose</h2><p>What about docker-compose? The new-new version supports docker contexts, but it's still in RC as I write this post, so the only other way is to set <code>DOCKER_HOST</code>, it will use it automatically.</p><p><code>paramiko.ssh_exception.ChannelException: ChannelException(1, 'Administratively prohibited')</code> or similar errors are caused by sshd MaxSessions default value of 10, where docker-compose tries to open 25 connections. Solution is to edit <code>/etc/ssh/sshd_config</code> and changing <code>MaxSessions</code> to something above 25.</p><p></p><p>Links:</p><ul><li><a href="https://github.com/docker/compose/issues/6463">https://github.com/docker/compose/issues/6463</a></li><li><a href="https://github.com/docker/docker-py/issues/2246">https://github.com/docker/docker-py/issues/2246</a></li><li><a href="https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/">https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/</a></li></ul>]]></content:encoded></item><item><title><![CDATA[Running Docker on Raspberry Pi Zero (W)]]></title><description><![CDATA[How to run docker on Raspberry Pi Zero in 2020]]></description><link>https://blog.petermartyniak.com/running-docker-on-raspberry-pi-zero-w/</link><guid isPermaLink="false">5eb1d1795f7acd0654738bb1</guid><category><![CDATA[Docker]]></category><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[PiLab]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Fri, 08 May 2020 11:29:55 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2020/05/dockeronrapi.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2020/05/dockeronrapi.png" alt="Running Docker on Raspberry Pi Zero (W)"><p>I'm working on my pi 'cluster', built using:</p><ul><li>1x Raspberry Pi 4</li><li>4x Raspberry Pi 0 w</li><li>2x Raspberry Pi 0</li></ul><p>Current use case is to run a python distributed task processor built on top of celery, Pi 0s and the controller on Pi4. The Backend for the processor is</p><ul><li>RabbitMQ for task distribution</li><li>Redis for collecting results (celery backend)</li></ul><p>I started with learning about celery (<a href="http://www.celeryproject.org/">http://www.celeryproject.org/</a>). When I got a simple worker up and running (following the basic tutorial) I started thinking about deployment. </p><p>The worker code, is in python, I was searching for a way to build a CI/CD pipeline from my Gitlab server, another requirement was to install worker as a service. I found this article to be the most insightful (<a href="https://www.nylas.com/blog/packaging-deploying-python/">https://www.nylas.com/blog/packaging-deploying-python/</a>). It lists couple solutions:</p><ul><li>git &amp; pip</li><li>PEX</li><li>deb packages (dh-virtualenv)</li><li>docker</li></ul><p>After investigating pros and cons (you can find them in the lined article) I decided that the minimal fuss solution is docker.</p><p>Next step was to get docker on all my pi nodes. Another problem, installing docker on pi0(w) does not work out of the box (<a href="https://www.reddit.com/r/raspberry_pi/comments/d29tg0/failing_to_get_docker_installed_on_a_pi_zero_w/">https://www.reddit.com/r/raspberry_pi/comments/d29tg0/failing_to_get_docker_installed_on_a_pi_zero_w/</a>) (<a href="https://github.com/moby/moby/issues/38175">https://github.com/moby/moby/issues/38175</a>) </p><p>The suggested ways of getting docker on pi0 are:</p><ul><li>HypriotOS</li><li>Downgrading containerd </li></ul><p>I started with HypriotOS as it seemed straightforward. Flashed the microSD card with 1.12.0, added my cloud-init (added ssh key, set static IP and hostname)</p><p>The result was - well, it booted up on Pi0, but the cloud-init didn't work, the <code>pirate</code> user wasn't created and I couldn't log in to the system. Found out it's a known issue (<a href="https://github.com/hypriot/image-builder-rpi/issues/340">https://github.com/hypriot/image-builder-rpi/issues/340</a>) but the suggested workaround wasn't suitable for me.</p><p>I didn't want to mess with raspbian packages, so I decided to try and get Hypriot to work. Putting that flashed microSD card into Pi4 worked fine. I was curious, if after getting cloud-init to work properly on Pi4, it would work after transferring the card to Pi0. And it did, that way I got a working hypriotOS, with docker on my Pi0s! I flashed all 6 nodes, flashed Pi4... and discovered another problem (or actually couple of them)</p><ul><li>The network did not always start properly, on random occasions it would fail the wpa_supplicant init and crash. The error suggested that <code>/dev/stderr</code> was not initialised.</li><li>Second problem was:</li></ul><pre><code class="language-bash">ctrl_iface exists and seems to be in use - cannot override it
Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore
Failed to initialize control interface 'DIR=/var/run/wpa_supplicant GROUP=netdev'.
You may have another wpa_supplicant process already running or the file was
left by an unclean termination of wpa_supplicant in which case you will need
to manually remove this file before starting wpa_supplicant again.</code></pre><ul><li>Third problem was that the wlan0 interface was getting secondary IP address assigned from DHCP</li></ul><p>I fixed the first problem by adding a little sed magic to cloud-init runcmd: (debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=838291)<br><code>- [ sed, -i, -e, 's/\/dev\/stderr/\&amp;2/g', /etc/wpa_supplicant/functions.sh]</code> <br><code>- [ sed, -i, -e, 's/\/dev\/stdout/\&amp;1/g', /etc/wpa_supplicant/functions.sh]</code> </p><p>Second problem, this solution worked (<a href="https://raspberrypi.stackexchange.com/questions/50967/raspi-3-wlan0-not-associated">https://raspberrypi.stackexchange.com/questions/50967/raspi-3-wlan0-not-associated</a>) but it is ad-hoc fix, not suitable for cluster node, I could as well just unplug and plug in the power manually to have same effect(usually after rebooting the network worked, it was really random)</p><p>The third problem was related to dhcpcd and /etc/network/interfaces miss configuration. Default cloud-init set the static IP in the <code>/etc/network/interface.d/wlan0</code> there was no entry in the dhcpcd.conf for it. While debugging the issue, I stopped the dhcpcd service, and the secondary IP disappeared, together with any host resolution... So it wasn't the way. (I later discovered that adding  <code>denyinterfaces wlan0</code> to dhcpcd.conf, but didn't have a chance to try it)</p><p>I was able to fix 2/3 issues, so it was still not good enough for my use, I decided to try playing with Raspbian and applying everything I have learned so far.</p><p>I got the latest Raspbian buster lite, flashed the microSD card, installed it on Pi4 (important) and I was able to install docker with no problem (<a href="https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl">source</a>)</p><pre><code>curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi
docker run hello-world

sudo apt install -y libffi-dev libssl-dev python3 python3-pip
sudo apt-get remove python-configparser
sudo pip3 install docker-compose</code></pre><p>After testing that it works on Pi0 (hooray) I added zsh, ohmyzsh, powerline10k, and vim.</p><p>Having a fully operational system I started to think about how to flash all the other nodes quickly? I went with creating an image from my microSD card, shrinking it, flashing it to other cards and adjusting hostnames and ip addresses manually. </p><pre><code># run the commands on Linux, not WSL, if on VM, mount the SD card to the VM
sudo fdisk -l # find the device name for your card, like /dev/mmcsd
sudo dd if=/dev/mmcsd of=/path/to/your/image

# let it run, it might take couple minutes, and there is no output.

wget  https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
chmod +x pishrink.sh
sudo ./pishrink /path/to/your/image.img /path/to/your/image.shrinked.img 
gzip -9 /path/to/your/image.shrinked.img

# First image for me was 32GB - as the size of the card. Shrinked version was below 4GB, gzipped around 900MB
</code></pre><p>Now you can use the image with Etcher (<a href="https://github.com/balena-io/etcher">https://github.com/balena-io/etcher</a>)</p><p>That's it.</p><p></p><p></p><p><strong>Links</strong></p><p><a href="https://packaging.python.org/overview/">https://packaging.python.org/overview/</a></p><p>.<a href="https://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address">https://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address</a></p><p>.<a href="https://raspberrypi.stackexchange.com/questions/39785/differences-between-etc-dhcpcd-conf-and-etc-network-interfaces">https://raspberrypi.stackexchange.com/questions/39785/differences-between-etc-dhcpcd-conf-and-etc-network-interfaces</a></p><p>.<a href="https://raspberrypi.stackexchange.com/questions/13359/where-does-my-secondary-ip-come-from">https://raspberrypi.stackexchange.com/questions/13359/where-does-my-secondary-ip-come-from</a></p><p>Clone and shrink Raspbian image: <a href="https://medium.com/platformer-blog/creating-a-custom-raspbian-os-image-for-production-3fcb43ff3630">https://medium.com/platformer-blog/creating-a-custom-raspbian-os-image-for-production-3fcb43ff3630</a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Docker-Compose with RancherOS]]></title><description><![CDATA[How to get docker-compose on RancherOS]]></description><link>https://blog.petermartyniak.com/docker-compose-with-rancheros/</link><guid isPermaLink="false">5ea1af175f7acd0654738b3c</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker-compose]]></category><category><![CDATA[RancherOS]]></category><category><![CDATA[containers]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Thu, 23 Apr 2020 15:17:56 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2020/04/docker.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2020/04/docker.png" alt="Docker-Compose with RancherOS"><p>I was trying to get SonarQube test instance for my HomeLab, and found out Bitnami docker image (<a href="https://github.com/bitnami/bitnami-docker-sonarqube">link</a>). I thought about using my RancherOS freshly updated VM for trying to run it. </p><p>The first obstacle happened to be the <code>curl</code>. There is no curl installed on bare RancherOS instance. But there is <code>wget</code> so a simple fix to replace those commands.</p><p>The second problem was bigger, you get <code>docker-compose.yml</code> file, and have to run docker-compose to start the stack. But there is no docker-compose on RancherOS...</p><p>After searching the web I discovered there is a docker image with docker compose, but no instructions on how to execute it from container. </p><p>After some googling I crafted a woring command:</p><p><code>docker run --rm -it -v ${PWD}:/tmp -v /var/run/docker.sock:/var/run/docker.sock -w /tmp docker/compose up</code></p><ul><li><code><code>-v ${PWD}:/tmp</code></code> mounts the current directory as <code>/tmp</code> on docker container</li><li><code>-v /var/run/docker.sock:/var/run/docker.sock</code> allows docker-compose to talk to rancherOS docker</li><li><code>-w /tmp</code> sets the working directory for docker container</li><li><code>docker/compose</code> is the latest compose image</li><li><code>up</code> is the command</li></ul><p>Overall it's the equivalent of running <code>docker-compose up</code> but without having docker-compose installed/available.</p><p></p><h3 id="usefull-links-">Usefull links:</h3><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://stackoverflow.com/questions/41803919/running-docker-compose-with-rancher-os"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Running docker-compose with Rancher OS</div><div class="kg-bookmark-description">I am trying with aws rancher os. I want to create and run a docker-compose file with the same rancher OS. When I am trying with Docker-compose up command I am getting the error ’not recognized doc...</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a" alt="Docker-Compose with RancherOS"><span class="kg-bookmark-author">NGN</span><span class="kg-bookmark-publisher">Stack Overflow</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded" alt="Docker-Compose with RancherOS"></div></a></figure>]]></content:encoded></item><item><title><![CDATA[RancherOS cloud-init (cloud-config) setup (2020 update)]]></title><description><![CDATA[Setting up RancherOS with cloud-config file]]></description><link>https://blog.petermartyniak.com/rancheros-cloud-init-cloud-config-setup-2020-update/</link><guid isPermaLink="false">5ea1aa435f7acd0654738ac1</guid><category><![CDATA[RancherOS]]></category><category><![CDATA[rancher]]></category><category><![CDATA[cloud-init]]></category><category><![CDATA[cloud-config]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Thu, 23 Apr 2020 15:04:14 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2020/04/0_wA9Z0-FWS3frubM8.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2020/04/0_wA9Z0-FWS3frubM8.png" alt="RancherOS cloud-init (cloud-config) setup (2020 update)"><p>As part of the HomeLab refresh, I started updating my tools and dependencies, one of the pieces was RancherOS image that I used for running Gitlab runners.</p><p>When I tried following my old notes (<a href="https://blog.petermartyniak.com/setting-up-rancheros-using-cloud-init-yml/">link</a>) I realised that some commands were no longer working.</p><p>I'm experimenting with XCP-ng (xen) this time, so cannot find a way to inject cloud-init on startup. I got the latest rancherOS iso, loaded it to my iso library and booted the newly created vm. Because I couldn't inject the config file directly, I had to find a way to get it to the rancherOS vm. In the old days I would just use <br><code>python -m  SimpleHTTPServer 8000</code> in the directory with files I wanted to use, but with python 2.x reaching EOL I moved to a modern, python 3.x syntax: <br><code>python -m http.server 8000</code>. That command starts a http server in the directory you run it in, so I can access all the files using HTTP protocol from all the machines in my homelab network. </p><p>The config file that works, looks like:</p><pre><code>#cloud-config

hostname: rancherX

rancher:
  network:
    interfaces:
      eth*:
        dhcp: false
      eth0:
        address: 192.168.0.2/24
        gateway: 192.168.0.1
    dns:
      nameservers:
        - 192.168.0.1

ssh_authorized_keys:
  - ssh-rsa ASDF..GF==</code></pre><p>This config file allows you to quickly set up </p><ul><li>hostname</li><li>static ip</li><li>nameservers</li><li>ssh key for remote access</li></ul><p>Now to install the rancherOS you have to run:</p><p><code>sudo ros install -c <a href="http://10.0.0.2:8000/rancher-cloud-config.yml">http://put.your.ip.here:8000/rancher-cloud-config.yml</a> -d /dev/mount_name</code></p><p>I noticed it doesn't allow to run without specifying the mount to install, so seems like the in-memory commands are no longer working</p>]]></content:encoded></item><item><title><![CDATA[Upgrading gitlab-ce version]]></title><description><![CDATA[<p>The time has come for me to revisit my local dev-lab, one of the things I'd like to do first is update the software versions of the tools I use. First tool is - Gitlab</p><p>When I started my lab, I installed Gitlab CE from bitnami, version 11. The current</p>]]></description><link>https://blog.petermartyniak.com/upgrading-gitlab-ce-version/</link><guid isPermaLink="false">5e9d999a5f7acd0654738a23</guid><category><![CDATA[GitLab]]></category><category><![CDATA[update]]></category><category><![CDATA[upgrade]]></category><category><![CDATA[bitnami]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Mon, 20 Apr 2020 13:51:59 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2020/04/gitlab.svg" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2020/04/gitlab.svg" alt="Upgrading gitlab-ce version"><p>The time has come for me to revisit my local dev-lab, one of the things I'd like to do first is update the software versions of the tools I use. First tool is - Gitlab</p><p>When I started my lab, I installed Gitlab CE from bitnami, version 11. The current version (as of April 2020) is version 12.</p><p>The upgrade process seems quite simple</p><ul><li><code>sudo apt update</code></li><li><code>sudo apt install gitlab-ce</code></li></ul><p>Let's see what's going to break :) </p><p>The first problem I encountered is the expired PUBKEY<br>(<em>The following signatures couldn't be verified because the public key is not available: NO_PUBKEY</em>). <br>Fix is quite simple :</p><ul><li><code>curl --silent https://packages.gitlab.com/gpg.key | sudo apt-key add -</code></li></ul><p>Now update should work. When I run install, I got a notification that I', trying to upgrade from major version <code>11</code> to major version <code>12</code>, and I first have to upgrade to version <code>11.11</code> ...</p><p>Now - how do I install this version? First I have to find the specific version number</p><ul><li><code>apt-cache madison gitlab-ce</code> and because there are a lot of version and I only care about 11.11, I will pipe it to grep <code>| grep 11.11</code></li><li>I found version <code>11.11.8-ce.0</code></li><li>Now to install the specific verion I run <code>sudo apt install gitlab-ce=11.11.8-ce.0</code></li></ul><p>If everything worked fine, now it's time to check if the gitlab server behaves properly - open the UI, pull and push some code.</p><p>Everything was fine, so I can proceed with latest version instalation</p><ul><li><code>sudo apt install gitlab-ce</code></li></ul><p> That's it! :)</p><p></p><p></p><p></p><p>Links:</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://blog.sleeplessbeastie.eu/2020/04/12/how-to-update-gitlab-repository-signing-key/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to update GitLab repository signing key</div><div class="kg-bookmark-description">GitLab repository signing key was updated at the beginning of the April, so you can get an error during the signature verification.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://blog.sleeplessbeastie.eu/favicon.ico" alt="Upgrading gitlab-ce version"><span class="kg-bookmark-author">Milosz Galazka</span></div></div></a></figure>]]></content:encoded></item><item><title><![CDATA[Register a Docker GitLab runner with 
a self-signed CA certificate]]></title><description><![CDATA[<p>If you have a GitLab instance using your self-signed certificate, you have to add it to machines pulling the code, and to the runner, so that they can securely communicate with the server.</p><p>I'm using docker based gitlab-runner, to add the cert to it follow these steps:</p><p>Make sure you</p>]]></description><link>https://blog.petermartyniak.com/register-docker-gitlab-runner-with-self-signed-ca-certificate/</link><guid isPermaLink="false">5dc8be786a2c740546e8dbf0</guid><category><![CDATA[GitLab]]></category><category><![CDATA[Docker]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Thu, 15 Nov 2018 17:27:27 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2018/11/gitlab.svg" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2018/11/gitlab.svg" alt="Register a Docker GitLab runner with 
a self-signed CA certificate"><p>If you have a GitLab instance using your self-signed certificate, you have to add it to machines pulling the code, and to the runner, so that they can securely communicate with the server.</p><p>I'm using docker based gitlab-runner, to add the cert to it follow these steps:</p><p>Make sure you have the certificate, I'm using the root pem certificate file.</p><p>Copy the file to your docker box and rename it to ca.crt (yes, change the file extension!)</p><p>Next step is to run the temporary container, mounting the config directory and registering it with gitlab: </p><!--kg-card-begin: markdown--><pre><code>Run: 
docker run --rm -t -i \
    -v /srv/gitlab-runner/config:/etc/gitlab-runner \
    -v /path-to-your-cert/ca.crt:/etc/gitlab-runner/certs/ca.crt \
    --name gitlab-runner gitlab/gitlab-runner register
</code></pre>
<!--kg-card-end: markdown--><p>You are going to be asked a few questions now: (borrowed from <a href="https://docs.gitlab.com/runner/register/index.html#docker">gitlab documentation</a>). You can get the required information from your gitlab server<br><code>https://your-gitlab.url/admin/runners</code></p><ol><li>Enter your GitLab instance URL:<br><code>Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )  https://gitlab.com </code></li><li>Enter the token you obtained to register the Runner:<br><code>Please enter the gitlab-ci token for this runner  xxx </code></li><li>Enter a description for the Runner, you can change this later in GitLab’s UI:<br><code>Please enter the gitlab-ci description for this runner  [hostame] my-runner </code></li><li>Enter the <a href="https://docs.gitlab.com/ee/ci/runners/#using-tags">tags associated with the Runner</a>, you can change this later in GitLab’s UI:<br><code>Please enter the gitlab-ci tags for this runner (comma separated):  my-tag,another-tag </code></li><li>Enter the <a href="https://docs.gitlab.com/runner/executors/README.html">Runner executor</a>:<br><code>Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:  docker </code></li><li>If you chose Docker as your executor, you’ll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml:<br><code>Please enter the Docker image (eg. ruby:2.1):  alpine:latest</code></li></ol><p>The final step is to run the runner:</p><!--kg-card-begin: markdown--><pre><code>Run:
docker run -d --name gitlab-runner --restart always \
    -v /srv/gitlab-runner/config:/etc/gitlab-runner \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /path-to-your-cert/ca.crt:/etc/gitlab-runner/certs/ca.crt \
    gitlab/gitlab-runner:latest
</code></pre>
<!--kg-card-end: markdown--><h3 id="links-">Links:</h3><p><a href="https://docs.gitlab.com/runner/register/index.html#docker">https://docs.gitlab.com/runner/register/index.html#docker</a></p><p><a href="https://docs.gitlab.com/runner/install/docker.html">https://docs.gitlab.com/runner/install/docker.html</a></p><p><a href="https://docs.gitlab.com/runner/">https://docs.gitlab.com/runner/</a></p>]]></content:encoded></item><item><title><![CDATA[Setting up RancherOS using cloud-config.yml [in 2019]]]></title><description><![CDATA[<p><strong>I wrote an updated version here: <a href="https://blog.petermartyniak.com/rancheros-cloud-init-cloud-config-setup-2020-update/">https://blog.petermartyniak.com/rancheros-cloud-init-cloud-config-setup-2020-update/</a></strong></p><p>When you create a new RancherOS box, you can use cloud-config.yml file to setup your OS. There are two ways of doing it, with or without installation to the disk.</p><h3 id="in-memory-option-">In memory option:</h3><p>Create or download your cloud-config.</p>]]></description><link>https://blog.petermartyniak.com/setting-up-rancheros-using-cloud-init-yml/</link><guid isPermaLink="false">5dc8be786a2c740546e8dbef</guid><category><![CDATA[RancherOS]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Mon, 29 Oct 2018 19:52:41 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2019/11/0_wA9Z0-FWS3frubM8.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2019/11/0_wA9Z0-FWS3frubM8.png" alt="Setting up RancherOS using cloud-config.yml [in 2019]"><p><strong>I wrote an updated version here: <a href="https://blog.petermartyniak.com/rancheros-cloud-init-cloud-config-setup-2020-update/">https://blog.petermartyniak.com/rancheros-cloud-init-cloud-config-setup-2020-update/</a></strong></p><p>When you create a new RancherOS box, you can use cloud-config.yml file to setup your OS. There are two ways of doing it, with or without installation to the disk.</p><h3 id="in-memory-option-">In memory option:</h3><p>Create or download your cloud-config.yml file:</p><p><code>sudo ros install -c https://link/to/cloud-config.yml</code></p><h3 id="install-to-disk-option-">Install to disk option:</h3><p>Get the config file as in the previous section, then:</p><p><code>sudo ros install -c cloud-config.yml -d /dev/sda</code></p><h3 id="kernel-params-for-esxi-6-7-option-">Kernel params for ESXi 6.7 option:</h3><p>Edit your Rancher VM open [VM Options] &gt; [Advanced] &gt; [Edit Configuration] and [Add parameter]</p><p>Key= <code>guestinfo.cloud-init.config.url</code></p><p>Value= <code>http://your.url/cloud-config.yml</code></p><p>Rancher is going to automatically pick up that config and apply it on boot</p><h3 id="the-cloud-config-file-">The cloud config file:</h3><p>This file sets the persistent drive, hostname, ssh key, static ip address and custom DNS</p><!--kg-card-begin: markdown--><pre><code class="language-yml">#cloud-config
runcmd:
  -  sudo mkfs.ext4 -L RANCHER_STATE /dev/sda
hostname : your-hostname
ssh_authorized_keys:
  - ssh-rsa =your=rsa=key
rancher:
  network:
    interfaces:
      eth*:
        address: ip/netmask
        gateway: gateway
    dns:
      nameservers:
        - nameserver
</code></pre>
<!--kg-card-end: markdown--><h3 id="links">Links</h3><p><a href="https://rancher.com/docs/os/v1.2/en/running-rancheros/cloud/vmware-esxi/">https://rancher.com/docs/os/v1.2/en/running-rancheros/cloud/vmware-esxi/</a></p><p><a href="https://rancher.com/docs/os/v1.2/en/boot-process/cloud-init/">https://rancher.com/docs/os/v1.2/en/boot-process/cloud-init/</a></p><p><a href="https://rancher.com/docs/os/v1.2/en/running-rancheros/server/install-to-disk/">https://rancher.com/docs/os/v1.2/en/running-rancheros/server/install-to-disk/</a></p><p><a href="https://cloudinit.readthedocs.io/en/latest/topics/examples.html">https://cloudinit.readthedocs.io/en/latest/topics/examples.html</a></p><p><a href="https://rancher.com/docs/os/v1.x/en/installation/configuration/">https://rancher.com/docs/os/v1.x/en/installation/configuration/</a></p>]]></content:encoded></item><item><title><![CDATA[Persisting RancherOS state]]></title><description><![CDATA[How to persist RancherOS state]]></description><link>https://blog.petermartyniak.com/persisting-rancheros-state/</link><guid isPermaLink="false">5dc8be786a2c740546e8dbec</guid><category><![CDATA[RancherOS]]></category><category><![CDATA[Docker]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Thu, 25 Oct 2018 17:10:24 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2018/10/0_wA9Z0-FWS3frubM8.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2018/10/0_wA9Z0-FWS3frubM8.png" alt="Persisting RancherOS state"><p>You can run RancherOS in two ways. Boot from an ISO to memory or install on disk. There are some advantages of running it from ISO, like super easy update process. The downside is - by default, after reboot, you're going to loose all your images, settings and data. To fix that, you can persist the data by creating and mounting a partition. (<a href="https://rancher.com/docs/os/v1.x/en/installation/running-rancheros/workstation/boot-from-iso/">documentation</a>)</p><!--kg-card-begin: markdown--><pre><code>sudo mkfs.ext4 -L RANCHER_STATE /dev/sda

sudo reboot
</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[How to become a local CA, and sign your own SSL certificates]]></title><description><![CDATA[<p>Sometimes when you experiment with some apps and VMs (like hosting gitlab on a local server) you might want to setup SSL for the app to work, to mimic the live setup and to make the browser happy. In order to do that, you need a SSL certificate. </p><p>You can</p>]]></description><link>https://blog.petermartyniak.com/how-to-become-a-local-ca-and-sign-your-own-certificates/</link><guid isPermaLink="false">5dc8be786a2c740546e8dbee</guid><category><![CDATA[SSL]]></category><category><![CDATA[Local Lab]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Thu, 25 Oct 2018 11:25:19 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2018/10/ssl.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2018/10/ssl.png" alt="How to become a local CA, and sign your own SSL certificates"><p>Sometimes when you experiment with some apps and VMs (like hosting gitlab on a local server) you might want to setup SSL for the app to work, to mimic the live setup and to make the browser happy. In order to do that, you need a SSL certificate. </p><p>You can buy one for your domain from a trusted CA, but if you're working on a local network, that might not be possible. The other solution is... becoming CA yourself and issuing and signing the certificate yourself!</p><p>It's pretty easy, you need a linux box with openssl installed, then follow these instructions:</p><h2 id="ca-part">CA part</h2><p>To become a CA, you need a key and certificate pair. To create the key, execute: </p><p><code>openssl genrsa -des3 -out myCA.key 2048</code></p><p>To generate the certificate, execute the following:</p><p><code>openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1925 -out myCA.pem</code></p><p>That's it! Now after you import the CA certificate to your machine, every certificate signed by it is going to be trusted!</p><h2 id="crt-part">CRT part</h2><p>First thing you need is a private key:</p><p><code>openssl genrsa -out gitlab.local.key 2048</code></p><p>Then create the signing request:</p><p><code>openssl req -new -key gitlab.local.key -out gitlab.local.csr</code></p><p>Answer the question asked, one potentially important is the Common Name.</p><p>Now to sign it with the CA key and certificate, you need the config file with Subject Alternative Name (SAN) specified.</p><p>The config I used comes from <a href="https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/">here</a>:</p><!--kg-card-begin: markdown--><pre><code>authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = gitlab.local
</code></pre>
<!--kg-card-end: markdown--><p>Now the final command to sign the certificate:</p><!--kg-card-begin: markdown--><pre><code>openssl x509 -req -in gitlab.local.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out gitlab.local.crt -days 1825 -sha256 -extfile config.conf
</code></pre>
<!--kg-card-end: markdown--><p>Now you should have the working and signed certificate.</p><p></p><h2 id="links-gotcha-s">Links &amp; Gotcha's</h2><h3 id="why-you-cannot-do-tld-wildcard-even-with-san-like-local-">why you cannot do TLD wildcard, even with SAN (like *.local)</h3><p><a href="https://bugs.chromium.org/p/chromium/issues/detail?id=736715">https://bugs.chromium.org/p/chromium/issues/detail?id=736715</a></p><p><a href="https://superuser.com/questions/1305671/san-wildcard-for-whole-domain-tld">https://superuser.com/questions/1305671/san-wildcard-for-whole-domain-tld</a></p><p><a href="https://www.icann.org/groups/ssac/documents/sac-015-en">https://www.icann.org/groups/ssac/documents/sac-015-en</a></p><p><a href="https://security.stackexchange.com/questions/6873/can-a-wildcard-ssl-certificate-be-issued-for-a-second-level-domain">https://security.stackexchange.com/questions/6873/can-a-wildcard-ssl-certificate-be-issued-for-a-second-level-domain</a></p><h3 id="useful-links">Useful links</h3><!--kg-card-begin: markdown--><p><a href="https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/">https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/</a></p>
<!--kg-card-end: markdown--><p><a href="https://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl/27931596#27931596">https://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl/27931596#27931596</a></p><p><a href="https://stackoverflow.com/questions/43665243/invalid-self-signed-ssl-cert-subject-alternative-name-missing/43665244#43665244">https://stackoverflow.com/questions/43665243/invalid-self-signed-ssl-cert-subject-alternative-name-missing/43665244#43665244</a></p><p><a href="https://unix.stackexchange.com/questions/371997/creating-a-local-ssl-certificate">https://unix.stackexchange.com/questions/371997/creating-a-local-ssl-certificate</a></p><p><a href="http://wiki.cacert.org/FAQ/subjectAltName">http://wiki.cacert.org/FAQ/subjectAltName</a></p><p><a href="https://geekflare.com/san-ssl-certificate/">https://geekflare.com/san-ssl-certificate/</a></p><p><a href="https://gist.github.com/bitoiu/9e19962b991a71165268">https://gist.github.com/bitoiu/9e19962b991a71165268</a></p><p><a href="https://blog.zencoffee.org/2013/04/creating-and-signing-an-ssl-cert-with-alternative-names/">https://blog.zencoffee.org/2013/04/creating-and-signing-an-ssl-cert-with-alternative-names/</a></p><p><a href="http://grokify.github.io/security/wildcard-subject-alternative-name-ssl-tls-certificates/">http://grokify.github.io/security/wildcard-subject-alternative-name-ssl-tls-certificates/</a></p><p><a href="https://stackoverflow.com/questions/1822268/how-do-i-create-my-own-wildcard-certificate-on-linux">https://stackoverflow.com/questions/1822268/how-do-i-create-my-own-wildcard-certificate-on-linux</a></p>]]></content:encoded></item><item><title><![CDATA[Setting up Bitnami Gitlab CE image with ESXi 6.7]]></title><description><![CDATA[<p>In order to setup your local GitLab CE instance (inside ESXi), you need:</p><ul><li>Working ESXi</li><li>Bitnami Gitlab *.OVA file (<a href="https://bitnami.com/stack/gitlab/virtual-machine">link</a>)</li><li>Local DNS is a bonus</li></ul><h3 id="vm">VM</h3><p>After you download the OVA file, open ESXi web UI, create a new VM and select Deploy a VM from UVF file, give it</p>]]></description><link>https://blog.petermartyniak.com/setting-up-bitnami-gitlab-ce-image-with-esxi-6-7/</link><guid isPermaLink="false">5dc8be786a2c740546e8dbed</guid><category><![CDATA[ESXi]]></category><category><![CDATA[bitnami]]></category><category><![CDATA[GitLab]]></category><dc:creator><![CDATA[Peter]]></dc:creator><pubDate>Mon, 22 Oct 2018 00:20:16 GMT</pubDate><media:content url="https://blog.petermartyniak.com/content/images/2018/10/bitnami-logo-white-bg-b8c3edf90e7c20dd020c1bcb0bf4552e.png" medium="image"/><content:encoded><![CDATA[<img src="https://blog.petermartyniak.com/content/images/2018/10/bitnami-logo-white-bg-b8c3edf90e7c20dd020c1bcb0bf4552e.png" alt="Setting up Bitnami Gitlab CE image with ESXi 6.7"><p>In order to setup your local GitLab CE instance (inside ESXi), you need:</p><ul><li>Working ESXi</li><li>Bitnami Gitlab *.OVA file (<a href="https://bitnami.com/stack/gitlab/virtual-machine">link</a>)</li><li>Local DNS is a bonus</li></ul><h3 id="vm">VM</h3><p>After you download the OVA file, open ESXi web UI, create a new VM and select Deploy a VM from UVF file, give it a name and select/drag the OVA file into the box. Follow on screen instructions.</p><h3 id="static-ip-dhcp">Static IP/ DHCP</h3><p>Now that you have the VM up an running, you have to make a decision, if you want to use DHCP or static IP for that box. If your choice is DHCP, setup your DHCP service to assign same IP to your VM MAC address every time, so that you can setup the URL/hostname in Gitlab. If you pick static IP, open the VM console in ESXi (or ssh to the box if enabled). You should see the login and password, use it. You might be asked to change the default password.</p><p>Now follow the instructions from <a href="https://docs.bitnami.com/virtual-machine/faq/configuration/configure-static-address/">here</a>:</p><ul><li>check your interface name: <code>ip a</code> it should be something like <code>ens32</code></li><li>navigate to network settings directory <code>cd /etc/systemd/network</code></li><li>copy network config file <code>sudo cp 99-dhcp.network 25-wired.network</code></li><li>edit the network settings file:</li></ul><!--kg-card-begin: markdown--><pre><code>[Match]
Name=ens32 (your interface neame here)

[Network]
Address=10.0.0.9/24 (desired IP address and netmask)
Gateway=10.0.0.1
DNS=10.0.0.1
</code></pre>
<!--kg-card-end: markdown--><ul><li>save file and restart the VM</li></ul><h3 id="hostname-dns">Hostname, DNS</h3><p>At this point you should have IP setup done and dusted, it's a good idea to give your GitLab instance some meaningful name to access, like gitlab.local</p><p>In order to do it, you need a local DNS server. Add an A record, pointing to your VM IP address, and a name.</p><p>Try accessing your GitLab instance using your newly created domain name. There are two problems. </p><ol><li>SSL is not set up and the browser is complaining about self signed certificate</li><li>Server is redirecting to IP address, not using the domain name</li></ol><p>To fix the second issue, follow those instructions (<a href="https://docs.bitnami.com/virtual-machine/apps/gitlab/configuration/change-default-address/">link</a>), or run</p><p><code>sudo /opt/bitnami/apps/gitlab/bnconfig --machine_hostname NAME</code></p><p>where NAME is your domain name. </p><p><strong>Rename or remove the bnconfig file to avoid the hostname being reset after reboot!</strong></p><h3 id="ssl">SSL</h3><p>The last part is setting up SSL. As we are using the server in a local network, self signed certificate is enough.</p><p>You need:</p><ul><li>server.key</li><li>server.crt</li></ul><p>Copy both files to the server (I'm using WinSCP), copy both files to <code>/etc/gitlab/ssl/</code> change owner to root:root and chmod 600.</p><p>Last two steps are - trigger gitlab script reconfigure and restart gitlab service.</p><!--kg-card-begin: markdown--><pre><code>mv server.* /etc/gitlab/ssl/
chown root:root /etc/gitlab/ssl/
chmod 600 /etc/gitlab/ssl/
gitlab-ctl reconfigure
gitlab-ctl restart
</code></pre>
<!--kg-card-end: markdown--><h3 id="git-exe-and-ssl">Git.exe and SSL</h3><p>Execute <code>git config --list --show-origin</code> to find out the location of your git config files. Then edit it and add:</p><!--kg-card-begin: markdown--><pre><code>[http]
	sslCAInfo=[your location]\\cert.pem
</code></pre>
<!--kg-card-end: markdown--><h3 id="gotcha-s">Gotcha's</h3><p>I use local DNS server, but the Bitnami image used Google's 8.8.8.8 and 8.8.4.4 DNS by default. Modifying the network setup wasn't enough. I had to manually edit <code>/etc/resolv.conf</code> file to add my DNS server.</p>]]></content:encoded></item></channel></rss>