<?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"><channel><title><![CDATA[Puck]]></title><description><![CDATA[World of Tech, Music and other random things]]></description><link>https://akos.me</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 02:11:11 GMT</lastBuildDate><atom:link href="https://akos.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[inkyFrame + golang for TFL API and Home Assistant info]]></title><description><![CDATA[It’s good to know when the next bus is coming, what the weather is like, what’s your next calendar event, etc. it’s also cool to not look at your phone all…]]></description><link>https://akos.me/inkyframe-golang-for-tfl-api-and-home-assistant-info</link><guid isPermaLink="true">https://akos.me/inkyframe-golang-for-tfl-api-and-home-assistant-info</guid><category><![CDATA[inkyframe]]></category><category><![CDATA[tfl]]></category><category><![CDATA[golang]]></category><category><![CDATA[micropython]]></category><category><![CDATA[Home Assistant]]></category><dc:creator><![CDATA[Ákos Veres]]></dc:creator><pubDate>Fri, 23 May 2025 11:22:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/cMFKKIfNFPg/upload/f2fff5d11d7c454192ab0e41d3f58f09.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-why">Why?</h2>
<p>It’s good to know when the next bus is coming, what the weather is like, what’s your next calendar event, etc.</p>
<p>it’s also cool to not look at your phone all the time (at least for me it is).</p>
<h2 id="heading-how">How?</h2>
<p>Enter InkyFrame!</p>
<p>A 5.7” E Ink display from Pimoroni - <a target="_blank" href="https://shop.pimoroni.com/products/inky-frame-5-7?variant=40048398958675">product page</a>.</p>
<p>The InkyFrame runs micropython as it has a <code>Pico W</code> board integrated into it, with this you can manipulate any type of data you get. <a target="_blank" href="https://github.com/pimoroni/inky-frame">Official example repository</a> to see some bits.</p>
<p>Fun fact, it takes ~30 seconds to render the display, this needs to be factored in, it will never be real time data you’re displaying.</p>
<h2 id="heading-details">Details</h2>
<p>For those who have done this before, the answer on what you do next is fairly standard, you need an API to call, to work out what you need from the API and you render it on the display. <code>Pico W</code> has a wireless chip as well, so all the data goes via your 2.4GHz WiFi.</p>
<p>Pulling down a load of data from various APIs, who knows how many, may become problematic on a <code>Pico W</code>, memory is a problem, but you do have an SD Card, so you can store data on a local disk and iterate over that.</p>
<p>But, I’ve seen something interesting over at <a target="_blank" href="https://github.com/jinglemansweep/inky-frame-web">https://github.com/jinglemansweep/inky-frame-web</a> - basically it’s a photo slideshow solution for inkyframe, so I started thinking, what if I create an image with the information I need and then I just need to download the image and render it. This would allow me to have a separate piece of software where I can iterate over the information I need, I don’t need to constantly deploy to the InkyFrame (and connect it via USB every time I need to do this).</p>
<p>So that’s what I set out to do.</p>
<h3 id="heading-enter-golang">Enter golang</h3>
<p>I’ll be honest, I wanted to write some golang, which made this decision even better for me personally. The idea would be:</p>
<ul>
<li><p>Create a golang web app</p>
</li>
<li><p>Create an image</p>
</li>
<li><p>Overlay all the information from the APIs on the image</p>
</li>
<li><p>Serve the image</p>
</li>
<li><p>Pull the image from InkyFrame and render it</p>
</li>
</ul>
<p>I was insipred by <a target="_blank" href="https://github.com/daniruizcamacho/image-generation-example">https://github.com/daniruizcamacho/image-generation-example</a> as I’ve never done image generation before.</p>
<h3 id="heading-the-apis">The APIs</h3>
<p>I started with the London TFL API which is a REST API, it was not easy understanding how I can get the exact information I need, but I was basically going for:</p>
<ul>
<li>Get the next arrival time for a bus at my local bus station going into a specific direction</li>
</ul>
<p>Next up was some weather information, given I’m already running Home Assistant, I do have weather data, so all I needed to do is understand how to call the Home Assistant REST API.</p>
<p>The last piece of information was calendar events, since this is also integrated into Home Assistant, it’s the same mechanism.</p>
<p>The web app is a docker container hosted within my network, so I can easily get to Home Assistant APIs and also the InkyFrame can download the image as well.</p>
<h3 id="heading-how-it-looks">How it looks</h3>
<p>It’s rough, it’s ugly, but it works. Here’s a rendered image:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747995883553/6a3b12be-7653-4cea-8ffb-995cff38fde6.jpeg" alt class="image--center mx-auto" /></p>
<p>I’ve added a timestamp at the bottom so we always know what was the last update time.</p>
<p>The rendering runs on a 5 minute loop, it takes around 30 seconds to render the image, so you always need to factor that in.</p>
<p>On the device it looks like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747996198395/7f7fd098-2bb5-4b99-8ef0-6f04b8629d09.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-the-code">The code</h3>
<p>I wanted to use something other than github for this piece of work (and for some of my future bits), so I decided I’ll give <code>codeberg</code> a try, I highly recommend it for any open source work you may want to do. It can store your packages too, so it also serves as my container registry.</p>
<p>Repository: <a target="_blank" href="https://codeberg.org/puck/inkyframe-golang-web">https://codeberg.org/puck/inkyframe-golang-web</a></p>
<h3 id="heading-the-future">The Future</h3>
<p>Oh boy, where do I start, here’s some of the things in my head:</p>
<ul>
<li><p>Actually try and see if I can loop over a JSON API via micropython as then I have some cool built in options to render the text</p>
</li>
<li><p>Start using the 5 buttons on the inkyFrame for different views</p>
</li>
<li><p>Add more information from Home Assistant</p>
</li>
<li><p>Rework the code and write tests</p>
</li>
<li><p>Implement auto-deployments</p>
</li>
<li><p>If something fails, write the error message on the inkyFrame display (things can go wrong once in a while)</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[XTRadio architecture]]></title><description><![CDATA[I wanted to write a blog post about XTRadio for a very long time. I finally have the time, so let's start with a short but sweet post which explains how…]]></description><link>https://akos.me/xtradio-architecture</link><guid isPermaLink="true">https://akos.me/xtradio-architecture</guid><category><![CDATA[xtradio]]></category><category><![CDATA[radio]]></category><category><![CDATA[liquidsoap]]></category><dc:creator><![CDATA[Ákos Veres]]></dc:creator><pubDate>Mon, 19 Sep 2022 15:16:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/OKLqGsCT8qs/upload/v1663598711614/eZnlHIiJk.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I wanted to write a blog post about <a target="_blank" href="https://xtradio.org">XTRadio</a> for a very long time. I finally have the time, so let's start with a short but sweet post which explains how everything works, how it all fits together.</p>
<h2 id="heading-what-is-xtradio">What is XTRadio</h2>
<p>XTRadio is an online radio station which started on 08.08.08. It's a joint venture between my good friend <code>crayon</code> and myself. It started on the Undernet IRC Servers, <code>Silvered</code> was heavily involved as well. It's not the biggest project you'll ever hear about, for us involved, it holds a special place in our hearts. A post detailing the history of the radio should happen in the future!</p>
<p>We play electronic music 24/7.</p>
<h2 id="heading-architecture-and-diagram">Architecture and diagram</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663598640969/e4UWi6w5Y.png" alt="xtradio.drawio(1).png" class="image--center mx-auto" /></p>
<p>In the above diagram you can see the full picture, we'll dive deeper into this, let's have two categories:</p>
<ul>
<li>Audio route</li>
<li>Data route</li>
</ul>
<h2 id="heading-audio">Audio</h2>
<p>We play music, dooh! We are not streaming from other websites, we have good old mp3 files. Why not OGG or OPUS? In 2008 it was just easy to set it all up with mp3 and we just stuck to it.</p>
<p>We need to upload, edit and store these MP3 files somehow. In the good old days we just ran an FTP server, upload the files, have the backend read it and we were done. Over time we wanted to more data with each MP3 file, like proper <code>Artist</code>, <code>Title</code>, <code>Source URL</code>, etc.</p>
<h3 id="heading-admin-interface">Admin interface</h3>
<p>Enter the Admin interface.</p>
<p>It's a very simple web application, it went through a couple of iterations and even now it's not ready for prime time, but essentially it's used for the following actions:</p>
<ul>
<li>Upload</li>
<li>List</li>
<li>Edit details</li>
<li>Create playlist file</li>
</ul>
<p>The most interesting aspect is the file upload. Once you select a file from your computer and you upload it, you have a form which allows you to change the Title, Artist, Source URL. An automatic search to Spotify and Soundcloud is made so we can get the album part for the song. The album art is uploaded to the CDN, stored on disk and a unique file name is returned.</p>
<p>All this information is stored in a MySQL database. We need it later, especially on the website.</p>
<p>The uploaded MP3 file is stored in a folder which is shared with Liquidsoap.</p>
<h3 id="heading-liquidsoap">Liquidsoap</h3>
<p>This piece of software is a beast! Super fast, extensible, reliable. Check out more details on <a target="_blank" href="https://liquidsoap.info">liquidsoap.info</a>.</p>
<p>In a nutshell, we grab a bunch of mp3 files and play them with Liquidsoap.</p>
<p>We can do metadata manipulation, encoding, decoding, call APIs on certain events, save stream output, a telnet interface to manipulate song queues, etc.</p>
<p>The first time the Admin interface spins up, it generates a playlist file based on the entries in the mysql database. Here's a few lines from the <code>playlist.txt</code> file:</p>
<pre><code>annotate:artist<span class="hljs-operator">=</span><span class="hljs-string">"Brandy"</span>,title<span class="hljs-operator">=</span><span class="hljs-string">"Full Moon (Final DJs Remix)"</span>,length<span class="hljs-operator">=</span><span class="hljs-string">"335"</span>,image<span class="hljs-operator">=</span><span class="hljs-string">"5004360098.jpg"</span>,share<span class="hljs-operator">=</span><span class="hljs-string">"https://soundcloud.com/finaldjs/brandy-full-moon-final-djs"</span>:<span class="hljs-operator">/</span>MUSIC<span class="hljs-operator">/</span>BACKUP<span class="hljs-operator">/</span>remix<span class="hljs-operator">/</span>Brandy_<span class="hljs-operator">-</span>_Full_Moon_(Final_DJs_Remix).mp3
annotate:artist<span class="hljs-operator">=</span><span class="hljs-string">"London Grammar"</span>,title<span class="hljs-operator">=</span><span class="hljs-string">"Wasting My Young Years (Sound Remedy Remix)"</span>,length<span class="hljs-operator">=</span><span class="hljs-string">"404"</span>,image<span class="hljs-operator">=</span><span class="hljs-string">"6161727760.jpg"</span>,share<span class="hljs-operator">=</span><span class="hljs-string">"https://soundcloud.com/soundremedy/wasting-my-young-years-sound"</span>:<span class="hljs-operator">/</span>MUSIC<span class="hljs-operator">/</span>BACKUP<span class="hljs-operator">/</span>remix<span class="hljs-operator">/</span>London_Grammar_<span class="hljs-operator">-</span>_Wasting_My_Young_Years_(Sound_Remedy_Remix).mp3
annotate:artist<span class="hljs-operator">=</span><span class="hljs-string">"The Black Keys"</span>,title<span class="hljs-operator">=</span><span class="hljs-string">"Little Black Submarines (Ageless Remix)"</span>,length<span class="hljs-operator">=</span><span class="hljs-string">"302"</span>,image<span class="hljs-operator">=</span><span class="hljs-string">"973019753.jpg"</span>,share<span class="hljs-operator">=</span><span class="hljs-string">"https://soundcloud.com/ageless84/little-black-submarines"</span>:<span class="hljs-operator">/</span>MUSIC<span class="hljs-operator">/</span>BACKUP<span class="hljs-operator">/</span>remix<span class="hljs-operator">/</span>The_Black_Keys_<span class="hljs-operator">-</span>_Little_Black_Submarines_(Ageless_Remix).mp3
annotate:artist<span class="hljs-operator">=</span><span class="hljs-string">"Andrew Gentry Remix"</span>,title<span class="hljs-operator">=</span><span class="hljs-string">"Poetic Justice (ft. Clams Casino) Remix"</span>,length<span class="hljs-operator">=</span><span class="hljs-string">"228"</span>,image<span class="hljs-operator">=</span><span class="hljs-string">"3840532694.jpg"</span>,share<span class="hljs-operator">=</span><span class="hljs-string">"https://soundcloud.com/andrewgentrymusic/poetic-justice-ft-casino-clams"</span>:<span class="hljs-operator">/</span>MUSIC<span class="hljs-operator">/</span>BACKUP<span class="hljs-operator">/</span>remix<span class="hljs-operator">/</span>Poetic_Justice_(ft._Clams_Casino)_Remix.mp3
annotate:artist<span class="hljs-operator">=</span><span class="hljs-string">"Kyla La Grange"</span>,title<span class="hljs-operator">=</span><span class="hljs-string">"Cut Your Teeth (Kygo Remix)"</span>,length<span class="hljs-operator">=</span><span class="hljs-string">"396"</span>,image<span class="hljs-operator">=</span><span class="hljs-string">"9869146691.jpg"</span>,share<span class="hljs-operator">=</span><span class="hljs-string">"https://soundcloud.com/kygo/kyla-la-grange-cut-your"</span>:<span class="hljs-operator">/</span>MUSIC<span class="hljs-operator">/</span>BACKUP<span class="hljs-operator">/</span>remix<span class="hljs-operator">/</span>Cut_Your_Teeth_(Kygo_Remix).mp3
</code></pre><p>We have the following information in here:</p>
<ul>
<li>Artist</li>
<li>Title</li>
<li>Song length</li>
<li>Image unique file name on the CDN</li>
<li>Source URL</li>
<li>File location</li>
</ul>
<p>Liquidsoap uses each of this information in various ways, the length is the most important for it, it knows for sure how long a song is, this way it can determine when to auto-queue the next file.</p>
<p>We decode the file we randomly pick from the playlist, grab all the information we can, re-encode the file into 3 bitrates, start playing the file and send an API call to our REST API.</p>
<p>When you connect to listen to the radio, you connect straight to <a target="_blank" href="https://icecast.org">Icecast</a>, you have a choice of various bitrates:</p>
<ul>
<li>AAC 32kbps</li>
<li>MP3 128kbps</li>
<li>MP3 320 kbps</li>
</ul>
<p>Liquidsoap re-encodes our MP3 files and sends it to the icecast endpoints.</p>
<p>You can find our Liquidsoap script <a target="_blank" href="https://github.com/xtradio/xtradio-liquidsoap/blob/master/radio.liq">on github</a>.</p>
<h2 id="heading-data">Data</h2>
<p>Having an audio stream is awesome and everything, but on a website you can't just have a a player and that's it. Not that our website is super detailed, but it's not just an audio player.</p>
<p>Our data is available through a public API, anyone can view it <a target="_blank" href="https://api.xtradio.org/api">here</a>, (the v2 is available <a target="_blank" href="https://api.xtradio.org/v1/np/">here</a>).</p>
<p>The source of the data is from our MySQL database and Liquidsoap. When a song plays, liquidsoap sends an event to the API, this prompts a request to the DB to request the details about the song. In the v2 API we're also getting the upcoming songs, straight from the Liquidsoap telnet interface, details of this code is <a target="_blank" href="https://github.com/xtradio/xtradio-api/blob/master/telnet.go">here</a>.</p>
<p>Based on this we can put together the details on the website, in the end it looks like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663600364555/LAdfoXVzm.png" alt="image.png" class="image--center mx-auto" /></p>
<p>The background color is always random, determined based on the album art.</p>
<h2 id="heading-fin">Fin</h2>
<p>If anyone is interested in more details, feel free to reach out and we can discuss other aspects. The next article in this series should discuss the infrastructure aspects, how we deployed everything, how we used Civo cloud and kubernetes.</p>
<p>All details about xtradio are available on github on <a target="_blank" href="https://github.com/xtradio">github.com/xtradio</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Civo Cloud k3s: Traefik v2 and Let's Encrypt]]></title><description><![CDATA[I’ve continued to play around with the K3S Beta cluster from Civo Cloud (you can request to join the beta), the aim was to also try out the new Traefik V2…]]></description><link>https://akos.me/civo-cloud-k3s-traefik-v2-and-lets-encrypt</link><guid isPermaLink="true">https://akos.me/civo-cloud-k3s-traefik-v2-and-lets-encrypt</guid><category><![CDATA[civo]]></category><category><![CDATA[Traefik]]></category><category><![CDATA[k3s]]></category><dc:creator><![CDATA[Ákos Veres]]></dc:creator><pubDate>Fri, 04 Oct 2019 23:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/dPgPoiUIiXk/upload/v1663600921516/bzwp3gHP8.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663594001466/9SWnSOIz1.png" alt="image.png" class="image--center mx-auto" /></p>
<p>I’ve continued to play around with the K3S Beta cluster from Civo Cloud (you can request to join the beta), the aim was to also try out the new <a target="_blank" href="https://blog.containo.us/traefik-2-0-6531ec5196c2">Traefik V2</a> which was released some time ago.</p>
<p>In this post we will:</p>
<ul>
<li>Update the default traefik install on k3s to v2.0.1</li>
<li>Secure the k3s install</li>
<li>Create and secure the ingress to the traefik dashboard</li>
<li>Enable Let's Encrypt certs for traefik</li>
<li>Some thoughts after the journey</li>
</ul>
<p>Let’s start.</p>
<h2 id="heading-update-traefik-to-v2">Update Traefik to V2</h2>
<p>By default the k3s cluster comes with Traefik v1.7. It’s a sane default, nothing wrong with it. As I am using a k3s cluster on a beta service, seemed like the perfect opportunity to play around with Traefik v2, it gives me the opportunity of exploring the new configuration, getting used to serving k8s services, as it matures, I’ll be ready to switch my production cluster to it.</p>
<p>The documentation around v2 is missing a lot of information, I’ve had to jump around quite a lot to understand how to get it going. (The Traefik documentation is open source, I could definetely contribute to it and it has been on my mind.) Through the post I’ll link to the relevant pages.</p>
<h3 id="heading-delete-the-existing-traefik-deployment-and-service">Delete the existing traefik deployment and service</h3>
<p>The existing Traefik deployment and service are under the name traefik, we just need to delete them:</p>
<pre><code>kubectl <span class="hljs-keyword">delete</span> deployment traefik <span class="hljs-operator">-</span>n kube<span class="hljs-operator">-</span>system
kubectl <span class="hljs-keyword">delete</span> service traefik <span class="hljs-operator">-</span>n kube<span class="hljs-operator">-</span>system
</code></pre><h3 id="heading-deploy-traefik-v2">Deploy Traefik v2</h3>
<p>There is <a target="_blank" href="https://docs.traefik.io/user-guides/crd-acme/">an official user guide</a> that helps you setup Traefik with Let’s Encrypt enabled on minikube, 75% of it is totally usable in our setup as well. We won’t enable Let’s Encrypt from the beginning, we will need to take some extra steps to do so.</p>
<p>Let’s create the CRD definitions, I’m using the kube-system namespace, not the default one as it is in the guide:</p>
<pre><code><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apiextensions.k8s.io/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">CustomResourceDefinition</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">ingressroutes.traefik.containo.us</span>

<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">group:</span> <span class="hljs-string">traefik.containo.us</span>
  <span class="hljs-attr">version:</span> <span class="hljs-string">v1alpha1</span>
  <span class="hljs-attr">names:</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">IngressRoute</span>
    <span class="hljs-attr">plural:</span> <span class="hljs-string">ingressroutes</span>
    <span class="hljs-attr">singular:</span> <span class="hljs-string">ingressroute</span>
  <span class="hljs-attr">scope:</span> <span class="hljs-string">Namespaced</span>

<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apiextensions.k8s.io/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">CustomResourceDefinition</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">ingressroutetcps.traefik.containo.us</span>

<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">group:</span> <span class="hljs-string">traefik.containo.us</span>
  <span class="hljs-attr">version:</span> <span class="hljs-string">v1alpha1</span>
  <span class="hljs-attr">names:</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">IngressRouteTCP</span>
    <span class="hljs-attr">plural:</span> <span class="hljs-string">ingressroutetcps</span>
    <span class="hljs-attr">singular:</span> <span class="hljs-string">ingressroutetcp</span>
  <span class="hljs-attr">scope:</span> <span class="hljs-string">Namespaced</span>

<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apiextensions.k8s.io/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">CustomResourceDefinition</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">middlewares.traefik.containo.us</span>

<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">group:</span> <span class="hljs-string">traefik.containo.us</span>
  <span class="hljs-attr">version:</span> <span class="hljs-string">v1alpha1</span>
  <span class="hljs-attr">names:</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">Middleware</span>
    <span class="hljs-attr">plural:</span> <span class="hljs-string">middlewares</span>
    <span class="hljs-attr">singular:</span> <span class="hljs-string">middleware</span>
  <span class="hljs-attr">scope:</span> <span class="hljs-string">Namespaced</span>

<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apiextensions.k8s.io/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">CustomResourceDefinition</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">tlsoptions.traefik.containo.us</span>

<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">group:</span> <span class="hljs-string">traefik.containo.us</span>
  <span class="hljs-attr">version:</span> <span class="hljs-string">v1alpha1</span>
  <span class="hljs-attr">names:</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">TLSOption</span>
    <span class="hljs-attr">plural:</span> <span class="hljs-string">tlsoptions</span>
    <span class="hljs-attr">singular:</span> <span class="hljs-string">tlsoption</span>
  <span class="hljs-attr">scope:</span> <span class="hljs-string">Namespaced</span>

<span class="hljs-meta">---</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">ClusterRole</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">rbac.authorization.k8s.io/v1beta1</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-ingress-controller</span>

<span class="hljs-attr">rules:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">""</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">services</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">endpoints</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">secrets</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">list</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">watch</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">extensions</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">ingresses</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">list</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">watch</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">extensions</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">ingresses/status</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">update</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">traefik.containo.us</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">middlewares</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">list</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">watch</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">traefik.containo.us</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">ingressroutes</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">list</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">watch</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">traefik.containo.us</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">ingressroutetcps</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">list</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">watch</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">apiGroups:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">traefik.containo.us</span>
    <span class="hljs-attr">resources:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">tlsoptions</span>
    <span class="hljs-attr">verbs:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">list</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">watch</span>

<span class="hljs-meta">---</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">ClusterRoleBinding</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">rbac.authorization.k8s.io/v1beta1</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-ingress-controller</span>

<span class="hljs-attr">roleRef:</span>
  <span class="hljs-attr">apiGroup:</span> <span class="hljs-string">rbac.authorization.k8s.io</span>
  <span class="hljs-attr">kind:</span> <span class="hljs-string">ClusterRole</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-ingress-controller</span>
<span class="hljs-attr">subjects:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">kind:</span> <span class="hljs-string">ServiceAccount</span>
    <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-ingress-controller</span>
    <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
</code></pre><p>Now we’re ready to create the deployment file together with the <code>ServiceAccount</code> used by Traefik:</p>
<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  namespace: kube<span class="hljs-operator">-</span>system
  name: traefik<span class="hljs-operator">-</span>ingress<span class="hljs-operator">-</span>controller

<span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>
kind: Deployment
apiVersion: extensions<span class="hljs-operator">/</span>v1beta1
metadata:
  namespace: kube<span class="hljs-operator">-</span>system
  name: traefik
  labels:
    app: traefik

spec:
  replicas: <span class="hljs-number">1</span>
  selector:
    matchLabels:
      app: traefik
  template:
    metadata:
      labels:
        app: traefik
    spec:
      serviceAccountName: traefik<span class="hljs-operator">-</span>ingress<span class="hljs-operator">-</span>controller
      containers:
        <span class="hljs-operator">-</span> name: traefik
          image: traefik:v2<span class="hljs-number">.0</span>
          args:
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>log.level=INFO
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>api.dashboard=<span class="hljs-literal">true</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>api.insecure=<span class="hljs-literal">true</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>accesslog
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>global.sendanonymoususage
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>entrypoints.web.Address=:<span class="hljs-number">80</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>entrypoints.websecure.Address=:<span class="hljs-number">443</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>providers.kubernetescrd
          ports:
            <span class="hljs-operator">-</span> name: web
              containerPort: <span class="hljs-number">80</span>
            <span class="hljs-operator">-</span> name: websecure
              containerPort: <span class="hljs-number">443</span>
            <span class="hljs-operator">-</span> name: admin
              containerPort: <span class="hljs-number">8080</span>
</code></pre><p>Explanation on some of the options (args) passed, the full list of options can be find on <a target="_blank" href="https://docs.traefik.io/reference/static-configuration/cli/">the CLI Reference Page</a>:</p>
<ul>
<li><code>--log.level=INFO</code> - By tailing the logs, we will be able to see more information</li>
<li><code>--api.dashboard</code> - Enable the Traefik Dashboard</li>
<li><code>--api.insecure</code> - Enable access to the Dashboard, we will secure this with basic auth later on</li>
<li><code>--acceslog</code> - Enable access logs</li>
<li><code>--global.sendanonymoususage</code> - It’s a test setup, the guys from Traefik maybe can find some anonymous data useful. Details of the collected data can be found <a target="_blank" href="https://docs.traefik.io/contributing/data-collection/">here</a>.</li>
</ul>
<p>Last piece of the puzzle is the service:</p>
<pre><code><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">ports:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">http</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
      <span class="hljs-attr">nodePort:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">admin</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">8080</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">https</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">443</span>
      <span class="hljs-attr">nodePort:</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">traefik</span>
  <span class="hljs-attr">type:</span> <span class="hljs-string">LoadBalancer</span>
</code></pre><p>Let’s deploy what we have right now:</p>
<pre><code>kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>crd.yaml
kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>deployment.yaml
kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>svc.yaml
</code></pre><p>In a couple of seconds the pod should start and the service should be able to serve content. You can check all of these with some of the following commands:</p>
<pre><code>kubectl get pods <span class="hljs-operator">-</span>n kube<span class="hljs-operator">-</span>system
kubectl logs traefik<span class="hljs-operator">-</span><span class="hljs-operator">&lt;</span>random<span class="hljs-operator">-</span>hash<span class="hljs-operator">&gt;</span> <span class="hljs-operator">-</span>n kube<span class="hljs-operator">-</span>system
kubectl get svc <span class="hljs-operator">-</span>n kube<span class="hljs-operator">-</span>system
</code></pre><h2 id="heading-secure-the-civo-cloud-k3s-install">Secure the Civo Cloud k3s install</h2>
<p>Civo Cloud has almost all ports open by default, this has been discussed in the #kube100 Slack channel, it will be looked at and secured fully, until then we just have to do another manual approach. Each k3s cluster deployed has a firewall created for it, open your Civo Cloud dashboard, click on <code>Kubernetes</code>, click on the name of your cluster and you’ll see <code>Firewall: Kubernetes cluster: &lt;name of your cluster&gt;</code>, click on it and you’ll be presented with the page where you can modify the rules.</p>
<p>Keep in mind this is a test cluster, you shouldn’t have any valuable information stored inside of it, if you do, it’s totally up to you to keep it secured.</p>
<p>These are the ports I’ve kept open:</p>
<pre><code><span class="hljs-string">ICMP</span> <span class="hljs-string">N/A</span> <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span><span class="hljs-string">/0</span> <span class="hljs-string">Ping/Traceroute</span> <span class="hljs-bullet">-</span> <span class="hljs-string">Just</span> <span class="hljs-string">so</span> <span class="hljs-string">I’m</span> <span class="hljs-string">able</span> <span class="hljs-string">to</span> <span class="hljs-string">ping</span> <span class="hljs-string">the</span> <span class="hljs-string">k3s</span> <span class="hljs-string">nodes</span>
<span class="hljs-string">TCP</span> <span class="hljs-number">443</span> <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span><span class="hljs-string">/0</span> <span class="hljs-string">HTTPS</span> <span class="hljs-bullet">-</span> <span class="hljs-string">Access</span> <span class="hljs-string">to</span> <span class="hljs-string">the</span> <span class="hljs-string">https</span> <span class="hljs-string">endpoint</span> <span class="hljs-string">for</span> <span class="hljs-string">Traefik</span>
<span class="hljs-string">TCP</span> <span class="hljs-number">80</span> <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span><span class="hljs-string">/0</span> <span class="hljs-string">HTTP</span> <span class="hljs-bullet">-</span> <span class="hljs-string">Access</span> <span class="hljs-string">to</span> <span class="hljs-string">the</span> <span class="hljs-string">http</span> <span class="hljs-string">endpoint</span> <span class="hljs-string">for</span> <span class="hljs-string">Traefik,</span> <span class="hljs-string">Let’s</span> <span class="hljs-string">encrypt</span> <span class="hljs-string">needs</span> <span class="hljs-string">access</span> <span class="hljs-string">to</span> <span class="hljs-string">this</span> <span class="hljs-string">so</span> <span class="hljs-string">it</span> <span class="hljs-string">can</span> <span class="hljs-string">do</span> <span class="hljs-string">the</span> <span class="hljs-string">HTTP</span> <span class="hljs-string">challenge</span>
<span class="hljs-string">TCP</span> <span class="hljs-number">6443 </span><span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span><span class="hljs-string">/0</span> <span class="hljs-string">K3S</span> <span class="hljs-string">API</span> <span class="hljs-bullet">-</span> <span class="hljs-string">Access</span> <span class="hljs-string">to</span> <span class="hljs-string">the</span> <span class="hljs-string">secure</span> <span class="hljs-string">k3s</span> <span class="hljs-string">API</span>
</code></pre><p>If you want to secure the cluster even more, feel free to use your own public IP instead of 0.0.0.0/0, if the IP is dynamic, don’t forget to update it.</p>
<h2 id="heading-create-and-secure-the-access-to-the-traefik-dashboard">Create and secure the access to the Traefik Dashboard</h2>
<p>The k3s nodes all have public IP addresses, Traefik runs the dashboard on port 8080, with the service created, by default it means anyone who opens one of the public IPs on port 8080 can have unauthenticated access to the dashboard. We mitigated this risk by not allowing port 8080 to be open to these public IPs. In order to go around it we will create an IngressRule on a specific host that will route all of our requests to the Traefik Dashboard.</p>
<h3 id="heading-point-domain-to-public-ip">Point domain to Public IP</h3>
<p>The first step is to make sure you point a domain to one of the public IP addresses. I’ve chosen the same public IP where the kubectl context is configured, you can see this with the following command:</p>
<pre><code>civo kubernetes <span class="hljs-keyword">show</span> &lt;<span class="hljs-type">name</span> <span class="hljs-keyword">of</span> your <span class="hljs-keyword">cluster</span>&gt; | grep API
</code></pre><p>Simply create an A record that points to the public IP Address. We also need this step for the Let’s Encrypt step.</p>
<h3 id="heading-create-the-ingressrule">Create the IngressRule</h3>
<p>We will set up an <code>IngressRule</code> that will route any requests coming in on our domain name to the Traefik dashboard, for security we will add basic auth.</p>
<p>The <a target="_blank" href="https://docs.traefik.io/middlewares/basicauth/">basic auth documentation</a> page explain how it works in the new Traefik v2, the step I’ve missed was on how to craete the basic auth. With a bit of exploring, it turns out it’s the same as in the old version, you create the htpassd file, create a secret from it and you present it to Traefik:</p>
<pre><code>htpasswd <span class="hljs-operator">-</span>c ./users <span class="hljs-operator">&lt;</span>your username<span class="hljs-operator">&gt;</span>
kubectl create secret generic mysecret <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-keyword">from</span><span class="hljs-operator">-</span>file users <span class="hljs-operator">-</span><span class="hljs-operator">-</span>namespace<span class="hljs-operator">=</span>kube<span class="hljs-operator">-</span>system
</code></pre><p>Time to create the IngressRoute and Middleware:</p>
<pre><code><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">traefik.containo.us/v1alpha1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Middleware</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">test-auth</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">basicAuth:</span>
    <span class="hljs-attr">secret:</span> <span class="hljs-string">mysecret</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">traefik.containo.us/v1alpha1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">IngressRoute</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-dashboard</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">entryPoints:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">web</span>
  <span class="hljs-attr">routes:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">match:</span> <span class="hljs-string">Host(`&lt;your-domain.fqdn&gt;`)</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">Rule</span>
    <span class="hljs-attr">services:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">traefik</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">8080</span>
    <span class="hljs-attr">middlewares:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">test-auth</span>
</code></pre><p>Let’s apply it:</p>
<pre><code>kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>ingress<span class="hljs-operator">-</span>dashboard.yaml
</code></pre><p>There we go, if you visit <code>http://your-domain.fqdn</code> you should be presented with basic auth, use your username and password and voila, the new great Traefik Dashboard will appear! Feel free to get used to the new layout and all the new information presented (I do miss the statistics, if I’m honest).</p>
<h3 id="heading-enable-lets-encrypt">Enable Let’s Encrypt</h3>
<p>Traefik’s one big and great feature is that it can handle SSL Certs for you automagically, let’s use it.</p>
<p>Configuration to Traefik is passed via the <code>args</code> field in the configuration file, we modify the previously created file and we’ll make sure it looks like this:</p>
<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  namespace: kube<span class="hljs-operator">-</span>system
  name: traefik<span class="hljs-operator">-</span>ingress<span class="hljs-operator">-</span>controller

<span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>
kind: Deployment
apiVersion: extensions<span class="hljs-operator">/</span>v1beta1
metadata:
  namespace: kube<span class="hljs-operator">-</span>system
  name: traefik
  labels:
    app: traefik

spec:
  replicas: <span class="hljs-number">1</span>
  selector:
    matchLabels:
      app: traefik
  template:
    metadata:
      labels:
        app: traefik
    spec:
      serviceAccountName: traefik<span class="hljs-operator">-</span>ingress<span class="hljs-operator">-</span>controller
      containers:
        <span class="hljs-operator">-</span> name: traefik
          image: traefik:v2<span class="hljs-number">.0</span>
          args:
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>log.level=INFO
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>api.dashboard=<span class="hljs-literal">true</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>api.insecure=<span class="hljs-literal">true</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>accesslog
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>global.sendanonymoususage
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>entrypoints.web.Address=:<span class="hljs-number">80</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>entrypoints.websecure.Address=:<span class="hljs-number">443</span>
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>providers.kubernetescrd
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>certificatesresolvers.default.acme.tlschallenge
            <span class="hljs-operator">-</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>certificatesresolvers.default.acme.email=<span class="hljs-operator">&lt;</span>your email <span class="hljs-keyword">address</span>@fqdn.com&gt;
          ports:
            <span class="hljs-operator">-</span> name: web
              containerPort: <span class="hljs-number">80</span>
            <span class="hljs-operator">-</span> name: websecure
              containerPort: <span class="hljs-number">443</span>
            <span class="hljs-operator">-</span> name: admin
              containerPort: <span class="hljs-number">8080</span>
</code></pre><p>The two new fields:</p>
<blockquote>
<p>--certificatesresolvers.default.acme.tlschallenge - Enable TLS Challenge
    --certificatesresolvers.default.acme.email=&lt;your email address@fqdn.com - The email address used to register the SSL Certs, used only for communication</p>
</blockquote>
<p>Save the file and apply it:</p>
<pre><code>kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>deployment.yaml
</code></pre><p>Traefik will restart the pods, it’s fast but until then we can simply update our IngressRoute to make use of the SSL enabled. Open the previously saved traefik-ingress-dashboard.yaml and update it:</p>
<pre><code><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">traefik.containo.us/v1alpha1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Middleware</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">test-auth</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">basicAuth:</span>
    <span class="hljs-attr">secret:</span> <span class="hljs-string">mysecret</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">traefik.containo.us/v1alpha1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">IngressRoute</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-dashboard</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">entryPoints:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">web</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">websecure</span>
  <span class="hljs-attr">routes:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">match:</span> <span class="hljs-string">Host(`&lt;your-domain.fqdn&gt;`)</span>
    <span class="hljs-attr">kind:</span> <span class="hljs-string">Rule</span>
    <span class="hljs-attr">services:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">traefik</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">8080</span>
    <span class="hljs-attr">middlewares:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">test-auth</span>
</code></pre><p>The difference between the two IngressRoutes are:</p>
<ul>
<li><code>entryPoints</code> - Traefik has 3 entrypoints, http, https and admin. For https, port 443, we used the name <code>websecure</code>, you can see this in the deployment definition.</li>
<li><code>tls.certResolver</code> - You can have multiple certResolvers, which is great, imagine using some protected, company owned cert provider but you also want to have public endpoints. The name of the certResolver is default, as defined in the <code>--certificatesresolvers.default.acme.tlschallenge</code> option in the deployments.</li>
</ul>
<p>Let’s apply:</p>
<pre><code>kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>ingress<span class="hljs-operator">-</span>deployment.yaml
</code></pre><p>Once you go to <code>https://your-domain.fqdn</code> you should be presented with the basic auth, once you log in, the dashboard should present its self behind SSL in all of its glory! Congratulations, we have achieved something great today!</p>
<h2 id="heading-some-thoughts-after-the-journey">Some thoughts after the journey</h2>
<p>Civo Cloud</p>
<p>The beta k3s cluster presented by Civo Cloud had no issues, everything worked correctly. The configuration around it is not optimal at this point, but it’s a beta feature, we’re helping by testing the cluster its self. Network security around it will be addressed, at least that’s what I’ve seen from the discussions in slack. I’d like to see an option where I can simply disable the public IPs and just have a load balancer in front of it. Locked down security groups.</p>
<p>I want to work on some sort of automation on configuring the firewalls once they get created, I’ve seen some write up about using terraform with Civo Cloud, which is great news!</p>
<p>Civo Cloud does have the option for Load Balancers, I just didn’t look in to it long enough on how can I use one with the k3s cluster.</p>
<h3 id="heading-traefik">Traefik</h3>
<p>I am very excited about Traefik v2 for the simple fact that I’ve been using their product for two years now, I’ve seen it mature, it works in production, it’s just getting better. Especilly with the new v2 feature of <a target="_blank" href="https://docs.traefik.io/observability/tracing/overview/">Observability</a>, which I do want to look in to more, maybe that will be another post down the line. Then there is <a target="_blank" href="https://mae.sh/">Maesh</a>, the simple service mesh!</p>
<p>Documentation for v2 is scarce, though as mentioned, I could be contributing, so it’s on me as well. I’m very glad that I got v2 working on a k3s install, from here on it’s just me playing around with all the new options and I’m really curious to see what metrics are exposed for Prometheus, which is the next big thing I want to look at, especially that there are no stats in the new Traefik v2 Dashboard.</p>
]]></content:encoded></item><item><title><![CDATA[Civo Cloud k3s: Enable Traefik Dashboard]]></title><description><![CDATA[This article is out of date. In this post I wanted to showcase how you can get the traefik dashboard enabled on the default civo cloud kubernetes k3s…]]></description><link>https://akos.me/civo-cloud-k3s-enable-traefik-dashboard</link><guid isPermaLink="true">https://akos.me/civo-cloud-k3s-enable-traefik-dashboard</guid><category><![CDATA[k3s]]></category><category><![CDATA[civo]]></category><category><![CDATA[Traefik]]></category><dc:creator><![CDATA[Ákos Veres]]></dc:creator><pubDate>Tue, 01 Oct 2019 23:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/GCFuprAvC6A/upload/v1663600956841/CqtDD2uQC.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>This article is out of date.</em></p>
<p>In this post I wanted to showcase how you can get the traefik dashboard enabled on the default civo cloud kubernetes k3s cluster. (It’s currently in beta, you can request access here). I must add, I’ve only played around with this for around an hour, I’m sure there are better ways (I don’t have that much experience with helm, I couldn’t edit the deployed version.)</p>
<p>The k3s cluster has been setup following <a target="_blank" href="https://www.civo.com/learn/kubernetes-cluster-administration-using-civo-cli">the civo kubernetes guide</a>.</p>
<p>The default helm chart has the dashboard disabled by default. The default options can be seen on <a target="_blank" href="https://github.com/helm/charts/tree/master/stable/traefik#configuration">the helm chart github page</a>. The <code>toml</code> file is stored as a configmap, we can just simply overwrite it:</p>
<pre><code>apiVersion: v1
data:
  traefik.toml: |
    <span class="hljs-comment"># traefik.toml</span>
    logLevel = <span class="hljs-string">"info"</span>
    defaultEntryPoints = [<span class="hljs-string">"http"</span>,<span class="hljs-string">"https"</span>]
    [entryPoints]
      [entryPoints.http]
      address = <span class="hljs-string">":80"</span>
      compress = <span class="hljs-literal">true</span>
      [entryPoints.https]
      address = <span class="hljs-string">":443"</span>
      compress = <span class="hljs-literal">true</span>
        [entryPoints.https.tls]
          [[entryPoints.https.tls.certificates]]
          CertFile = <span class="hljs-string">"/ssl/tls.crt"</span>
          KeyFile = <span class="hljs-string">"/ssl/tls.key"</span>
    [ping]
    entryPoint = <span class="hljs-string">"http"</span>
    [kubernetes]
      [kubernetes.ingressEndpoint]
      publishedService = <span class="hljs-string">"kube-system/traefik"</span>
    [traefikLog]
      format = <span class="hljs-string">"json"</span>
    [api]
      dashboard = <span class="hljs-literal">true</span>
