Closed zeigerpuppy closed 3 years ago
See https://github.com/kata-containers/documentation/blob/master/Limitations.md#docker-run-and-sysctl. But We are working on it
Thanks for the pointer, although I think this issue may be a little different, as it's necessary to set vm.max_map_count
on the host, not the guest container. In this case, the host would mean the KVM image, so a modification of /usr/share/kata-containers/kata-containers-image_clearlinux_1.6.0-rc1_agent_a2037c08531.img
should be able to accomplish the fix without having to hook into the docker sysctl
issues.
Out of interest, is there a simple way to loop mount and modify the .img file,? I have been struggling to mount it.
answering my own question regarding mounting the image:
cd /usr/share/kata-containers
mkdir mount
kpartx -av kata-containers-image_clearlinux_1.6.0-rc1_agent_a2037c08531.img
mount /dev/mapper/loop0p1 ./mount/
Or use losetup
as kata-collect-data.sh
does to read the image metadata:
I use losetup
- makes it much much easier.
I fixed this by modifying the kata-containers clearlinux image.
I added the following to the image in /usr/lib/sysctl.d/50-default.conf
:
# fix for elasticsearch
vm.max_map_count=262144
@zeigerpuppy - nice work :-)
Yeah, looks like docker sysctl only supports the namespaced sysctl's, and vm.*
is not one of them.
I don't believe we have any other method in place with Kata right now to have per-container 'Host VM' side modifications like this sysctl. Hmm, I wonder if any of the callback hooks are run at that level?
I can't think of a nice way to add a method either, or not one that won't potentially introduce a big security hole ;-)
Now, for pods at least, we do have the ability to have a 'kernel-per-pod', that is, specify which kernel is used for which pod (and use the default if none specified). I'm not sure if we also support per-pod-images (for the rootfs). If we don't, maybe that is a solution for the k8s side at least?
@zeigerpuppy In case you are using k8s, you can set the sysctll using a privileged init container to set the sysctl, your app containers could then run as non-privileged. Something like:
apiVersion: v1
kind: Pod
metadata:
name: busybox-kata
spec:
runtimeClassName: kata-qemu
securityContext:
sysctls:
- name: kernel.shm_rmid_forced
value: "0"
containers:
- name: first-test-container
image: debian
command:
- sleep
- "3000"
initContainers:
- name: init-mysys
securityContext:
privileged: true
image: busybox
command: ['sh', '-c', 'echo "64000" > /proc/sys/vm/max_map_count']
Using this pattern, you can then set non-namespaced sysctls for Kata, without affecting the host/other pods. I have started a document explaining this yesterday.
Description of problem
When starting an elasticsearch container using the image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.3`, it fails to start due to the error:
This setting is usually on the docker host and changed by setting something like:
and made permanent in
/etc/sysctl.conf
However, changing this setting on the kata-containers host does not have the desired effect (I presume because the change will need to occur on the kata KVM host for the container).
Expected result
It should be possible to set this variable in the kata config or have the default image have a larger value of
vm.max_map_count
. Then the elasticsearch instance would start without error.Actual result
container fails to start
Meta details
Running
kata-collect-data.sh
version1.3.1 (commit 258eae0)
at2019-03-08.13:23:31.638048064+1100
.Runtime is
/usr/bin/kata-runtime
.kata-env
Output of "
/usr/bin/kata-runtime kata-env
":Runtime config files
Runtime default config files
Runtime config file contents
Config file
/etc/kata-containers/configuration.toml
not found Output of "cat "/usr/share/defaults/kata-containers/configuration.toml"
":KSM throttler
version
Output of "
/usr/libexec/cc-ksm-throttler/cc-ksm-throttler --version
":Output of "
/usr/libexec/kata-ksm-throttler/kata-ksm-throttler --version
":systemd service
Image details
Initrd details
No initrd
Logfiles
Runtime logs
/usr/bin/kata-collect-data.sh: line 244: journalctl: command not found No recent runtime problems found in system journal.
Proxy logs
/usr/bin/kata-collect-data.sh: line 244: journalctl: command not found No recent proxy problems found in system journal.
Shim logs
/usr/bin/kata-collect-data.sh: line 244: journalctl: command not found No recent shim problems found in system journal.
Throttler logs
/usr/bin/kata-collect-data.sh: line 244: journalctl: command not found No recent throttler problems found in system journal.
Container manager details
Have
docker
Docker
Output of "
docker version
":Output of "
docker info
":Output of "
systemctl show docker
":No
kubectl
Packages
Have
dpkg
Output of "dpkg -l|egrep "(cc-oci-runtimecc-runtimerunv|kata-proxy|kata-runtime|kata-shim|kata-ksm-throttler|kata-containers-image|linux-container|qemu-)"
":Have
rpm
Output of "rpm -qa|egrep "(cc-oci-runtimecc-runtimerunv|kata-proxy|kata-runtime|kata-shim|kata-ksm-throttler|kata-containers-image|linux-container|qemu-)"
":