LinuxKit

LinuxKit offers a minimal, immutable Linux framework built on containers. To get a taste of what it can do, check out the simple introduction on LinuxKit's GitHub page. In this discussion, we'll be using LinuxKit to build a Kubernetes image and deploy a simple Kubernetes cluster.

This step-by-step guide operates in the Mac OS X environment. The components we'll use are:

  • Kubernetes v1.7.2

  • Etcd v3

  • Weave

  • Docker v17.06.0-ce

Preliminary Needs

Before we begin, we need to ensure that:

  • Docker has been installed and activated on the host system.

  • Git has been installed on the host.

  • The LinuxKit project has been downloaded on the host, we have built Moby and LinuxKit tools.

Here are the commands for creating Moby and LinuxKit:

Building a Kubernetes System Image

First, we need to create a Linux system that comes pre-packaged with Kubernetes. Luckily there's already an example provided by the authorities. The following steps will guide you through the building process:

Deploying a Kubernetes Cluster

Once the image is ready, we can use the following command to start the Master OS and fetch its IP address:

After it has started, open a new console to SSH into the Master and initialize it with kubeadm:

Once kubeadm is finished, you will see a Token. Please remember this Token information. Next, open another console and run the command to initiate the Node:

Note: To initialize nodes, follow the format ./boot.sh <n> [<join_args> ...].

Next, open two additional consoles to join the cluster:

After completing the above, go back to the Master node and run the following command to check the status of the nodes:

Deploying a Simple Nginx Service

Kubernetes lets you build applications and services directly using instructions, or design app deployment configurations using YAML and JSON files. Let's spin up a simple Nginx service:

After that, we will create a Service(svc) to provide external network access to the app:

Since our deployment isn't on physical machines but uses Docker namespace networking, we will need to use ubuntu-desktop-lxde-vnc to view the Nginx app:

After that, connect to HTML VNC via the browser at http://localhost:6080.

Finally, to shut down nodes just execute the following:

If you've followed these steps, congratulations! You've built and deployed your own Kubernetes cluster with LinuxKit!

最后更新于