kind: ConfigMap
metadata:
  labels:
    app: traefik
    chart: traefik<span class="hljs-number">-1.76</span><span class="hljs-number">.1</span>
    heritage: Tiller
    release: traefik
  name: traefik
  <span class="hljs-keyword">namespace</span>: <span class="hljs-title">kube</span>-<span class="hljs-title">system</span>
</code></pre><p>Take a look at <a target="_blank" href="https://docs.traefik.io/v1.7/configuration/api/">the traefik api definition page</a> and make sure you add the missing [api] entries to the file. Once you save the file we need to apply the configuration and need to restart the traefik pod so the toml configuration file is reload.</p>
<pre><code><span class="hljs-attribute">kubectl</span> apply -f traefik-configmap.yaml
<span class="hljs-attribute">kubectl</span> get pods -n kube-system
<span class="hljs-comment"># ...</span>
<span class="hljs-comment"># traefik-6f7cd584cb-l9nsn         1/1     Running     0          10m</span>
<span class="hljs-attribute">kubectl</span> delete pod traefik-<span class="hljs-number">6</span>f<span class="hljs-number">7</span>cd<span class="hljs-number">584</span>cb-l<span class="hljs-number">9</span>nsn
</code></pre><p>Once you tail the logs of the pod you should see that the new pod has re-read the configuration file and has also started on port 8080.</p>
<pre><code>{<span class="hljs-attr">"level"</span>:<span class="hljs-string">"info"</span>,<span class="hljs-attr">"msg"</span>:<span class="hljs-string">"Server configuration reloaded on :8080"</span>,<span class="hljs-attr">"time"</span>:<span class="hljs-string">"2019-10-02T19:13:40Z"</span>}
</code></pre><p>At this point the container is listening on port 8080, we need to modify the deployment of traefik so the admin port is exposed</p>
<pre><code><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">extensions/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">annotations:</span>
  <span class="hljs-attr">generation:</span> <span class="hljs-number">2</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">traefik</span>
    <span class="hljs-attr">chart:</span> <span class="hljs-string">traefik-1.76.1</span>
    <span class="hljs-attr">heritage:</span> <span class="hljs-string">Tiller</span>
    <span class="hljs-attr">release:</span> <span class="hljs-string">traefik</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">progressDeadlineSeconds:</span> <span class="hljs-number">600</span>
  <span class="hljs-attr">replicas:</span> <span class="hljs-number">1</span>
  <span class="hljs-attr">revisionHistoryLimit:</span> <span class="hljs-number">10</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">matchLabels:</span>
      <span class="hljs-attr">app:</span> <span class="hljs-string">traefik</span>
      <span class="hljs-attr">release:</span> <span class="hljs-string">traefik</span>
  <span class="hljs-attr">strategy:</span>
    <span class="hljs-attr">rollingUpdate:</span>
      <span class="hljs-attr">maxSurge:</span> <span class="hljs-number">25</span><span class="hljs-string">%</span>
      <span class="hljs-attr">maxUnavailable:</span> <span class="hljs-number">25</span><span class="hljs-string">%</span>
    <span class="hljs-attr">type:</span> <span class="hljs-string">RollingUpdate</span>
  <span class="hljs-attr">template:</span>
    <span class="hljs-attr">metadata:</span>
      <span class="hljs-attr">creationTimestamp:</span> <span class="hljs-literal">null</span>
      <span class="hljs-attr">labels:</span>
        <span class="hljs-attr">app:</span> <span class="hljs-string">traefik</span>
        <span class="hljs-attr">chart:</span> <span class="hljs-string">traefik-1.76.1</span>
        <span class="hljs-attr">heritage:</span> <span class="hljs-string">Tiller</span>
        <span class="hljs-attr">release:</span> <span class="hljs-string">traefik</span>
    <span class="hljs-attr">spec:</span>
      <span class="hljs-attr">containers:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">args:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">--configfile=/config/traefik.toml</span>
        <span class="hljs-attr">image:</span> <span class="hljs-string">traefik:1.7.12</span>
        <span class="hljs-attr">imagePullPolicy:</span> <span class="hljs-string">IfNotPresent</span>
        <span class="hljs-attr">livenessProbe:</span>
          <span class="hljs-attr">failureThreshold:</span> <span class="hljs-number">3</span>
          <span class="hljs-attr">httpGet:</span>
            <span class="hljs-attr">path:</span> <span class="hljs-string">/ping</span>
            <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
            <span class="hljs-attr">scheme:</span> <span class="hljs-string">HTTP</span>
          <span class="hljs-attr">initialDelaySeconds:</span> <span class="hljs-number">10</span>
          <span class="hljs-attr">periodSeconds:</span> <span class="hljs-number">10</span>
          <span class="hljs-attr">successThreshold:</span> <span class="hljs-number">1</span>
          <span class="hljs-attr">timeoutSeconds:</span> <span class="hljs-number">2</span>
        <span class="hljs-attr">name:</span> <span class="hljs-string">traefik</span>
        <span class="hljs-attr">ports:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">80</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">http</span>
          <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">8880</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">httpn</span>
          <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">443</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">https</span>
          <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">8080</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">admin</span>
          <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
        <span class="hljs-attr">readinessProbe:</span>
          <span class="hljs-attr">failureThreshold:</span> <span class="hljs-number">1</span>
          <span class="hljs-attr">httpGet:</span>
            <span class="hljs-attr">path:</span> <span class="hljs-string">/ping</span>
            <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
            <span class="hljs-attr">scheme:</span> <span class="hljs-string">HTTP</span>
          <span class="hljs-attr">initialDelaySeconds:</span> <span class="hljs-number">10</span>
          <span class="hljs-attr">periodSeconds:</span> <span class="hljs-number">10</span>
          <span class="hljs-attr">successThreshold:</span> <span class="hljs-number">1</span>
          <span class="hljs-attr">timeoutSeconds:</span> <span class="hljs-number">2</span>
        <span class="hljs-attr">resources:</span> {}
        <span class="hljs-attr">terminationMessagePath:</span> <span class="hljs-string">/dev/termination-log</span>
        <span class="hljs-attr">terminationMessagePolicy:</span> <span class="hljs-string">File</span>
        <span class="hljs-attr">volumeMounts:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">mountPath:</span> <span class="hljs-string">/config</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">config</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">mountPath:</span> <span class="hljs-string">/ssl</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">ssl</span>
      <span class="hljs-attr">dnsPolicy:</span> <span class="hljs-string">ClusterFirst</span>
      <span class="hljs-attr">restartPolicy:</span> <span class="hljs-string">Always</span>
      <span class="hljs-attr">schedulerName:</span> <span class="hljs-string">default-scheduler</span>
      <span class="hljs-attr">securityContext:</span> {}
      <span class="hljs-attr">serviceAccount:</span> <span class="hljs-string">traefik</span>
      <span class="hljs-attr">serviceAccountName:</span> <span class="hljs-string">traefik</span>
      <span class="hljs-attr">terminationGracePeriodSeconds:</span> <span class="hljs-number">60</span>
      <span class="hljs-attr">volumes:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">configMap:</span>
          <span class="hljs-attr">defaultMode:</span> <span class="hljs-number">420</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">traefik</span>
        <span class="hljs-attr">name:</span> <span class="hljs-string">config</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">ssl</span>
        <span class="hljs-attr">secret:</span>
          <span class="hljs-attr">defaultMode:</span> <span class="hljs-number">420</span>
          <span class="hljs-attr">secretName:</span> <span class="hljs-string">traefik-default-cert</span>
