<?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 Quassain Raza on Medium]]></title>
        <description><![CDATA[Stories by Quassain Raza on Medium]]></description>
        <link>https://medium.com/@i181568?source=rss-737b78fe1e9b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gLtwDrkVPuj0h5nL</url>
            <title>Stories by Quassain Raza on Medium</title>
            <link>https://medium.com/@i181568?source=rss-737b78fe1e9b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:56:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@i181568/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[Kuma, Best Choice of all Service Meshes?]]></title>
            <link>https://medium.com/@i181568/kuma-best-choice-of-all-service-meshes-68f398c95c56?source=rss-737b78fe1e9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/68f398c95c56</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kuma]]></category>
            <category><![CDATA[kubectl]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[service-mesh]]></category>
            <dc:creator><![CDATA[Quassain Raza]]></dc:creator>
            <pubDate>Wed, 30 Nov 2022 22:16:05 GMT</pubDate>
            <atom:updated>2022-11-30T22:16:05.716Z</atom:updated>
            <content:encoded><![CDATA[<h3>Problems in Distributed Architectures?</h3><p>The application agility and scalability drives the increase to modernize the developer productivity, meanwhile many organizations are opting for an distributed micro-service architecture for both novel and old applications and services. Monolithic applications are hard and complex to build and release.In a monolithic application, all function-to-function calls are secure inside the monolith. Consider how microservices authenticate, authorize, encrypt, and communicate. Also consider the additional auditing tools needed to trace service-to-service communication. The matter of fact it causes much of the problems like:</p><p>1-<strong>Network resiliency</strong>:</p><p>In distributed architectures, consider the effect of latency and the overall response time when multiple services communicate to produce a response. Also consider fault tolerance. How does a distributed architecture ensure that a service in one downstream service does not cause cascading failure in other services?</p><p>2-<strong>Communication policy</strong>:</p><p>In distributed architectures, some services can become bottlenecks or dependencies for other services. Network policies that manage quotas and rate limits for all services can ensure that a rogue service making too many calls does not overload the services it calls. To effectively control services, create policies that specify which services can and can’t make calls.</p><p><strong>3</strong>-<strong>Observability</strong>:</p><p>When compared with monolithic applications, observability is more important in microservice-based architectures. In monolithic applications, log files are sufficient to identify the source of an issue. In a microservices architecture, multiple services can span a single request. Latency, errors, and failures can happen in any service within the architecture. Developers need logging, network metrics, and distributed tracing and topology to investigate problems and pinpoint their location.</p><h3>What is Kuma?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0WBrs1XhpJ0BQ41Pf4hZQQ.png" /></figure><p>Kuma is an enterprise-grade service mesh that runs on both Kubernetes and VMs on any cloud. Built on top of Envoy and focused on simplicity, it enables microservices transformation with out-of-the-box service connectivity and discovery, zero-trust security, traffic reliability and global observability across all traffic including cross-cluster deployments. Kuma is more than production-ready and comes with features you would expect from a capable service mesh tool. It supports all backends that are compatible with OpenTracing and lets you use an external CA certificate if needed.</p><h4><strong>How it plays an essential part?</strong></h4><p>Kuma addresses limitations of first-generation <a href="https://konghq.com/products/kong-enterprise/kong-mesh">service mesh technologies</a> by enabling seamless management of any service on the network, including L4 and L7 traffic, as well as microservices and APIs. Its fast data plane and advanced control plane makes it significantly easier to use and adopt across every team. Kuma runs on any platform, including Kubernetes, virtual machines, containers, bare metal and legacy environments, to enable a more practical cloud native journey across an entire organization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*w91lF2CJ4rzKvC7QiLKkXw.png" /><figcaption>Multi-zone deployment for multiple Kubernetes clusters, or a hybrid Kubernetes/VM cluster</figcaption></figure><p>When building any modern digital application, we will inevitably introduce services that will communicate with each other by making requests on the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9qNwP_xMs3TtDRRqwieJ9g.png" /></figure><p>For example, think of any application that communicates with a database to store or retrieve data, or think of a more complex microservice-oriented application that makes many requests across different services to execute its operations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*uc95bXuarp6-Z5XdgobRMA.jpeg" /></figure><p>Kuma exists today to provide a pragmatic journey to implementing Service Mesh for the entire organization and for every team: for those running on modern Kubernetes environments and for those running on more traditional platforms like Virtual Machines and Bare Metal.</p><ul><li><strong>Universal and Kubernetes-Native</strong>: Platform-agnostic, can run and operate anywhere on both Kubernetes and VMs.</li><li><strong>Single and Multi-Zone</strong>: To support multiple clouds, regions and Kubernetes clusters with out of the box multi-zone connectivity thanks to the native service discovery and ingress capability.</li><li><strong>Multi-Mesh</strong>: To support multiple individual meshes with one control plane, lowering the operational costs of supporting the entire organization.</li><li><strong>Attribute-Based policies</strong>: To apply fine grained service and traffic policies using any arbitrary tag selector for sources and destinations.</li><li><strong>Envoy-Based</strong>: Powered by Envoy sidecar proxies, without exposing the complexity of Envoy itself.</li><li><strong>Easy to use</strong>: No moving parts. One click policy installation. Horizontally scalable.</li><li><strong>Enterprise-Ready</strong>: Used by mission critical enterprise use-cases that require uptime and stability.</li></ul><p>Kuma can run on many cloud distribution including K8s, Helm-charts,Open-shift,Docker,Amazon Linux, Ubuntu, macOS and many more. Preferably I used it on my <strong>Kubernetes</strong> cluster and here you can see all the commands to install and successfully run it..</p><p>To install and run Kuma you need to first download kuma through downloading Kumactl:</p><p>To run Kuma on Kubernetes, you need to download the Kuma cli (kumactl) on your machine.</p><p>You can run the following script to automatically detect the operating system and download Kuma:</p><pre>curl -L https://kuma.io/installer.sh | VERSION=2.0.0 sh -</pre><p>You can omit the VERSION variable to install the latest version.</p><p>Once downloaded, you will find the contents of Kuma in the kuma-2.0.0 folder. In this folder, you will find - among other files - the bin directory that stores the executables for Kuma, including the CLI client <a href="https://kuma.io/docs/2.0.x/explore/cli">kumactl</a>.</p><p>Note: On Kubernetes — of all the Kuma binaries in the bin folder - we only need kumactl.</p><p>So we enter the bin folder by executing: cd kuma-2.0.0/bin</p><p>We suggest adding the kumactl executable to your PATH (by executing: PATH=$(pwd):$PATH) so that it’s always available in every working directory. Or - alternatively - you can also create link in /usr/local/bin/ by executing:</p><pre>ln -s kuma-2.0.0/bin/kumactl /usr/local/bin/kumactl</pre><p>Finally, we can install and run Kuma:</p><pre>kumactl install control-plane | kubectl apply -f -</pre><p>This example will run Kuma in standalone mode for a “flat” deployment, but there are more advanced dev modes like “multi-zone”.</p><p>It may take a while for Kubernetes to start the Kuma resources, you can check the status by executing:</p><pre>kubectl get pod -n kuma-system</pre><p>Kuma (<em>kuma-cp</em>) will be installed in the newly created kuma-system namespace! Now that Kuma has been installed.</p><p>You can use Kuma with <strong>kubectl</strong> to perform read and write operations on Kuma resources. For example:</p><pre>kubectl get meshes<br># NAME          AGE<br># default       1m</pre><p>or you can enable mTLS on the default Mesh with:</p><pre>echo &quot;apiVersion: kuma.io/v1alpha1<br>kind: Mesh<br>metadata:<br>  name: default<br>spec:<br>  mtls:<br>    enabledBackend: ca-1<br>    backends:<br>    - name: ca-1<br>      type: builtin&quot; | kubectl apply -f -</pre><p>You will notice that Kuma automatically creates a Service Mesh entity with name “default”.</p><h3><strong>Conclusion:</strong></h3><p>Apparently many service meshes are used to improve the microservice architectures and Kuma continues to be Platform-agnostic, can run and operate anywhere, apart from that there has been some major improvements in Kuma, for that please reach out to this excellent <a href="https://kuma.io/blog/2022/kuma-2-0-0/"><strong>blog</strong></a><strong>.</strong></p><h4><strong>And you can find:</strong></h4><h4>Their official website at:</h4><p><a href="http://kuma.io/">kuma.io</a></p><h4>Their Github Repo at:</h4><p><a href="https://github.com/kumahq/kuma">Github repo</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68f398c95c56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All about K3s and K3sup]]></title>
            <link>https://medium.com/@i181568/all-about-k3s-and-k3sup-20dbda252732?source=rss-737b78fe1e9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/20dbda252732</guid>
            <dc:creator><![CDATA[Quassain Raza]]></dc:creator>
            <pubDate>Mon, 24 Oct 2022 21:37:50 GMT</pubDate>
            <atom:updated>2022-10-24T21:37:50.178Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*j1azgitRNFCzJVYSfxsXyw.png" /></figure><h3>What is K3s?</h3><p>K3s is another lightweight kubernetes distribution that is used for different purposes than other distributions like K8s or local kubernetes clusters like minikube,microkits etc. It is basically used for deployment purposes. For example you might want to install an application like containers application in resource constraint environment, think about IOT devices or Raspberry Pi or anything that has resource constraint so you just can’t pay more for your cloud provider or maybe use your entire machine space its definitely quite resource constraint. K3s had been developed by Rancher Labs, they originally wanted to develop something called “Rio”. However, they then decided to branch it out of Rio into its own tool — which became K3s. It was more of a figure it out by doing it. The important aspect of k3s is that it was oriented around production right from the beginning. You want to be able to run Kubernetes in highly resource constraint environments , which is not always possible with pure Kubernetes. K3s is currently a CNCF sandbox project ,the development is led by Rancher, which provides Kubernetes as a service.</p><h3>How it works?</h3><p>It uses Containerd instead of Docker and now Kubernetes is also shifting to containerd but that doesnot mean that you can’t use Docker. K3s includes only core Kubernetes components, such as kube-apiserver, kube-scheduler, kubelet, kube-controller-manager, and kube-proxy. Using only core components keeps the distribution lightweight, but you can easily replace components with external add-ons. It bundles these components into unified processes presented as a simple server and agent model. Once you run the k3s server, it starts the Kubernetes server and automatically registers the localhost as an agent to create a one-node Kubernetes cluster.</p><p>A server node is a bare-metal or virtual machine that runs the k3s server command, and a worker node is a machine that runs the k3s agent command. There are various ways you can use the K3s for your applications. Here is a diagram visualizing a cluster using a single-node K3s server with an embedded SQLite database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BQxmY7uOPIYqSx2hvzgzfw.png" /><figcaption>Image source:<a href="https://rancher.com/docs/img/rancher/k3s-architecture-single-server.png"> Rancher</a></figcaption></figure><p>This configuration registers every agent node to constant server node. It lets a K3s user decision the K3s API on the server node to govern Kubernetes resources.</p><p>You will put together single server clusters to satisfy for varied use cases. However, environments that need period of the Kubernetes control plane ought to run K3s in an angular distance configuration. AN HA K3s cluster consists of two or a lot of server nodes that serve the Kubernetes API and run alternative control plane services and an external datastore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c174iloyRDO8Jp6s8f8ZHA.png" /><figcaption>Image source: <a href="https://rancher.com/docs/img/rancher/k3s-architecture-ha-server.png">Rancher</a></figcaption></figure><blockquote>Hoping to K3sup…</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*gZ-84_0ifs3bL6EhEzBa6w.png" /></figure><h3>What is K3sup?</h3><blockquote>K3sup is a K3s installer that works over SSH, and at the end of the installation merges the cluster’s configuration file into your local one, so that you can use kubectl remotely. The idea with Kubernetes is that all of your nodes - whether masters or workers, should be left well alone, and rarely logged into for any kind of administrative activity. Raspberry Pi can also be replaced by those two nodes.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRJ91UD8LMrCd1FD0XtmzA.png" /></figure><p><em>K3sup can install K3s to a single machine, or be used to form a cluster — all over SSH.</em></p><h3><strong>Installing K3sup</strong></h3><p>K3sup is distributed as a static Go binary. You can use the installer on MacOS and Linux, or visit the <a href="https://github.com/alexellis/k3sup/releases">Releases page</a> to download the executable for Windows.</p><p>You’ll find these detailed install instructions in <a href="https://github.com/alexellis/k3sup">the k3sup README-file</a> too.</p><pre>$ curl -sLS https://get.k3sup.dev | sh<br>$ sudo install k3sup /usr/local/bin/</pre><pre>$ k3sup --help</pre><p><em>A note for Windows users: you can use </em><em>k3sup install and </em><em>k3sup join with the normal “Windows command prompt”.</em></p><h3>Setting K3s on K3sup</h3><p>You can setup a server and stop here, or go on to use the join command to add some “agents” aka nodes or workers into the cluster to expand its compute capacity.</p><p>Provision a new VM running a compatible operating system such as Ubuntu, Debian, Raspbian, or something else. Make sure that you <strong>opt-in</strong> to copy your registered SSH keys over to the new VM or host automatically.</p><p><strong>Note:</strong> You can copy ssh keys to a remote VM with ssh-copy-id user@IP.</p><p>Imagine the IP was 192.168.0.1 and the username was ubuntu, then you would run this:</p><p>Run k3sup:</p><pre>$ export IP<strong>=</strong>192.168.0.1<br>$ k3sup install --ip $IP --user ubuntu</pre><p>Now try the access:</p><pre>$ export KUBECONFIG<strong>=</strong>`pwd`/kubeconfig<br>$ kubectl get node</pre><h3>Join some agents to your Kubernetes server</h3><p>Let’s say that you have a server, and have already run the following:</p><pre>$ export SERVER_IP<strong>=</strong>192.168.0.100<br>$ export USER<strong>=</strong>root</pre><pre>$ k3sup install --ip $SERVER_IP --user $USER</pre><p>Next, join one or more agents to the cluster:</p><pre>$ export AGENT_IP<strong>=</strong>192.168.0.101</pre><pre>$ export SERVER_IP<strong>=</strong>192.168.0.100<br>$ export USER<strong>=</strong>root</pre><pre>$ k3sup join --ip $AGENT_IP --server-ip $SERVER_IP --user $USER</pre><p>That’s all, so with the above command you can have a two-node cluster up and running, whether that’s using VMs on-premises, using Raspberry Pis, 64-bit ARM or even cloud VMs on EC2.</p><h3>Create a multi-master (HA) setup</h3><p>As of k3s 1.0, a HA multi-master configuration is available through sqlite. A quorum of masters will be required, which means having at least three nodes.</p><h4>Initialize the cluster with the first server</h4><p>Note the --cluster flag:</p><pre>$ export SERVER_IP<strong>=</strong>192.168.0.100<br>$ export USER<strong>=</strong>root</pre><pre>$ k3sup install \<br>    --ip $SERVER_IP \<br>    --user $USER \<br>    --cluster</pre><h4>Join each additional server</h4><p>Note the new --server flag:</p><pre>$ export USER<strong>=</strong>root<br>$ export SERVER_IP<strong>=</strong>192.168.0.100<br>$ export NEXT_SERVER_IP<strong>=</strong>192.168.0.101</pre><pre>$ k3sup join \<br>    --ip $NEXT_SERVER_IP \<br>    --user $USER \<br>    --server-user $USER \<br>    --server-ip $SERVER_IP \<br>    --server</pre><p>Now check kubectl get node:</p><pre>$ kubectl get node<br>NAME              STATUS   ROLES    AGE     VERSION<br>paprika-gregory   Ready    master   8m27s   v1.16.3-k3s.2<br>cave-sensor       Ready    master   27m     v1.16.3-k3s.2</pre><h3>Micro-tutorial for Raspberry Pi (2, 3, or 4)</h3><p>In a few moments you will have Kubernetes up and running on your Raspberry Pi 2, 3 or 4. Stand by for the fastest possible install. At the end, you will have a KUBECONFIG file on your local computer that you can use to access your cluster remotely.</p><h3>Common issues</h3><p>The most common problem is that you missed a step, fortunately it’s relatively easy to get the logs from the K3s service and it should tell you what’s wrong.</p><ul><li>For the Raspberry Pi you probably haven’t updated cmdline.txt to enable cgroups for CPU and memory. Update it as per the instructions in this file.</li><li>You ran kubectl on a node. Don&#39;t do this. k3sup copies the file to your local workstation. Don&#39;t log into agents or servers other than to check logs / upgrade the system.</li><li>sudo: a terminal is required to read the password - setup password-less sudo on your hosts, see also:<a href="https://github.com/alexellis/k3sup#pre-requisites-for-k3sup-servers-and-agents">Pre-requisites for k3sup agents and servers</a></li><li>You want to install directly on a server, without using SSH. See also: k3sup install --local which doesn&#39;t use SSH, but executes the commands directly on a host.</li><li>K3s server didn’t start. Log in and run sudo systemctl status k3s or sudo journalctl -u k3s to see the logs for the service.</li><li>The K3s agent didn’t start. Log in and run sudo systemctl status k3s-agent</li><li>You tried to remove and re-add a server in an etcd cluster and it failed. This is a known issue, see the <a href="https://github.com/k3s-io/k3s/issues">K3s issue tracker</a>.</li><li>You tried to use an unsupported version of a database for HA. See <a href="https://rancher.com/docs/k3s/latest/en/installation/datastore/">this list from Rancher</a></li><li>Your tried to join a node to the cluster and got an error “ssh: handshake failed”. This is probably one of three possibilities:</li><li>You did not run ssh-copy-id. Try to run it and check if you can log in to the server and the new node without a password prompt using regular ssh.</li><li>You have an RSA public key. There is an <a href="https://github.com/golang/go/issues/39885">underlying issue in a Go library</a> which is <a href="https://github.com/alexellis/k3sup/issues/63">referred here</a>. Please provide the additional parameter --ssh-key ~/.ssh/id_rsa (or wherever your private key lives) until the issue is resolved.</li><li>You are using different usernames for SSH’ing to the server and the node to be added. In that case, playe provide the username for the server via the --server-user parameter.</li><li>Your .ssh/config file isn&#39;t being used by K3sup. K3sup does not use the config file used by the ssh command-line, but instead uses CLI flags, run k3sup install/join --help to learn which are supported.</li></ul><h3>Contributing</h3><blockquote><strong>Blog posts &amp; tweets</strong></blockquote><blockquote>Blogs posts, tutorials, and Tweets about k3sup (#k3sup) are appreciated. Please send a PR to the README.md file to add yours.</blockquote><blockquote><strong>Contributing via GitHub</strong></blockquote><blockquote>Before contributing code, please see the <a href="https://github.com/alexellis/arkade/blob/master/CONTRIBUTING.md">CONTRIBUTING guide</a>. Note that k3sup uses the same guide <a href="https://arkade.dev/">arkade</a></blockquote><blockquote>Both Issues and PRs have their own templates. Please fill out the whole template.</blockquote><blockquote>All commits must be signed-off as part of the <a href="https://developercertificate.org/">Developer Certificate of Origin (DCO)</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20dbda252732" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DOCKER BUILDKIT-BUILDX]]></title>
            <link>https://medium.com/@i181568/docker-buildx-b5174e6eb21c?source=rss-737b78fe1e9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5174e6eb21c</guid>
            <dc:creator><![CDATA[Quassain Raza]]></dc:creator>
            <pubDate>Sat, 10 Sep 2022 15:20:56 GMT</pubDate>
            <atom:updated>2022-09-17T20:44:42.538Z</atom:updated>
            <content:encoded><![CDATA[<p>Docker builds images by reading the instructions from a Dockerfile. If you are not familiar with Dockerfile then please have a read on this <a href="https://www.simplilearn.com/tutorials/docker-tutorial/what-is-dockerfile">link</a>.</p><p>Docker images consist of <strong>read-only layers</strong>, each resulting from an instruction in the Dockerfile. Layers are stacked sequentially and each one is a delta representing the changes applied to the previous layer.</p><h3><strong>What is docker buildX?</strong></h3><blockquote>It is a CLI plugin that extends the docker command with the full support of the features provided by <a href="https://github.com/moby/buildkit">Moby Build Kit</a> builder toolkit. It provides the same user experience as docker build with many new features like creating scoped builder instances and building against multiple nodes concurrently. Furthermore, it also provides us with the same user experience as building with the <strong>docker build</strong> command.</blockquote><h3><strong>Why BuildX is necessary when we can build with Docker Build?</strong></h3><p>BuildX comes with new extra features like it allows us to build an image for the native architecture, similar to a docker build but it also supports and allows for <em>emulation</em>.</p><p>Here, <strong>emulation</strong> means that from a specific machine (for example, say Intel machine) we can build an image targeted for a different architecture-supported machine (for example, a raspberry pi machine). For some more information on emulation, have a look on <a href="https://blog.davetcode.co.uk/post/21st-century-emulator/">here</a>.</p><p>Along with some new additions to it, such as constructing simultaneously against many nodes with various arch images, builder instances, etc. Additionally, buildx enables brand-new features like creating manifest lists and distributed caching that are not currently supported by standard Docker builds.</p><h3>Play with Docker Builder Objects..</h3><p>By default, Buildx uses the “docker” driver if it is supported, providing a user experience very similar to the native docker build. Note that you must use a local shared daemon to build your applications.</p><p>Buildx allows you to create new instances of isolated builders. You can use this to get a scoped environment for your CI builds that does not change the state of the shared daemon, or for isolating builds for different projects. You can create a new instance for a set of remote nodes, forming a build farm, and quickly switch between them.</p><p>You can create new instances using the <strong>docker buildx create</strong> command. This creates a new builder instance with a single node based on your current configuration. To check all available builders you can use<strong> ls</strong> command. You can also switch between different builders by using this command <strong>docker buildx use &lt;name&gt;</strong>.After running this command, the build commands will automatically use this builder.</p><h3>Now use BuildX to build Multi-platform Images!</h3><p>We can build multi-platform images using <strong><em>three different strategies</em></strong> that are supported by Buildx and Dockerfiles:</p><ol><li><em>Using the QEMU emulation support in the kernel</em>.<br>In particular, this approach is considered to be the most suitable approach when one is working on a Docker Desktop ( usually Mac or Windows ). QEMU is the easiest way to get started if your node already supports it (for example. if you are using Docker Desktop). It requires no changes to your Dockerfile and BuildKit automatically detects the secondary architectures that are available.</li><li><em>Building on multiple native nodes using the same builder instance</em>.<br>This approach is suitable for covering all the use-cases that are not handled efficiently by the QEMU approach, and as a result, we achieve better performance.</li><li><em>Using a stage in Dockerfile to cross-compile to different architectures</em>.<br>In this case, <strong><em>multi-stage builds</em></strong> in Dockerfiles can be effectively used to build binaries for the platform specified<strong> — platform</strong> using the native architecture of the build node.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*XrvKHOvon9nlQJvh62-sFw.png" /><figcaption>A list of build arguments like <strong>BUILDPLATFORM </strong>and <strong>TARGETPLATFORM</strong> is available automatically inside your Dockerfile.</figcaption></figure><p>If you want to build images on multi platform, follow the detailed and very clear steps given <a href="https://medium.com/@jamieeduncan/easily-making-container-images-for-multiple-platforms-6fbf097c9742">here</a>.</p><h3>Creating a Buildx Builder</h3><p>The docker CLI now understands the buildx command, but you also need to create a new builder object which buildx can use:</p><pre>$ <strong>docker buildx create --name myImagebuilder</strong><br>myImagebuilder<br>$ <strong>docker buildx use myImagebuilder</strong></pre><p>You can check your newly created <strong><em>myImagebuilder</em></strong> with:</p><pre>$ <strong>docker buildx inspect --bootstrap</strong><br>[+] Building 3.5s (1/1) FINISHED<br> =&gt; [internal] booting buildkit                                3.8s<br> =&gt; =&gt; pulling image moby/buildkit:buildx-stable-1             2.8s<br> =&gt; =&gt; creating container buildx_buildkit_myImagebuilder0           0.8s<br>Name:   myImagebuilder<br>Driver: docker-container</pre><pre>Nodes:<br>Name:      myImagebuilder0<br>Endpoint:  unix:///var/run/docker.sock<br>Status:    running<br>Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le,<br>linux/s390x, linux/386, linux/arm/v7, linux/arm/v6</pre><p>Note how the <em>Platforms</em> line reports support for various non-native architectures which you have installed via QEMU. If it only reports support for <em>linux/amd64</em> and <em>linux/386</em> you either still haven’t met all software requirements, or you had created a builder before you have met the software requirements. In the latter case remove it with <strong>docker buildx rm</strong> and recreate it.</p><p>You can also see your just created <em>myImagebuilder</em> with <strong>buildx’ <em>ls</em></strong> subcommand:</p><pre>$ <strong>docker buildx ls</strong><br>NAME/NODE    DRIVER/ENDPOINT             STATUS  PLATFORMS<br>myImagebuilder *  docker-container<br>  myImagebuilder0 unix:///var/run/docker.sock running linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6<br>default      docker<br>  default    default                     running linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6</pre><h3>Buildx will Build your images..</h3><p>Alright, now we’re ready to build multi-architecture docker images with buildx. To have something concrete to work with we’re going to use the following example Dockerfile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*2KNULVIVTPrgao5g8EiSyA.png" /></figure><p>It’s a simple stand-in for whatever you’d like to build yourself in your own Dockerfile. It uses the latest <em>Alpine</em> distribution which itself is a multi-architecture docker image and it prints out the architecture on which it is executing. That will allow us to check which kind of image we’re running.</p><p>The <strong>docker buildx build </strong>subcommand has a number of flags which determine where the final image will be stored. By default, i.e. if none of the flags are specified, the resulting image will remain captive in docker’s internal build cache. This is unlike the regular <strong>docker build</strong> command which stores the resulting image in the local <strong>docker images </strong>list. The important flags are:</p><ul><li><strong>— load</strong>: This flag instructs docker to load the resulting image into the local <strong>docker images</strong> list. However, this currently only works for single-architecture images. If you try this with multi-architecture images you’ll get an export error:</li></ul><pre>$ <strong>docker buildx build … --load …</strong><br>…<br> <em>=&gt; ERROR exporting to oci image format 0.0s<br> — — — <br> &gt; exporting to oci image format:<br> — — — <br>failed to solve: rpc error: code = Unknown desc = docker<br> exporter does not currently support exporting manifest lists</em></pre><ul><li><strong>— push</strong> : This flag tells docker to push the resulting image to a docker registry. Your image tag has to contain the proper reference to the registry and repository name. This currently is the best way to store multi-architecture images.</li></ul><p>We’re going to use the default Docker Hub registry. First we have to log in:</p><pre>$ <strong>export DOCKER_USER=’quassainraza’</strong><br>$ <strong>docker login -u “$DOCKER_USER”</strong><br>Password: *****<br>WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.<br>Configure a credential helper to remove this warning. See<br>https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded</pre><p>Now we can build and use the<strong> — push</strong> flag to push the image to Docker Hub. In our example we’re going to build for three different architectures — x86, ARM, and PowerPC — which are specified with the<strong> — platform </strong>flag:</p><pre>$ <strong>docker buildx build -t “${DOCKER_USER}/buildx-test:latest” \<br>  --platform linux/amd64,linux/arm64,linux/ppc64le --push .</strong>[+] Building 1.5s (9/9) FINISHED<br> =&gt; [internal] load build definition from Dockerfile            0.0s<br> =&gt; =&gt; transferring dockerfile: 91B                             0.0s<br> =&gt; [internal] load .dockerignore                               0.0s<br> =&gt; =&gt; transferring context: 2B                                 0.0s<br> =&gt; [linux/ppc64le internal] load metadata for docker.io/libra  0.1s<br> =&gt; [linux/amd64 internal] load metadata for docker.io/library  0.2s<br> =&gt; [linux/arm64 internal] load metadata for docker.io/library  0.2s<br> =&gt; CACHED [linux/ppc64le 1/1] FROM docker.io/library/alpine:l  0.0s<br> =&gt; =&gt; resolve docker.io/library/alpine:latest@sha256:21716586  0.0s<br> =&gt; CACHED [linux/amd64 1/1] FROM docker.io/library/alpine:lat  0.0s<br> =&gt; =&gt; resolve docker.io/library/alpine:latest@sha256:21716586  0.0s<br> =&gt; CACHED [linux/arm64 1/1] FROM docker.io/library/alpine:lat  0.0s<br> =&gt; =&gt; resolve docker.io/library/alpine:latest@sha256:21716586  0.0s<br> =&gt; exporting to image                                          1.2s<br> =&gt; =&gt; exporting layers                                         0.0s<br> =&gt; =&gt; exporting manifest sha256:cc57b693aba3acedeec2e624b55e5  0.0s<br> =&gt; =&gt; exporting config sha256:d90689831fec93dd68f90509031907c  0.0s<br> =&gt; =&gt; exporting manifest sha256:7997da18dbf6e4b2748736821ec6f  0.0s<br> =&gt; =&gt; exporting config sha256:c105b7a88a6002ad96802aa287be387  0.0s<br> =&gt; =&gt; exporting manifest sha256:6ed2267dc7082fbfc4454805b9432  0.0s<br> =&gt; =&gt; exporting config sha256:5df18a6f10cc8591839d1b29732d3d2  0.0s<br> =&gt; =&gt; exporting manifest list sha256:57ca2d778839da0b6287bcbc  0.0s<br> =&gt; =&gt; pushing layers                                           0.2s<br> =&gt; =&gt; pushing manifest for docker.io/quassainraza/buildx-tes   0.7s</pre><p>We can check the image with the <strong>imagetools </strong>subcommand which confirms that three architecture versions are included in the image:</p><pre>$ <strong>docker buildx imagetools inspect “$DOCKER_USER/buildx-test:latest”</strong><br>Name:      docker.io/quassainraza/buildx-test:latest<br>MediaType: application/vnd.docker.distribution.manifest.list.v2+json<br>Digest:    sha256:57ca2d778839da0b6287bcbc99fc2299b0cea29e5fe4cff8492a1ba6e62fc8c5</pre><pre>Manifests:<br>  Name:      docker.io/quassainraza/buildx-test:latest@sha256:cc57b693aba3acedeec2e624b55e543919173a3e9ed76c2af2f2cd9713b84b78<br>  MediaType: application/vnd.docker.distribution.manifest.v2+json<br>  Platform:  linux/amd64</pre><pre>  Name:      docker.io/quassainraza/buildx-test:latest@sha256:7997da18dbf6e4b2748736821ec6f1dd11d6e8493f068fb23913507a9a271e2c<br>  MediaType: application/vnd.docker.distribution.manifest.v2+json<br>  Platform:  linux/arm64</pre><pre>  Name:      docker.io/quassainraza/buildx-test:latest@sha256:6ed2267dc7082fbfc4454805b94326418ad14c530879a7c9d6f02f0961e2899c<br>  MediaType: application/vnd.docker.distribution.manifest.v2+json<br>  Platform:  linux/ppc64le</pre><p>To verify that you’ve actually got what you’ve been promised, let’s try to run the image:</p><pre>$ <strong>docker run --rm “$DOCKER_USER/buildx-test:latest”</strong><br>Unable to find image ‘quassainraza/buildx-test:latest’ locally<br>latest: Pulling from quassainraza/buildx-test<br>Digest: sha256:57ca2d778839da0b6287bcbc99fc2299b0cea29e5fe4cff8492a1ba6e62fc8c5<br>Status: Downloaded newer image for quassainraza/buildx-test:latest<br>Running on x86_64</pre><blockquote>As expected, since we’re running on a 64-bit x86 host, the default architecture version that was used by docker was the <em>amd64</em> which reports running on <em>x86_64</em>. If you check the local image in docker it confirms that:</blockquote><blockquote>$ <strong>docker inspect --format “{{.Architecture}}” “$DOCKER_USER/buildx-test:latest”</strong><br>amd64</blockquote><p>To pull and run a specific architecture version, use the image name including its full sha256 value that was reported by<strong> imagetools</strong>:</p><pre>$ <strong>docker run — rm “$DOCKER_USER/buildx-test:latest@sha256:6ed2267dc7082fbfc4454805b94326418ad14c530879a7c9d6f02f0961e2899c”</strong><br>Unable to find image ‘quassainraza/buildx-test:latest@sha256:6ed2267dc7082fbfc4454805b94326418ad14c530879a7c9d6f02f0961e2899c’ locally<br>sha256:6ed2267dc7082fbfc4454805b94326418ad14c530879a7c9d6f02f0961e2899c: Pulling from quassainraza/buildx-test<br>a5dee701e1e8: Pull complete <br>Digest: sha256:6ed2267dc7082fbfc4454805b94326418ad14c530879a7c9d6f02f0961e2899c<br>Status: Downloaded newer image for quassainraza/buildx-test@sha256:6ed2267dc7082fbfc4454805b94326418ad14c530879a7c9d6f02f0961e2899c<br>Running on ppc64le</pre><p>Since the sha256 value we requested here was that of the PowerPC image version, we see that the image is reporting to run on <em>ppc64le</em> as expected.</p><p>Optionally, we can pull and run non-native image versions by platform name. For that though we need to turn on another experimental feature, this time in the docker engine, that’ll allow us to specify a --platform. If docker engine experimental features are not turned on you’ll get an error instead:</p><pre><em>“–platform” is only supported on a Docker daemon with experimental features enabled</em></pre><p>Change the docker engine configuration file /etc/docker/daemon.json or create one if it doesn’t exist already:</p><pre>{<br>  …<br>  “experimental” : true<br>}</pre><p>After changing the configuration file you’ll also need to restart dockerd for the change to take effect:</p><pre>$ <strong>sudo systemctl restart docker</strong></pre><p>Let’s purge the image that we’ve already pulled and try a different architecture:</p><pre>$ <strong>docker rmi “$DOCKER_USER/buildx-test:latest”</strong><br>Untagged: quassainraza/buildx-test:latest<br>Untagged: quassainraza/buildx-test@sha256:57ca2d778839da0b6287bcbc99fc2299b0cea29e5fe4cff8492a1ba6e62fc8c5$ <strong>docker run --rm --platform linux/aarch64 “$DOCKER_USER/buildx-test:latest”</strong><br>Unable to find image ‘quassainraza/buildx-test:latest’ locally<br>latest: Pulling from quassainraza/buildx-test<br>cde5963f3b93: Pull complete <br>Digest: sha256:57ca2d778839da0b6287bcbc99fc2299b0cea29e5fe4cff8492a1ba6e62fc8c5<br>Status: Downloaded newer image for quassainraza/buildx-test:latest<br>Running on aarch64</pre><p>Now we see that the architecture version of the image we’ve pulled and run is the one for 64-bit ARM <em>aarch64</em>, as can also be verified by looking at the image metadata:</p><pre>$ <strong>docker inspect --format “{{.Architecture}}” “$DOCKER_USER/buildx-test:latest”</strong><br>arm64</pre><p>With this you’ve got to the point where you can start to build your own multi-architecture docker images with buildx.</p><h3>To Install BuildX as your default builder</h3><p>To set buildX as your default builder run the command <strong>docker buildx install</strong> and it sets up docker builder command as an alias to <strong>docker buildx</strong> . This results in the ability to have<strong> docker build</strong> use the current buildx builder.</p><p>To remove this alias, run <strong>docker buildx uninstall</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5174e6eb21c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>