Errors while creating master in cluster of kubernetes in lxc container

1/10/2019

I'm setting up a kubernetes cluster using lxc container while I was configuring master node with kubeadm init it is showing the following error:-

kubeadm init --apiserver-advertise-address=10.102.126.160 --pod-network-cidr=192.168.0.0/16
[init] Using Kubernetes version: v1.13.1
[preflight] Running pre-flight checks
[preflight] The system verification failed. Printing the output from the verification:
KERNEL_VERSION: 4.15.0-43-generic
DOCKER_VERSION: 18.06.1-ce
DOCKER_GRAPH_DRIVER: overlay2
OS: Linux
CGROUPS_CPU: enabled
CGROUPS_CPUACCT: enabled
CGROUPS_CPUSET: enabled
CGROUPS_DEVICES: enabled
CGROUPS_FREEZER: enabled
CGROUPS_MEMORY: enabled
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
    [ERROR Swap]: running with swap on is not supported. Please disable swap
    [ERROR SystemVerification]: failed to parse kernel config: unable to load kernel module: "configs", output: "modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.15.0-43-generic/modules.dep.bin'\nmodprobe: FATAL: Module configs not found in directory /lib/modules/4.15.0-43-generic\n", err: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

Can anyone help me out to solve this issue.

-- T.V.Deekshith
kubernetes

2 Answers

5/17/2020

Yes, as @Prafull Ladha said already, you have to create lxc containers with some config:

  • Disable swap
  • Use overlay2 driver for docker
  • Run containers as privileged

You can see all this stuff in this lxc profile that you should pass when you create your containers.

lxc launch images:ubuntu/16.04 CONTAINER_NAME --profile PROFILE_NAME

But your big big problem is run the Kubelet into a lxc container. Kubelet logs will show something like that:

failed to start OOM watcher open /dev/kmsg: no such file or directory

If you get this error you should do a little hack because the /dev/kmsg character device is not created by default. You can create this device with following command:

mknod /dev/kmsg c 1 11

Maybe a kernel image update is needed. You can go through the whole process in this script for ubuntu 16.04

-- debiasej
Source: StackOverflow

1/10/2019

To run kubernetes inside lxc container you need to do some configuration first, like there is no kernel module in lxc container, so you need to use overlay driver for docker. Also, your swap is ON you need to disable it using swapoff -a. There are many of these configuration you need to do before installing kubernetes cluster using kubeadm.

Here is the very nice blog explaining step by step configuration in lxc container:

https://medium.com/@kvapss/run-kubernetes-in-lxc-container-f04aa94b6c9c

-- Prafull Ladha
Source: StackOverflow