</code></pre><p>Save the file and let’s update the deployment:</p>
<pre><code>kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>deployment.yaml
</code></pre><p>To secure the dashboard we will just use basic auth, it’s simple and it works. I don’t want to repeat documentation already available, so please, see <a target="_blank" href="https://docs.traefik.io/v1.7/user-guide/kubernetes/#basic-authentication">the traefik documentation</a> on how to create the credentials.</p>
<p>The last remaining step is to create a service for the dashboard and actually expose it via traefik:</p>
<pre><code><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-web-ui</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">traefik</span>
  <span class="hljs-attr">ports:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
      <span class="hljs-attr">targetPort:</span> <span class="hljs-number">8080</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">admin</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">extensions/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Ingress</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">traefik-web-ui</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">kube-system</span>
  <span class="hljs-attr">annotations:</span>
    <span class="hljs-attr">kubernetes.io/ingress.class:</span> <span class="hljs-string">traefik</span>
    <span class="hljs-attr">ingress.kubernetes.io/auth-type:</span> <span class="hljs-string">"basic"</span>
    <span class="hljs-attr">ingress.kubernetes.io/auth-secret:</span> <span class="hljs-string">"mysecret"</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">rules:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-attr">host:</span> <span class="hljs-string">&lt;your-domain.fqdn&gt;</span>
    <span class="hljs-attr">http:</span>
      <span class="hljs-attr">paths:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">backend:</span>
          <span class="hljs-attr">serviceName:</span> <span class="hljs-string">traefik-web-ui</span>
          <span class="hljs-attr">servicePort:</span> <span class="hljs-number">80</span>
