<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Quay | DCMST</title><link>https://portfolio.devcrumbs.com/tag/quay/</link><atom:link href="https://portfolio.devcrumbs.com/tag/quay/index.xml" rel="self" type="application/rss+xml"/><description>Quay</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Mon, 18 Jun 2018 00:00:00 +0000</lastBuildDate><image><url>https://portfolio.devcrumbs.com/media/icon_hu28290437db960aa4e7d19bb9f7230401_6937_512x512_fill_lanczos_center_3.png</url><title>Quay</title><link>https://portfolio.devcrumbs.com/tag/quay/</link></image><item><title>Set a hugo blog on Kubernetes</title><link>https://portfolio.devcrumbs.com/blog-hugo-docker-k8s-quay/</link><pubDate>Mon, 18 Jun 2018 00:00:00 +0000</pubDate><guid>https://portfolio.devcrumbs.com/blog-hugo-docker-k8s-quay/</guid><description>&lt;details class="toc-inpage d-print-none " open>
&lt;summary class="font-weight-bold">Table of Contents&lt;/summary>
&lt;nav id="TableOfContents">
&lt;ul>
&lt;li>&lt;a href="#overview">Overview&lt;/a>
&lt;ul>
&lt;li>&lt;a href="#architecture">Architecture&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;a href="#containerized">Containerized&lt;/a>
&lt;ul>
&lt;li>&lt;a href="#dockerfile">Dockerfile&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;/nav>
&lt;/details>
&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>Since last year I been trying to become an SRE (Site Reliability Engineer), so I been involved with some emerging technologies, like ansible, docker and on this time with kubernetes.&lt;/p>
&lt;p>This time, I will try to explain how I containerized my blog using:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.docker.com/" target="_blank" rel="noopener">Docker&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://kubernetes.io/" target="_blank" rel="noopener">Kubernetes&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://quay.io/" target="_blank" rel="noopener">Quay&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com" target="_blank" rel="noopener">Git&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="architecture">Architecture&lt;/h3>
&lt;p>So, I take some ideas from &lt;a href="https://www.civo.com/learn/using-civo-k3s-service-to-host-your-blog-in-hugo-using-github-actions" target="_blank" rel="noopener">here&lt;/a> and I modify them and adapt the architecture described to my options.&lt;/p>
&lt;p>The principal changes that I made are:&lt;/p>
&lt;ul>
&lt;li>My Kubernetes cluster is running on 2 cloud server on Rackspace Public Cloud&lt;/li>
&lt;li>The container registry that I&amp;rsquo;m using is Quay&lt;/li>
&lt;li>Rackspace Public Cloud does not support a Kubernetes LoadBalancer service automatically,
so I simulate that behavior adding a Cloud Load Balancer manually after the Kubernetes service provide me the port.&lt;/li>
&lt;/ul>
&lt;figure id="figure-blog-hugo-architecture">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Architecture" srcset="
/media/posts/blog-hugo-docker-k8s-quay/architecture_hu8b96b5b52b85b051d387a2869880f3ab_113861_90038fb3c81eb33b4ff587d44167dbfc.webp 400w,
/media/posts/blog-hugo-docker-k8s-quay/architecture_hu8b96b5b52b85b051d387a2869880f3ab_113861_422b03095e3febbbd91dbb98eee4f1ca.webp 760w,
/media/posts/blog-hugo-docker-k8s-quay/architecture_hu8b96b5b52b85b051d387a2869880f3ab_113861_1200x1200_fit_q90_h2_lanczos_3.webp 1200w"
src="https://portfolio.devcrumbs.com/media/posts/blog-hugo-docker-k8s-quay/architecture_hu8b96b5b52b85b051d387a2869880f3ab_113861_90038fb3c81eb33b4ff587d44167dbfc.webp"
width="760"
height="486"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Architecture
&lt;/figcaption>&lt;/figure>
&lt;h2 id="containerized">Containerized&lt;/h2>
&lt;p>I use &lt;a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo&lt;/a> to deploy my blog, I used to do it as mentioned on &lt;a href="https://d-cmst.io/deployment-hugo-site-git-hooks/" target="_blank" rel="noopener">this&lt;/a> previous post (In Spanish).&lt;/p>
&lt;p>Now, as a part of containerize the blog it make sense to me to create two stages as described &lt;a href="https://www.civo.com/learn/using-civo-k3s-service-to-host-your-blog-in-hugo-using-github-actions" target="_blank" rel="noopener">here&lt;/a>:&lt;/p>
&lt;ul>
&lt;li>The first stage is a defined build environment containing all required build tools (hugo, pygments) and the source of the website (Git repository).&lt;/li>
&lt;li>The second stage is the build artifact (HTML and assets), from the first stage and a webserver to serve the artifact over HTTP.&lt;/li>
&lt;/ul>
&lt;h3 id="dockerfile">Dockerfile&lt;/h3>
&lt;p>Here is the Dockerfile that containerize the blog:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">FROM ubuntu:latest as STAGEONE
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># install hugo&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ENV &lt;span class="nv">HUGO_VERSION&lt;/span>&lt;span class="o">=&lt;/span>0.41
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ADD https://github.com/gohugoio/hugo/releases/download/v&lt;span class="si">${&lt;/span>&lt;span class="nv">HUGO_VERSION&lt;/span>&lt;span class="si">}&lt;/span>/hugo_&lt;span class="si">${&lt;/span>&lt;span class="nv">HUGO_VERSION&lt;/span>&lt;span class="si">}&lt;/span>_Linux-64bit.tar.gz /tmp/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">RUN tar -xf /tmp/hugo_&lt;span class="si">${&lt;/span>&lt;span class="nv">HUGO_VERSION&lt;/span>&lt;span class="si">}&lt;/span>_Linux-64bit.tar.gz -C /usr/local/bin/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># install syntax highlighting&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">RUN apt-get update
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">RUN apt-get install -y python3-pygments
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># build site&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">COPY &lt;span class="nb">source&lt;/span> /source
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">RUN hugo --source&lt;span class="o">=&lt;/span>/source/ --destination&lt;span class="o">=&lt;/span>/public/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">FROM nginx:stable-alpine
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">RUN apk --update add curl bash
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">RUN rm /etc/nginx/conf.d/default.conf
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">COPY modules/nginx.d-cmst.io.conf /etc/nginx/conf.d/d-cmst.io.conf
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">COPY --from&lt;span class="o">=&lt;/span>STAGEONE /public/ /usr/share/nginx/html/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">EXPOSE &lt;span class="m">80&lt;/span> &lt;span class="m">443&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">MAINTAINER dcmst &amp;lt;dcmst@gmx.com&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="first-stage">First Stage&lt;/h4>
&lt;ul>
&lt;li>Fetch the lastest Ubuntu image and name as &lt;strong>STAGEONE&lt;/strong>&lt;/li>
&lt;li>Install the last available &lt;strong>hugo&lt;/strong> version from source.&lt;/li>
&lt;li>Install &lt;strong>pygments&lt;/strong> library to use it for highlighting.&lt;/li>
&lt;li>Build the site with &lt;strong>hugo&lt;/strong> and the output is set on &lt;strong>/public&lt;/strong> as a build artifact.&lt;/li>
&lt;/ul>
&lt;h4 id="second-stage">Second Stage&lt;/h4>
&lt;ul>
&lt;li>Fetch the lastest stable nginx alpine image.&lt;/li>
&lt;li>Update the image and install some utilities.&lt;/li>
&lt;li>Delete the &lt;strong>default&lt;/strong> nginx configuration file.&lt;/li>
&lt;li>Copy the configuration files needed from the repository root directory.&lt;/li>
&lt;li>Copy the build artifact &lt;strong>/public&lt;/strong> from the previous stage (&lt;strong>STAGEONE&lt;/strong>)&lt;/li>
&lt;/ul></description></item></channel></rss>