Kubernetes cluster provisioning in lxc
Kubernetes:
Kubernetes is a portable, extensible open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.
Linux Containers
LXC is a userspace interface for the Linux kernel containment features. Through a powerful API and simple tools, it allows Linux users to easily create and manage system or application containers.
Features of LXC:
->Kernel namespaces
->Apparmor and SELinux profiles
->Seccomp policies
->Kernel capabilities
->Cgroups
LXC containers are often considered as something in the middle between a chroot and a full-fledged virtual machine. The goal of LXC is to create an environment as close as possible to a standard Linux installation but without the need for a separate kernel.
Why Kubernetes in LXC?
Kubernetes is a large tool in managing containers it requires more configuration and specifications. Linux containers are light weighted but they use the host machine kernel to work.
Due to this reason, the LXC containers are customizable according to Kubernetes required configuration.
LXC and LXD
LXD is an open-source container management extension for Linux Containers (LXC). ... LXD also supplies a system daemon that applications can use to access.
LXC and has a template distribution system to enable faster container creation and operation.
Objective
To provision a Kubernetes cluster on top of Linux containers (LXC)
Architecture
Installation
Step 1: Installing lxd in ubuntu
# apt-get install lxd
Step 2: Enable and start the lxd service
# systemctl enable lxd and systemctl start lxd
Step 3:Intializing
# lxd init
Press Enter for default setup and provide dir for storage backend (not important).
Step 4: Deploying a Centos/7 container
# lxc launch images:centos/7 mydemomachine
Step 5: View the list of containers
# lxc list
Provisioning k8s cluster
Step 1: For provisioning the k8s cluster the profile file should be configured. Copy the default profile
# lxc profile copy default k8s-profile
Step 2: Edit the k8s-profile
# lxc profile edit k8s-profile
Step 3: Create k8s master and worker node
(must have names master and worker while creating containers)
# lxc launch images:centos/7 kmaster –profile k8s-master
# lxc launch images:centos/7 kworker –profile k8s-master
Step 4: Download the shell script for the k8s cluster (for version 1.14)
#wget https://github.com/fazil422/mykubernetes/blob/master/Shell/boot.sh
Step 5: Provision k8s cluster
# cat boot.sh | lxc exec kmaster bash
# cat boot.sh | lxc exec kworker bash
Step 6: Log in to kmaster
# lxc exec kmaster bash
Step 7: Check Kubernetes cluster
# kubectl cluster-info
Step 8: Check for the nodes
# kubectl get nodes
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post