</code></pre><p>Let’s apply it:</p>
<pre><code>kubectl apply <span class="hljs-operator">-</span>f traefik<span class="hljs-operator">-</span>admin.yaml
</code></pre><p>The last step is to actually point your domain to your Civo Kubernetes endpoint IP. The IP address can be found via the civo CLI tool:</p>
<pre><code>civo kubernetes <span class="hljs-keyword">show</span> &lt;<span class="hljs-type">name</span> <span class="hljs-keyword">of</span> the <span class="hljs-keyword">cluster</span>&gt; | grep API
</code></pre><p>If you want to use Traefik v2, please check out <a target="_blank" href="https://akos.me/2019/civo-cloud-treafik-v2-tls/">this blog post</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Airapi Tunein From Golang]]></title><description><![CDATA[Just a small snipet on how to send data to TuneIn’s AirAPI from golang. This way you can update your metadata information directly from your API, if you…]]></description><link>https://akos.me/airapi-tunein-from-golang</link><guid isPermaLink="true">https://akos.me/airapi-tunein-from-golang</guid><category><![CDATA[golang]]></category><category><![CDATA[airapi]]></category><category><![CDATA[xtradio]]></category><dc:creator><![CDATA[Ákos Veres]]></dc:creator><pubDate>Thu, 21 Sep 2017 23:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Just a small snipet on how to send data to TuneIn’s AirAPI from golang. This way you can update your metadata information directly from your API, if you wish.</p>
<pre><code><span class="hljs-keyword">import</span> (
    <span class="hljs-string">"fmt"</span>
    <span class="hljs-string">"net/http"</span>
    <span class="hljs-string">"net/url"</span>
    <span class="hljs-string">"time"</span>
)

