Snaps package applications and their dependencies into a self-contained bundle. They are designed to be platform-agnostic, meaning they can run on various distributions without requiring modifications or manual dependency management. MicroK8s is a Kubernetes distribution packaged as a snap and so it includes the application (Kubernetes in this case) and all of its dependencies. MicroK8s is distributed through the Snap Store from tracks corresponding to the flavors/versions of K8s.
Building MicroK8s from source can be beneficial for two main reasons:
Custom Build Configuration:
One common reason for building MicroK8s from source is when you require a specific build configuration, such as a particular Kubernetes patch version or a custom feature. By building from source, you gain the flexibility to tailor MicroK8s according to your needs. For example, if you need a specific Kubernetes patch number that is not available in the MicroK8s binaries distributed through the Snap Store, building from source may be your only option. Building from source can also be particularly useful when you rely on specific bug fixes or feature enhancements that are not available in the official MicroK8s release.
Ownership of the Build Process:
Another reason to build MicroK8s from source is to have full control and ownership of the build and distribution process. When you build from source, you gain insight into the internals of MicroK8s and have the ability to modify the build pipeline or add additional customizations. By owning the build process, you can ensure the integrity of the resulting binaries and have the freedom to include any modifications or enhancements that suit your needs. This level of control can be important if you want to incorporate custom enhancements, optimize performance, or add custom features to MicroK8s.
The build process for snaps involves several steps. Every snap has a
snapcraft.yaml file that specifies the application’s metadata, dependencies, and build instructions. This file outlines the necessary steps to build and package the application. The build process is typically automated using the Snapcraft tool, which reads the
snapcraft.yaml file and orchestrates the build. When building a snap, Snapcraft fetches the required dependencies and libraries, either from the distribution’s package repositories or by downloading the source code and building them from scratch. Snapcraft also handles the installation of build tools, compilers, and other necessary components within a controlled build environment.
The list of software placed in the MicroK8s snap can be seen under the components folder in the project’s source tree. In the folder of each components you will find the following items:
repository: a file with the repository where the component can be found
version.sh: a script that prints the repository tag or commit within the repository to fetch during a build
build.sh: a script that when called builds the component at handles
patches: an optional folder with patches to be applied on the source right after it is checked out
Repositories of addons are git repositories that can be placed into the snap during build. The list of addon repositories distributed along with MicroK8s are found under the
Please, see the “How to build MicroK8s from source” guide for a concrete step-by-step example on how to build and install a customised MicroK8s snap.
- Building a snap, https://snapcraft.io/docs/snapcraft-overview
- The MicroK8s source, GitHub - canonical/microk8s: MicroK8s is a small, fast, single-package Kubernetes for datacenters and the edge.
- How to build MicroK8s from source, How to build MicroK8s from source