<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mattia Peri on Medium]]></title>
        <description><![CDATA[Stories by Mattia Peri on Medium]]></description>
        <link>https://medium.com/@mattiaperi?source=rss-9b569e4045a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*vrM6gT4X5ofe3yf0n6XWWQ.png</url>
            <title>Stories by Mattia Peri on Medium</title>
            <link>https://medium.com/@mattiaperi?source=rss-9b569e4045a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:28:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mattiaperi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Serverless or Kubernetes? Serverless ON Kubernetes!]]></title>
            <link>https://medium.com/@mattiaperi/serverless-or-kubernetes-serverless-on-kubernetes-e88e086a177b?source=rss-9b569e4045a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e88e086a177b</guid>
            <category><![CDATA[multipass]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubeless]]></category>
            <dc:creator><![CDATA[Mattia Peri]]></dc:creator>
            <pubDate>Wed, 26 Feb 2020 21:54:16 GMT</pubDate>
            <atom:updated>2020-02-27T11:08:30.700Z</atom:updated>
            <content:encoded><![CDATA[<p>Many articles in recent months have focused on putting in opposition two of the most popular buzzwords in the DevOps world: serverless and Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tta3P0ahT8No0t94DsQAng.jpeg" /></figure><p>I leave to <a href="http://techgenix.com/kubernetes-and-serverless/">these</a> <a href="https://towardsdatascience.com/kubernetes-serverless-differences-84699f370609">articles</a> <a href="https://thenewstack.io/why-serverless-vs-kubernetes-isnt-a-real-debate/">the</a> <a href="https://serverless.com/blog/why-we-switched-from-docker-to-serverless/">considerations</a> on the merits and demerits of each technology, while I prefer to focus on taking the best from each of them and <strong>set up a serverless platform on top of a Kubernetes cluster and deploy a sample function from scratch with only 10 commands</strong>.</p><h3>Why Kubeless?</h3><p>There are many frameworks that aim to make Kubernetes a serverless platform and Kubeless, developed by <a href="https://bitnami.com/">Bitnami</a>, is one of them. What makes it special? As per official statement:</p><blockquote>“Kubeless uses k8s primitives, there is no additional API server or API router/gateway. Kubernetes users will quickly understand how it works and be able to leverage their existing logging and monitoring setup as well as their troubleshooting skills.”</blockquote><p>What I really love about Kubeless is the ability to manage functions like standard Kubernetes objects. Indeed, Kubeless works by adding the concept of a “function” as a custom resource definition (CRD) in Kubernetes turning Kubernetes into a Function As A Service platform, without being forced to add any layer of difficulty like a messaging bus as per other serverless frameworks.</p><p>There are many ways to interact with the Kubeless framework, for example using:</p><ul><li>the <a href="https://kubeless.io/docs/quick-start/">Kubeless CLI</a></li><li>the <a href="https://github.com/kubeless/kubeless-ui">Kubeless UI</a></li><li>the <a href="https://serverless.com/">Serverless</a> framework and the <a href="https://github.com/serverless/serverless-kubeless">Kubeless plugin</a> (<a href="https://engineering.bitnami.com/articles/going-serverless-with-kubeless.html">how to</a>)</li><li>the kubectl binary, exactly as we are used to managing our Kubernetes clusters, and that’s what I’m going to show right now using <a href="https://multipass.run/">multipass</a> and <a href="https://github.com/rancher/k3s">Rancher k3s</a>.</li></ul><h3>A serverless platform on top of a kubernetes cluster from scratch</h3><p><strong>Install multipass</strong></p><blockquote>It’s a system that orchestrates the creation, management and maintenance of virtual machines and associated Ubuntu images to simplify development.</blockquote><pre>$ brew cask install multipass</pre><p>Multipass is available for <a href="https://multipass.run/docs/installing-on-macos">MacOs</a>, <a href="https://multipass.run/docs/installing-on-linux">GNU/Linux</a> and <a href="https://multipass.run/docs/installing-on-windows">Windows</a> as well.</p><p><strong>Set up the k3s cluster</strong></p><blockquote>K3s is a <a href="https://www.cncf.io/certification/software-conformance/">certified Kubernetes distribution</a> designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances.</blockquote><pre>### Create the VM named k3s<br>$ multipass launch --name k3s --cpus 2 --mem 2048M --disk 10G<br><em>Launched: k3s</em></pre><pre>### Install kubernetes<br>$ multipass exec k3s -- /bin/bash -c &quot;curl -sfL <a href="https://get.k3s.io/">https://get.k3s.io</a> | K3S_KUBECONFIG_MODE=&quot;644&quot; sh -&quot;<br><em>[INFO]  Finding latest release<br>[...]<br>[INFO]  systemd: Starting k3s</em></pre><pre>### Open a shell on k3s VM<br>$ multipass shell k3s<br><em>Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-88-generic x86_64)<br>[...]<br>ubuntu@k3s:~$</em></pre><p><strong>Install kubeless CRDs</strong></p><p>First we need to create a dedicated namespace and then deploy the kubeless CRDs:</p><pre>ubuntu@k3s:~$ kubectl create ns kubeless<br><em>namespace/kubeless created</em></pre><pre>ubuntu@k3s:~$ kubectl create -f <a href="https://github.com/kubeless/kubeless/releases/download/v1.0.6/kubeless-v1.0.6.yaml">https://github.com/kubeless/kubeless/releases/download/v1.0.6/kubeless-v1.0.6.yaml</a><br><em>[...]</em></pre><p><strong>Deploy a sample function</strong></p><p>That’s where the magic is. This sample function we are going to use is written in python 2.7 and it will output the data passed in input:</p><pre>def hello(event, context):<br>  print event<br>  return event[&#39;data&#39;]</pre><p>The function above is embedded into a Kubernetes manifest file similarly to how we would do with any other Kubernetes object. Copy and past in the shell the command below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8833586a5662820d02af21451d172200/href">https://medium.com/media/8833586a5662820d02af21451d172200/href</a></iframe><p>It’s done: the manifest above is deploying our function taking advantage of Kubernetes building blocks. What is happening here is that our function is going to be deployed inside a container, managed by a pod, controlled by a deployment to guarantee reliability as well as by a service to make it reachable from a network perspective. It’s amazing how straightforward it is, just using the kubectl CLI.</p><p><strong>Test the sample function</strong></p><p>Wait a few seconds (~30s) for the 2 pods (as we specified in the manifest file) to be in a running state and then it’s time to test the sample function using curl within the VM:</p><pre>ubuntu@k3s:~$ curl -s <a href="http://localhost:30333/">http://localhost:30333</a> --data &quot;<a href="https://www.youtube.com/watch?v=lQkpes3dgzg">You Talking To Me?</a>&quot;<br><em>You Talking To Me?</em></pre><p>Since we created the service as type NodePort we can also test the function from the host machine:</p><pre>ubuntu@k3s:~$ logout</pre><pre>$ curl -s <a href="http://$(multipass/">http://$(multipass</a> ls --format json | jq -r &#39;.list[] | select(.name==&quot;k3s&quot;) | .ipv4[]&#39;):30333 --data &quot;Well, I&#39;m the only one here.&quot;<br><em>Well, I&#39;m the only one here.</em></pre><p>where $(multipass ls --format json [...]) command is just a lazy way to get the VM IP.</p><p>Here we are, with few commands we got a serverless solution on top of a Kubernetes cluster. From now on we are free to deep dive!</p><h3>Deep dive</h3><p>We can deep dive into our function still using kubectl:</p><pre>$ multipass exec k3s -- /bin/bash -c &quot;kubectl get functions&quot;</pre><pre>$ multipass exec k3s -- /bin/bash -c &quot;kubectl describe functions function-echo&quot;</pre><pre>$ multipass exec k3s -- /bin/bash -c &quot;kubectl logs -l function=function-echo&quot;</pre><p>For those of you who are accustomed to Kubernetes, all this should look familiar:</p><pre>$ multipass exec k3s -- /bin/bash -c &quot;kubectl get all -l function=function-echo&quot;<br><em>NAME                                 READY   STATUS    RESTARTS   AGE<br>pod/function-echo-64fc8bccb9-cqk8d   1/1     Running   0          23m<br>pod/function-echo-64fc8bccb9-hbzts   1/1     Running   0          23m</em></pre><pre><em>NAME                    TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE<br>service/function-echo   NodePort   10.43.205.15   &lt;none&gt;        8080:30333/TCP   23m</em></pre><pre><em>NAME                            READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/function-echo   2/2     2            2           23m</em></pre><pre><em>NAME                                       DESIRED   CURRENT   READY   AGE<br>replicaset.apps/function-echo-64fc8bccb9   2         2         2       23m</em></pre><h3>The next step</h3><p>For the sake of honesty, I’ve been a little unfair until now, hiding some complexity under the carpet. Although it is true that we can deploy a function with Kubeless through only the kubectl binary, it is also true that to get the best out of it, we should rely on the command line binary provided by Kubeless.</p><p>This step is all about install and configure the kubeless binary in our VM k3s and repeat what we have done so far using the kubeless CLI:</p><pre>### Install kubeless CLI<br>$ multipass exec k3s -- /bin/bash -c &quot;\<br>  sudo apt-get install unzip &amp;&amp; \<br>  curl -sOL https://github.com/kubeless/kubeless/releases/download/v1.0.6/kubeless_linux-amd64.zip &amp;&amp; \<br>  unzip kubeless_linux-amd64.zip &amp;&amp; \<br>  sudo mv bundles/kubeless_linux-amd64/kubeless /usr/local/bin/ \<br>&quot;</pre><pre>### Open a shell on k3s VM<br>$ multipass shell k3s</pre><pre>### Enable kubeless completion and configure kubeless CLI<br>ubuntu@k3s:~$ echo -e &#39;export KUBECONFIG=/etc/rancher/k3s/k3s.yaml\nsource &lt;(kubeless completion bash)&#39; &gt;&gt; ~/.bashrc &amp;&amp; source ~/.bashrc</pre><p>Hereunder some example of kubeless commands, and how to obtain the same result we have seen with the kubernetes manifest file:</p><pre>### Create a file func.py with the function code<br>ubuntu@k3s:~$ cat &lt;&lt;EOF &gt; func.py<br>def hello(event, context):<br>  print event<br>  return event[&#39;data&#39;]<br>EOF</pre><pre>### Deploy the function<br>ubuntu@k3s:~$ kubeless function deploy echo-cli --runtime python2.7 \<br>                --from-file func.py \<br>                --handler handl.hello \<br>                --namespace default</pre><pre>### Check the functions<br>ubuntu@k3s:~$ kubeless function ls<br><em>NAME          NAMESPACE HANDLER     RUNTIME   DEPENDENCIES STATUS<br>function-echo default   hello.hello python2.7              2/2 READY<br>echo-cli      default   handl.hello python2.7              1/1 READY</em></pre><pre>### Test the function via kubeless CLI<br>ubuntu@k3s:~$ kubeless function call echo-cli --data &#39;Hello world!&#39;<br><em>Hello world!</em></pre><pre>### Monitor the functions<br>ubuntu@k3s:~$ kubeless function top<br><em>[...]</em></pre><pre>### Create an http trigger<br>ubuntu@k3s:~$ kubeless trigger http create echo-cli-http-trigger \<br>  --function-name echo-cli \<br>  --hostname <strong><em>192-168-64-2</em></strong>.nip.io \<br>  --path echo-cli<br><em>INFO[0000] HTTP trigger echo-cli-http-trigger created in namespace default successfully!</em></pre><pre>### Check the trigger correctly created ingress resource<br>ubuntu@k3s:~$ kubectl get ingress<br><em>NAME                    HOSTS                 ADDRESS        PORTS   AGE<br>echo-cli-http-trigger   192-168-64-2.nip.io   192.168.64.2   80      9s</em></pre><pre>ubuntu@k3s:~$ logout</pre><pre>### Test the function via curl<br>$ curl -XGET <strong>192-168-64-2</strong>.nip.io/echo-cli -d &quot;Hi there!&quot;<br><em>Hi there!</em></pre><p>where <strong><em>192–168–64–2</em></strong> is the VM IP. Please edit it accordingly.</p><h3>Clean up</h3><p>When we are ready to get rid of everything, just:</p><pre>$ multipass delete k3s --purge</pre><h3>Conclusion</h3><p>Serverless and kubernetes represent the latest effort to make developer’s life easier. They take different approaches toward a common goal, which is making sure developers can focus 100% on their code and not have to bother about infrastructure. IMHO, it’s a nonsense to put in competition two technologies which provide different pros and cons depending on business needs.</p><p>If you are interested in deep dive into multipass and k3s, you might find interesting my <a href="https://levelup.gitconnected.com/kubernetes-cluster-with-k3s-and-multipass-7532361affa3">previous Medium story</a>.</p><p><strong>References:</strong></p><ul><li><a href="https://docs.bitnami.com/kubernetes/how-to/get-started-serverless-computing-kubeless/">https://docs.bitnami.com/kubernetes/how-to/get-started-serverless-computing-kubeless/</a></li><li><a href="https://kubeless.io/docs/dev-guide/">https://kubeless.io/docs/dev-guide/</a></li><li><a href="https://kubeless.io/docs/quick-start/">https://kubeless.io/docs/quick-start/</a></li><li><a href="https://github.com/kubeless/kubeless/blob/master/docs/http-triggers.md">https://github.com/kubeless/kubeless/</a></li><li><a href="https://github.com/kubeless/kubeless/blob/master/docs/http-triggers.md">https://github.com/kubeless/kubeless/blob/master/docs/http-triggers.md</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e88e086a177b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes multi-nodes cluster with k3s and multipass]]></title>
            <link>https://levelup.gitconnected.com/kubernetes-cluster-with-k3s-and-multipass-7532361affa3?source=rss-9b569e4045a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7532361affa3</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k3]]></category>
            <category><![CDATA[kubectl]]></category>
            <category><![CDATA[multipass]]></category>
            <dc:creator><![CDATA[Mattia Peri]]></dc:creator>
            <pubDate>Sun, 02 Jun 2019 13:27:00 GMT</pubDate>
            <atom:updated>2020-01-07T10:12:18.841Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes multi-node cluster with k3s and multipass</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0P_MP5y1xJiNqnTDuyhS_w.png" /></figure><p>Working with <a href="https://kubernetes.io/">Kubernetes</a>, you might happen to need a local Kubernetes cluster for development and testing purposes. Of course, Minikube is an option. But what if we need something more powerful without any added complexity? For example, what if we are preparing ourselves for the <a href="https://www.cncf.io/certification/ckad/">CKAD: Certified Kubernetes Application Developer</a> certification?</p><p>Here is my personal solution on OS X (but should work smoothly with GNU/Linux too) that I’d like to share with you: <a href="https://github.com/CanonicalLtd/multipass">multipass</a> + <a href="https://github.com/rancher/k3s">k3s</a>.</p><h3>Multipass</h3><p>First, we need a virtualization layer in order to run any number of Kubernetes nodes. Very likely, the easiest way to get an <a href="https://discourse.ubuntu.com/t/multipass-now-available-for-macos/6824">Ubuntu VM on OS X</a> using <a href="https://github.com/CanonicalLtd/multipass">multipass</a>, created by Canonical Ltd:</p><blockquote>It’s a system that orchestrates the creation, management and maintenance of virtual machines and associated Ubuntu images to simplify development.</blockquote><h3>k3s</h3><p>Since I want to keep things small and simple, I take advantage of the amazing Kubernetes project created by <a href="https://github.com/rancher/k3s">Rancher k3s</a>. K3s promises to be a lightweight Kubernetes:</p><blockquote>K3s is a <a href="https://www.cncf.io/certification/software-conformance/">certified Kubernetes distribution</a> designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances.</blockquote><h3>How to create a local Kubernetes cluster</h3><p>KISS style, just 9 commands in 3 easy steps to set up a basic 3 node k3s cluster:</p><ol><li>Install multipass</li><li>Create the virtual machines</li><li>Create the k3s cluster</li></ol><h4><strong>Step 1: Install multipass</strong></h4><p>I take it for granted that <a href="https://brew.sh/">brew.sh</a> can’t be missing in your Mac. If not, please follow that <a href="https://brew.sh/">link</a>. After that, it is nothing more than:</p><pre>brew cask install multipass</pre><h4><strong>Step 2: Create the Virtual Machines</strong></h4><p>Let’s assume we would like a Kubernetes cluster with 1 master node (“k3s-master”) and 2 (worker) nodes (“k3s-worker1” and “k3s-worker2”).</p><pre>multipass launch --name k3s-master --cpus 1 --mem 1024M --disk 3G<br>multipass launch --name k3s-worker1 --cpus 1 --mem 1024M --disk 3G<br>multipass launch --name k3s-worker2 --cpus 1 --mem 1024M --disk 3G</pre><h4><strong>Step 3: Create the k3s cluster</strong></h4><p>Things here become a little more tricky and a couple of notes are deserved:</p><ul><li>The deploy of the k3s-master i̶s̶ was pretty straight forward as per <a href="https://k3s.io/">official instructions</a> until k3s release 0.6.0. Add K3S_KUBECONFIG_MODE=&quot;644&quot; for details jump to “Step 4. Configure kubectl”</li><li>k3s installation script, if not properly configured, is designed to boot as a single node cluster. Since we don’t want that, before deploying k3s-worker1 and k3s-worker2 we need two information from the master node, which are:<br>- k3s-master ip address, stored in the K3S_NODEIP_MASTER variable<br>- k3s-master k3s token, stored in the K3S_TOKEN variable<br>in order to allow the worker nodes to join the same k3s cluster created by the k3s-master node.</li><li>The deploy of k3s-worker1 and k3s-worker2 is merely a matter of the right configuration based on the 2 variables.</li></ul><pre># Deploy k3s on the master node<br>multipass exec k3s-master -- /bin/bash -c &quot;curl -sfL <a href="https://get.k3s.io/">https://get.k3s.io</a> | K3S_KUBECONFIG_MODE=&quot;644&quot; sh -&quot;</pre><pre># Get the IP of the master node<br>K3S_NODEIP_MASTER=&quot;https://$(multipass info k3s-master | grep &quot;IPv4&quot; | awk -F&#39; &#39; &#39;{print $2}&#39;):6443&quot;</pre><pre># Get the TOKEN from the master node<br>K3S_TOKEN=&quot;$(multipass exec k3s-master -- /bin/bash -c &quot;sudo cat /var/lib/rancher/k3s/server/node-token&quot;)&quot;</pre><pre># Deploy k3s on the worker node<br>multipass exec k3s-worker1 -- /bin/bash -c &quot;curl -sfL https://get.k3s.io | K3S_TOKEN=${K3S_TOKEN} K3S_URL=${K3S_NODEIP_MASTER} sh -&quot;</pre><pre># Deploy k3s on the worker node<br>multipass exec k3s-worker2 -- /bin/bash -c &quot;curl -sfL https://get.k3s.io | K3S_TOKEN=${K3S_TOKEN} K3S_URL=${K3S_NODEIP_MASTER} sh -&quot;</pre><p><strong>Check everything:</strong></p><pre>multipass list</pre><pre>Name State IPv4 Release<br>k3s-worker2 RUNNING 192.168.64.5 Ubuntu 18.04 LTS<br>k3s-worker1 RUNNING 192.168.64.4 Ubuntu 18.04 LTS<br>k3s-master RUNNING 192.168.64.3 Ubuntu 18.04 LTS</pre><pre>multipass exec k3s-master kubectl get nodes</pre><pre>NAME          STATUS   ROLES    AGE   VERSION<br>k3s-master    Ready    master   48s   v1.14.1-k3s.4<br>k3s-worker1   Ready    &lt;none&gt;   16s   v1.14.1-k3s.4<br>k3s-worker2   Ready    &lt;none&gt;   6s    v1.14.1-k3s.4</pre><p>N̶o̶t̶e̶ ̶t̶h̶e̶ ̶&lt;none&gt; ̶i̶n̶ ̶t̶h̶e̶ ̶ROLES ̶c̶o̶l̶u̶m̶n̶.̶ ̶I̶n̶ ̶t̶h̶e̶ ̶s̶e̶c̶o̶n̶d̶ ̶p̶a̶r̶t̶ ̶o̶f̶ ̶t̶h̶i̶s̶ ̶s̶t̶o̶r̶y̶,̶ ̶w̶e̶’̶l̶l̶ ̶g̶e̶t̶ ̶t̶h̶e̶r̶e̶. <em>Update 20191011: k3s release 0.6.0 introduced node roles and </em>--node-label and --node-taint flags.</p><p>That’s it, the Kubernetes cluster is up and running. Nevertheless, you might want to have a look at the following steps:</p><h3>How to create a local Kubernetes cluster (that makes sense)</h3><p>Hereunder I’m going to add some useful tips to make the cluster useful for developing and testing purposes:</p><p>4. Configure kubectl<br>5. Configure cluster node roles and taint<br>6. Helm installation<br>7. Service type “NodePort”<br>8. Ingress controller <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjKnILS0MriAhXSzaQKHf5xAjYQFjAAegQIBRAC&amp;url=https%3A%2F%2Ftraefik.io%2F&amp;usg=AOvVaw204mn6RPY_Znna2JH9mdFp">Traefik</a></p><h4><strong>Step 4. Configure kubectl</strong></h4><blockquote>Update 20191011: k3s release 0.6.0 changed default <em>k3s.yaml</em> permissions from 0644 to 0600 for <a href="https://github.com/rancher/k3s/issues/389">security reasons</a>. Please have a look to <a href="https://github.com/rancher/k3s/issues/389#issuecomment-503616742">https://github.com/rancher/k3s/issues/389#issuecomment-503616742</a>. To overcome this change (during startup phase) there are mainly two solutions:</blockquote><ul><li>Using --write-kubeconfig-mode 644</li></ul><pre>curl -sfL <a href="https://get.k3s.io/">https://get.k3s.io</a> | sh -s - --write-kubeconfig-mode 644</pre><ul><li>Using the variable K3S_KUBECONFIG_MODE</li></ul><pre>curl -sfL <a href="https://get.k3s.io/">https://get.k3s.io</a> | K3S_KUBECONFIG_MODE=&quot;644&quot; sh -s -</pre><blockquote>Update 20191011: k3s release 0.9.0 <a href="https://github.com/rancher/k3s/pull/750">“localhost” has been substituted by “127.0.0.1”</a> in k3s.yaml, which was causing sed command to fail.</blockquote><p>If we want to forget about the multipass CLI, it’s very easy to configure kubectl installed in your host machine to use the brand new k3s cluster directly (I’m assuming kubectl is already installed in your machine, otherwise: $ brew install kubernetes-cli). First, we need to retrieve the kubectl config file from the k3s-master node and edit the it with the k3s-master IP address, as described hereunder:</p><pre># Copy the k3s kubectl config file locally<br>$ multipass copy-files k3s-master:/etc/rancher/k3s/k3s.yaml ${HOME}/.kube/k3s.yaml</pre><pre># Edit the kubectl config file with the right IP address<br>$ sed -ie s,https://127.0.0.1:6443,${K3S_NODEIP_MASTER},g ${HOME}/.kube/k3s.yaml</pre><pre># Check<br>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml get nodes</pre><p>Specifying the --kubeconfig is boring and, above all, potentially dangerous in case we forget to do it and we run the wrong command in the wrong cluster (anyone? no? really?!). It might worth to merge the kubectl config file k3s.yaml with your current ${HOME}/.kube/config file or, since our k3s cluster is not intended to be written in the rocks, we have a couple of easy options (see the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/">official documentation</a> for details):</p><pre># Create a dedicated alias:<br>alias k3sctl=&quot;kubectl --kubeconfig=${HOME}/.kube/k3s.yaml&quot;</pre><p>or</p><pre># Use the KUBECONFIG variable<br>export KUBECONFIG=${HOME}/.kube/k3s.yaml</pre><h4><strong>Step 5. Configure cluster node roles and taint</strong></h4><blockquote>Update 20191011: k3s release 0.6.0 introduced node roles and --node-label and --node-taint flags. Therefore <strong>“Step 5.” is not needed anymore</strong>.</blockquote><p>As we have previously noticed, the 3 nodes have no roles. That’s because:</p><ul><li>K3s installation script does not label any node it creates</li><li>K3s installation script does not taint the master nodes for NoSchedule</li></ul><p>Let’s take care of these two configurations:</p><pre># Configure the node roles:<br>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml label node k3s-master node-role.kubernetes.io/master=””<br>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml label node k3s-worker1 node-role.kubernetes.io/node=””<br>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml label node k3s-worker2 node-role.kubernetes.io/node=””</pre><pre># Configure taint NoSchedule for the k3s-master node<br>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml taint node k3s-master node-role.kubernetes.io/master=effect:NoSchedule</pre><p>The nodes roles are now properly configured:</p><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml get nodes<br>NAME STATUS ROLES AGE VERSION<br>k3s-master Ready <strong>master</strong> 4h12m v1.14.1-k3s.4<br>k3s-worker1 Ready <strong>node</strong> 3h57m v1.14.1-k3s.4<br>k3s-worker2 Ready <strong>node</strong> 3h57m v1.14.1-k3s.4</pre><p>Eventually we are ready for a deployment. What I’d like to highlight is that the NGiNX pods are going to be scheduled only in the k3s-worker1 and k3s-worker2 nodes:</p><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml run nginx --image=nginx --replicas=3 --expose --port 80<br>kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.<br>service/nginx created<br>deployment.apps/nginx created</pre><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml get pods -o wide<br>NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES<br>nginx-755464dd6c-6nzvr 1/1 Running 0 3h22m 10.42.1.3 <strong>k3s-worker2</strong> &lt;none&gt; &lt;none&gt;<br>nginx-755464dd6c-rkd6r 1/1 Running 0 3h22m 10.42.1.4 <strong>k3s-worker2</strong> &lt;none&gt; &lt;none&gt;<br>nginx-755464dd6c-v5v64 1/1 Running 0 3h22m 10.42.2.3 <strong>k3s-worker1</strong> &lt;none&gt; &lt;none&gt;</pre><h4><strong>Step 6: Helm installation</strong></h4><p><a href="https://helm.sh/">Helm</a> tries to combine a <strong>template engine</strong> and a <strong>package manager</strong> for Kubernetes. Helm installation might not be as straightforward as we are used to, indeed k3s demands for a <a href="https://rancher.com/docs/rancher/v2.x/en/installation/ha/helm-init/">few more steps</a>:</p><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml -n kube-system create serviceaccount tiller</pre><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml create clusterrolebinding tiller \<br>--clusterrole=cluster-admin \<br>--serviceaccount=kube-system:tiller</pre><pre>$ helm --kubeconfig=${HOME}/.kube/k3s.yaml init --service-account tiller</pre><pre>$ helm --kubeconfig=${HOME}/.kube/k3s.yaml install stable/mysql</pre><p>If you are interested to know something more about Helm, I shared my experience with the Helm chart repository topic in the following story: “<a href="https://medium.com/@mattiaperi/create-a-public-helm-chart-repository-with-github-pages-49b180dbb417">Create a public Helm chart repository with GitHub Pages</a>”</p><h4><strong>Step 7: Service type “NodePort”</strong></h4><p>Actually this step is not k3s specific. I just wanted to highlight that the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport">NodePort services</a> creation is as easy as usual because the network between host machine and VMs is transparent for the user:</p><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml create deploy nginx2 --image=nginx</pre><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml create svc nodeport nginx2 --tcp=30001:80 --node-port=30001</pre><pre>$ curl -XGET -s -I -o /dev/null -w &quot;%{http_code}\n&quot; <a href="http://$(multipass/">http://$(multipass</a> info k3s-master | grep &quot;IPv4&quot; | awk -F&#39; &#39; &#39;{print $2}&#39;):30001<br>200</pre><h4>Step 8: Ingress controller <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjKnILS0MriAhXSzaQKHf5xAjYQFjAAegQIBRAC&amp;url=https%3A%2F%2Ftraefik.io%2F&amp;usg=AOvVaw204mn6RPY_Znna2JH9mdFp">Traefik</a></h4><p>I didn’t mention before but it’s easy to believe that to keep things light, k3s comes with some compromises and one of them regards <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress</a>. In order for the Ingress resource to work, the cluster must have an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/">Ingress Controller</a> running (and usually it’s <a href="https://www.nginx.com/products/nginx/kubernetes-ingress-controller">NGiNX</a>). K3s includes <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjKnILS0MriAhXSzaQKHf5xAjYQFjAAegQIBRAC&amp;url=https%3A%2F%2Ftraefik.io%2F&amp;usg=AOvVaw204mn6RPY_Znna2JH9mdFp">Traefik</a> for this purpose instead. It also includes a simple service <a href="https://github.com/rancher/k3s/blob/master/README.md#service-load-balancer">load balancer</a> that makes it possible to get an external IP for a Service in the cluster. Let’s see a simple example on how to configure the ingress controller (just edit the YAML file with the right ip address):</p><pre>$ cat &lt;&lt;EOF &gt; ingress-controller.yaml<br>apiVersion: extensions/v1beta1<br>kind: Ingress<br>metadata:<br>  name: ingress<br>spec:<br>  rules:<br>  - host: <strong>192.168.64.3</strong>.xip.io<br>    http:<br>      paths:<br>      - path: /<br>        backend:<br>          serviceName: nginx2<br>          servicePort: 30001<br>EOF</pre><pre>$ kubectl --kubeconfig=${HOME}/.kube/k3s.yaml apply -f ingress-controller.yaml<br>ingress.extensions/ingress created</pre><pre>$ curl -XGET -s -I -o /dev/null -w &quot;%{http_code}\n&quot; <a href="http://192.168.64.3.xip.io/">http://192.168.64.3.xip.io/</a><br>200 </pre><p><a href="https://nip.io/">nip.io</a> is a “Dead simple wildcard DNS for any IP Address” allowing you to map any IP Address to a hostname.</p><h4>Hint: how to connect via SSH</h4><p>In case you’d like to be more flexible and connect to multipass VMs via SSH instead of using multipass shell, you need to use the key at the path hereunder (OS X) with the right permissions and use the ubuntu user:</p><pre>$ sudo cp -a /var/root/Library/Application\ Support/multipassd/ssh-keys/id_rsa ~/.ssh/multipass<br>$ sudo chown $USER ~/.ssh/multipass<br>$ ssh -i ~/.ssh/multipass ubuntu@<em>192.168.64.3</em></pre><h4><strong>Final step: clean-up everything</strong></h4><p>It was a nice journey, now it’s time to get rid of everything:</p><pre>$ multipass stop k3s-master k3s-worker1 k3s-worker2<br>$ multipass delete k3s-master k3s-worker1 k3s-worker2<br>$ multipass purge</pre><h3><strong>Conclusion</strong></h3><p>It’s very easy to create a local multi-node Kubernetes cluster with a nice degree of complexity without losing the Minikube simplicity. Moreover, the solution described adds a remarkable level of flexibility thanks to multipass VMs implementation that guarantees isolation and security to your Kubernetes tweaking.</p><p>As a final hint, I created a bash script able to set up a k3s environment completed with all fancy stuff like metrics-server, weavescope, prometheus and istio. You are more than welcome to get ideas from it:</p><p><a href="https://github.com/mattiaperi/k3s-multipass-cluster">https://github.com/mattiaperi/k3s-multipass-cluster</a></p><p>I hope you find this information useful, any feedback or advice for improvements are very well accepted.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7532361affa3" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/kubernetes-cluster-with-k3s-and-multipass-7532361affa3">Kubernetes multi-nodes cluster with k3s and multipass</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a public Helm chart repository with GitHub Pages]]></title>
            <link>https://medium.com/@mattiaperi/create-a-public-helm-chart-repository-with-github-pages-49b180dbb417?source=rss-9b569e4045a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/49b180dbb417</guid>
            <category><![CDATA[yaml]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[github-pages]]></category>
            <dc:creator><![CDATA[Mattia Peri]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 08:20:41 GMT</pubDate>
            <atom:updated>2019-04-18T08:20:41.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*3v0SGXdJXsztqY7KRoQKOA.png" /></figure><p>In the last months I had the opportunity to work on Kubernetes and the ecosystem of tools built around it by the community. These tools aim to help the DevOps guys through all the stages of the Software Lifecycle, from the development phase to the deployment phase. One of these tools is <a href="https://helm.sh/">Helm</a>.</p><p><strong>What is Helm and a Helm chart repository</strong></p><p>Helm, as per <a href="https://helm.sh/">official claim</a>, is “The package manager for Kubernetes”.</p><p>Indeed Helm really helps handling application deployments on Kubernetes, not only because it simplifies the application release phase but also because Helm makes possible to easily manage variables in the Kubernetes manifest YAML files.</p><p>Once the charts are ready and you need to share them, the easiest way to do so is by uploading them to a chart repository. A Helm chart repository is where we host and share Helm packages and any HTTP server will do. Unluckily Helm does not include natively a tool for uploading charts to a remote chart repository server (Helm can serve the local repository via $ helm serve though).</p><p>We’ll take advantage of GitHub Pages for the purpose to share our charts.</p><p><strong>What is GitHub Pages</strong></p><p>GitHub Pages is a static site hosting service provided to you by GitHub, designed to host your pages directly from a GitHub repository. GitHub Pages is a perfect match for our purpose, since everything we need is to host a single index.yaml file along with a bunch of .tgz files.</p><p>Why not hosting all this stuff in your own web server? A managed service helps to reduce your operational overhead and risk (think to monitoring, patch management, security, backup services…) so you can focus on code and in what makes your business relevant for your customers.</p><h3><strong>Step-by-step guide</strong></h3><p><em>Please keep in mind that following the instruction below, your Helm charts repository will be public.</em></p><p>Let me guide you through how to implement this solution.</p><p><strong>Create a new repository on your Github account (i.e. “helm-chart”):</strong></p><p>Follow the link <a href="https://github.com/new">https://github.com/new</a> and login, then create a new git repository as per image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssMG7O18NzLv5dppmmlSuw.png" /></figure><p>Since it’s an empty repository, we can’t publish a GitHub Pages site for now, keep the browser tab open for later.</p><p><strong>Clone the repository</strong></p><pre>$ git clone https://github.com/mattiaperi/helm-chart.git &amp;&amp; cd helm-chart/<br>Cloning into ‘helm-chart’…<br>remote: Enumerating objects: 3, done.<br>remote: Counting objects: 100% (3/3), done.<br>remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0<br>Unpacking objects: 100% (3/3), done.</pre><p><strong>Create robots.txt</strong></p><p>I’d like to avoid bot crawling on my repository, so I add the following <a href="https://en.wikipedia.org/wiki/Robots_exclusion_standard">robots.txt</a> file:</p><pre>$ echo -e “User-Agent: *\nDisallow: /” &gt; robots.txt</pre><p><strong>Create a helm chart from scratch (or copy your own)</strong></p><p>As a pre-requisite of this stage, you need to have the Helm CLI installed and initialized. Please <a href="https://helm.sh/docs/using_helm/#installing-helm">find here the instructions</a> in case you haven’t install Helm client yet.</p><p>I’m going to use the directory ./helm-chart-sources/ for the sources of our charts. I’m creating a default chart just for testing purposes, you might want to copy into ./helm-chart-sources/ your charts instead:</p><pre>$ mkdir ./helm-chart-sources &amp;&amp; cd ./helm-chart-sources/</pre><pre>$ helm create helm-chart-sources/helm-chart-test<br>Creating helm-chart-sources/helm-chart-test</pre><p><strong>Lint the chart</strong></p><p>As a good habit, helm lint runs a series of tests to verify that<br>the chart is well-formed:</p><pre>$ helm lint helm-chart-sources/*</pre><p><strong>Create the Helm chart package</strong></p><pre>$ helm package helm-chart-sources/*<br>Successfully packaged chart and saved it to: /Users/perim/git/helm-chart/helm-chart-test-0.1.0.tgz</pre><p><strong>Create the Helm chart repository index</strong></p><p>According to <a href="https://helm.sh/docs/developing_charts/">Helm</a>:</p><blockquote>A repository is characterized primarily by the presence of a special file called index.yaml that has a list of all of the packages supplied by the repository, together with metadata that allows retrieving and verifying those packages.</blockquote><p>So, everything we need to create is the index.yaml file and the command to do that is:</p><pre>$ helm repo index --url <a href="https://mattiaperi.github.io/helm-chart/">https://mattiaperi.github.io/helm-chart/</a> .</pre><pre>$ cat index.yaml <br>apiVersion: v1<br>entries:<br>  helm-chart-test:<br>  - apiVersion: v1<br>    appVersion: &quot;1.0&quot;<br>    created: 2019-04-16T11:10:08.729944+02:00<br>    description: A Helm chart for Kubernetes<br>    digest: 35a4e31bfacc496f1b1bce664652916bb8701cc9df77f1b90534f5234ff297a6<br>    name: helm-chart-test<br>    urls:<br>    - <a href="https://mattiaperi.github.io/helm-chart/helm-chart-test-0.1.0.tgz">https://mattiaperi.github.io/helm-chart/helm-chart-test-0.1.0.tgz</a><br>    version: 0.1.0<br>generated: 2019-04-16T11:10:08.729368+02:00</pre><p><strong>Push the git repository on GitHub</strong></p><pre>$ git add . &amp;&amp; git commit -m “Initial commit” &amp;&amp; git push origin master</pre><p><strong>Configure the “helm-chart” repository as a Github pages site</strong></p><p>Now it’s time to publish the contents of our git repository as Github pages. Go back to your browser, in the “settings” section of your git repository, scroll down to Github Pages section and configure it as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fTMgrSI6LY8RniiO-vzxag.png" /></figure><p><strong>Configure helm client</strong></p><p>In order to share your brand new repository, everyone interested in your charts need to configure their own Helm client. Also on client side, repositories are managed with the $ helm repo commands:</p><pre>$ helm repo add myhelmrepo <a href="https://mattiaperi.github.io/helm-chart/">https://mattiaperi.github.io/helm-chart/</a><br>“myhelmrepo” has been added to your repositories</pre><p><strong>Test the Helm chart repository</strong></p><pre>$ helm search test<br>NAME CHART VERSION APP VERSION DESCRIPTION<br>[…]<br>myhelmrepo/helm-chart-test 0.1.0 1.0 A Helm chart for Kubernetes<br>[…]</pre><p><strong>Add new charts to an existing repository</strong></p><p>Whenever you need to add a new chart to the Helm chart repository, it’s mandatory for you to regenerate the index.yaml file. The $ helm repo index command will completely rebuild the index.yaml file from scratch, including only the charts that it finds locally, which very likely is our case. However, it worth notice that you can use the --merge flag to incrementally add new charts to an existing index.yaml:</p><pre>$ helm repo index --url <a href="https://mattiaperi.github.io/helm-chart/">https://mattiaperi.github.io/helm-chart/</a> --merge index.yaml .</pre><p>Hope you find these information useful, any feedback or advice for improvements are very well accepted. Let me know if you enjoyed this article by hitting the applause button or leaving a comment below, it would mean a lot.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49b180dbb417" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ACM: AWS Certificate Manager]]></title>
            <link>https://medium.com/@mattiaperi/acm-aws-certificate-manager-17cec940929?source=rss-9b569e4045a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/17cec940929</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ssl]]></category>
            <dc:creator><![CDATA[Mattia Peri]]></dc:creator>
            <pubDate>Wed, 08 Aug 2018 15:49:54 GMT</pubDate>
            <atom:updated>2019-04-16T10:29:38.189Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi there, I’d like to share my experience with the <a href="https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html">ACM service by AWS</a> along with some Terraform code to implement it in your VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*hPzQ6VOjYXihgr4x5DdKGg.jpeg" /></figure><h3>First things first: What is AWS Certificate Manager?</h3><p>ACM is AWS answer to SSL/TLS certifications manager. ACM helps you with the process of provisioning, validating, and configuring Transport Layer Security (TLS) certificates. You probably already know <a href="https://letsencrypt.org/">Let’s Encrypt</a> service, right? Very likely, you are going to use it in the same way, that is, handling your web applications HTTPS connections thanks to <a href="https://www.amazontrust.com/">Amazon controlling the CA </a>(Certification Authority) behind the certificates provided.</p><p>Much like Let’s Encrypt, ACM allows you to:<br>1. secure multiple domain names and multiple names within a domain<br>2. create wildcard SSL certificates that can protect an unlimited number of subdomains.<br>3. it’s free: nothing is going to be charged for ACM service.</p><p>There are some differences, though:</p><ol><li>Given that ACM is an AWS service, you cannot install public ACM certificates directly on your website or application. You must install your certificate by using one of the services integrated with ACM, i.e.:<br>- Elastic Load Balancing<br>- Amazon CloudFront<br>- Amazon API Gateway<br>In other words: you can’t install ACM certificates in an EC2 node.</li><li>ACM certificates last 1 year vs 3 months of Let’s Encrypt</li></ol><h3>How to deploy ACM with Terraform</h3><p>Let’s see how we can create and deploy a certificate managed by ACM with Terraform and install it on an ALB (Application Load Balancer). Terraform side, we need 3 kind of resources in order to set-up an ACM certificate:</p><ul><li><strong>aws_acm_certificate:</strong> terraform resource for requesting and managing ACM certificates.</li></ul><pre>resource &quot;aws_acm_certificate&quot; &quot;acm_certificate&quot; {<br>  domain_name               = &quot;example.com&quot;<br>  validation_method         = &quot;DNS&quot;</pre><pre>tags {<br>    Environment = &quot;prd&quot;<br>  }</pre><pre>lifecycle {<br>    create_before_destroy = true<br>  }<br>}</pre><ul><li><strong>aws_route53_record:</strong> create a DNS record to validate the certificate request</li></ul><pre>resource &quot;aws_route53_record&quot; &quot;validation_route53_record&quot; {</pre><pre>name    = &quot;${aws_acm_certificate.acm_certificate.domain_validation_options.0.resource_record_name&quot;)}&quot;<br>  type    = &quot;${aws_acm_certificate.acm_certificate.domain_validation_options.0.resource_record_type&quot;)}&quot;<br>  zone_id = &quot;${aws_route53_zone.examplecom.zone_id}&quot;<br>  records = [&quot;${aws_acm_certificate.acm_certificate.domain_validation_options.0.resource_record_value&quot;)}&quot;]<br>  ttl     = &quot;60&quot;<br>}</pre><ul><li><strong>acm_certificate_validation: </strong>provides a mechanism to wait for an aws_acm_certificate resource to be validated before it can be used in your Terraform configuration.</li></ul><pre>resource “aws_acm_certificate_validation” “acm_certificate_validation” {<br> certificate_arn = “${aws_acm_certificate.acm_certificate.arn}”</pre><pre>validation_record_fqdns = [<br> “${aws_route53_record.validation_route53_record.*.fqdn}”,<br> ]<br>}</pre><p>Last but not least, in case you’d like to associate the certificate created to an ALB (Application Load Balancer), you just need to create (or edit) the listener on port 443 as described hereunder:</p><pre>resource “aws_alb_listener” “frontend443_alb_listener” {<br> load_balancer_arn = “${aws_alb.vpc01_alb.id}”<br> port = “443”<br> protocol = “HTTPS”<br> ssl_policy = “ELBSecurityPolicy-2016–08”<br> certificate_arn = “${aws_acm_certificate.acm_certificate.arn}”</pre><pre>default_action {<br> target_group_arn = “${aws_alb_target_group.vpc01_docker_app.id}”<br> type = “forward”<br> }<br>}</pre><p>Please be aware that in my case:</p><ul><li>ALB resource name is: “vpc01_alb”, edit accordingly</li><li>“targer_group” resource name is: “vpc01_docker_app”, edit accordingly</li></ul><p>It is worth to mention that with an ALB you are able to manage more than one certificate, for example you might want to handle more DNS domains with a single ALB. In the example above, with the parameter “certificate_arn” we set-up the default certificate for requests that do not match the domains of any certificates in your certificate list. If you need to deep dive, please have a look to the resource <a href="https://www.terraform.io/docs/providers/aws/r/lb_listener_certificate.html">“aws_alb_listener_certificate”</a>.</p><p>Hope you find these information useful, any feedback or advice for improvements are very well accepted. Let me know if you enjoyed this article by hitting the applause button or leaving a comment below, it would mean a lot.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17cec940929" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>