<span class="hljs-title">func</span> <span class="hljs-title">tuneinAPI</span>(<span class="hljs-title">artist</span> <span class="hljs-title"><span class="hljs-keyword">string</span></span>, <span class="hljs-title">title</span> <span class="hljs-title"><span class="hljs-keyword">string</span></span>) {

    <span class="hljs-title">partnerid</span> :<span class="hljs-operator">=</span> <span class="hljs-title">os</span>.<span class="hljs-title">Getenv</span>(<span class="hljs-string">"TUNEIN_PARTNER_ID"</span>)
    <span class="hljs-title">partnerkey</span> :<span class="hljs-operator">=</span> <span class="hljs-title">os</span>.<span class="hljs-title">Getenv</span>(<span class="hljs-string">"TUNEIN_PARTNER_KEY"</span>)
    <span class="hljs-title">stationid</span> :<span class="hljs-operator">=</span> <span class="hljs-title">os</span>.<span class="hljs-title">Getenv</span>(<span class="hljs-string">"TUNEIN_STATION_ID"</span>)
    <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">partnerid</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">""</span> <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-title">partnerkey</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">""</span> <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-title">stationid</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">""</span> {
        <span class="hljs-title">fmt</span>.<span class="hljs-title">Println</span>(<span class="hljs-title">time</span>.<span class="hljs-title">Now</span>(), <span class="hljs-string">"No tunein creds, skipping."</span>)
        <span class="hljs-title"><span class="hljs-keyword">return</span></span>
    }

    <span class="hljs-title"><span class="hljs-keyword">var</span></span> <span class="hljs-title">URL</span> <span class="hljs-operator">*</span><span class="hljs-title">url</span>.<span class="hljs-title">URL</span>
    <span class="hljs-title">URL</span>, <span class="hljs-title">err</span> :<span class="hljs-operator">=</span> <span class="hljs-title">url</span>.<span class="hljs-title">Parse</span>(<span class="hljs-string">"http://air.radiotime.com/Playing.ashx?"</span>)
    <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">err</span> <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-title">nil</span> {
        <span class="hljs-title">fmt</span>.<span class="hljs-title">Println</span>(<span class="hljs-title">time</span>.<span class="hljs-title">Now</span>(), <span class="hljs-string">"Tunein URL unavailable"</span>)
        <span class="hljs-title"><span class="hljs-keyword">return</span></span>
    }

    <span class="hljs-title">parameters</span> :<span class="hljs-operator">=</span> <span class="hljs-title">url</span>.<span class="hljs-title">Values</span>{}
    <span class="hljs-title">parameters</span>.<span class="hljs-title">Add</span>(<span class="hljs-string">"partnerId"</span>, <span class="hljs-title">partnerid</span>)
    <span class="hljs-title">parameters</span>.<span class="hljs-title">Add</span>(<span class="hljs-string">"partnerKey"</span>, <span class="hljs-title">partnerkey</span>)
    <span class="hljs-title">parameters</span>.<span class="hljs-title">Add</span>(<span class="hljs-string">"id"</span>, <span class="hljs-title">stationid</span>)
    <span class="hljs-title">parameters</span>.<span class="hljs-title">Add</span>(<span class="hljs-string">"artist"</span>, <span class="hljs-title">artist</span>)
    <span class="hljs-title">parameters</span>.<span class="hljs-title">Add</span>(<span class="hljs-string">"title"</span>, <span class="hljs-title">title</span>)
    <span class="hljs-title">URL</span>.<span class="hljs-title">RawQuery</span> <span class="hljs-operator">=</span> <span class="hljs-title">parameters</span>.<span class="hljs-title">Encode</span>()

    <span class="hljs-title">fmt</span>.<span class="hljs-title">Printf</span>(<span class="hljs-string">"Encoded URL is %q\n"</span>, <span class="hljs-title">URL</span>.<span class="hljs-title">String</span>())
    <span class="hljs-title">res</span>, <span class="hljs-title">err</span> :<span class="hljs-operator">=</span> <span class="hljs-title">http</span>.<span class="hljs-title">Get</span>(<span class="hljs-title">URL</span>.<span class="hljs-title">String</span>())
    <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">err</span> <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-title">nil</span> {
        <span class="hljs-title">fmt</span>.<span class="hljs-title">Println</span>(<span class="hljs-title">err</span>)
    }
    <span class="hljs-title"><span class="hljs-keyword">if</span></span> <span class="hljs-title">res</span>.<span class="hljs-title">StatusCode</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> 200 {
        <span class="hljs-title">fmt</span>.<span class="hljs-title">Println</span>(<span class="hljs-title">time</span>.<span class="hljs-title">Now</span>(), <span class="hljs-string">"TuneIn: "</span><span class="hljs-operator">+</span><span class="hljs-title">artist</span><span class="hljs-operator">+</span><span class="hljs-string">" - "</span><span class="hljs-operator">+</span><span class="hljs-title">title</span>)
    } <span class="hljs-title"><span class="hljs-keyword">else</span></span> {
        <span class="hljs-title">fmt</span>.<span class="hljs-title">Println</span>(<span class="hljs-title">time</span>.<span class="hljs-title">Now</span>(), <span class="hljs-string">"Tunein submission failed."</span>)
    }
}
</code></pre><p>Make sure you export the TUNEIN environment variables. This code is currently used over at XTRadio</p>
]]></content:encoded></item><item><title><![CDATA[Stream Icecast Stream To Youtube]]></title><description><![CDATA[At XTRadio we thought of taking our stream to a new platform (or even more), the first obvious choice was Youtube Live. Facebook Live could be another…]]></description><link>https://akos.me/stream-icecast-stream-to-youtube</link><guid isPermaLink="true">https://akos.me/stream-icecast-stream-to-youtube</guid><dc:creator><![CDATA[Ákos Veres]]></dc:creator><pubDate>Sat, 18 Mar 2017 00:00:00 GMT</pubDate><content:encoded><![CDATA[<p>At XTRadio we thought of taking our stream to a new platform (or even more), the first obvious choice was Youtube Live. Facebook Live could be another option but it only allows 4 continous hours of stream, so it wouldn’t allow us to stream our 24/7 broadcast.</p>
<p>Youtube Live has been easy enough to setup, we’ve used ffmpeg on a Debian server, it takes an image and our stream, puts them together and it pushes to Youtube. Easy peasy, eh? One thing to keep in ming: make the image HD, then the stream will be HD as well, of course use the best stream you have. Here’s our way of running things:</p>
<pre><code><span class="hljs-attribute">avconv</span> -loop <span class="hljs-number">1</span> -i /MUSIC/xt-hd.png -i http://localhost:<span class="hljs-number">8080</span>/mp<span class="hljs-number">3</span> -r <span class="hljs-number">30</span> -acodec aac -strict -<span class="hljs-number">2</span> -c:v libx<span class="hljs-number">264</span> -strict experimental -b:a <span class="hljs-number">128</span>k -pix_fmt yuvj<span class="hljs-number">444</span>p -b:v <span class="hljs-number">256</span>k -minrate <span class="hljs-number">128</span>k -maxrate <span class="hljs-number">512</span>k -bufsize <span class="hljs-number">768</span>k -f flv rtmp://a.rtmp.youtube.com/live<span class="hljs-number">2</span>/[KEY]
</code></pre><p>(code is still WIP)</p>
<p>You can listen to the XTRadio Youtube Live Stream if you please, the next step is to bake this in to Liquidsoap and have the image display the song information as well, eventually have some sort of live equalizer. And run all of this dockerized, but that’s another post.</p>
]]></content:encoded></item></channel></rss>