Commit Graph

8 Commits

Author SHA1 Message Date
Phil Sphicas 918da6d055 Avoid rbd unmap failure; use HostToContainer mountPropagation
The divingbell pods use a hostPath volume for the root filesystem.
Because this mount includes /var/lib/kubelet, the pod holds a reference
to every volume mounted by every pod on the same host.

The most visible case where this causes a problem is the termination of
a pod that uses a ceph-backed PVCs. When kubelet tries to unmap the rbd
device, it is unable to do so, manifesting in the kubelet logs as:
    rbd: unmap failed: (16) Device or resource busy

This change sets the mountPropagation to HostToContainer for the rootfs
volume, so that the divingbell pods will not prevent kubelet from
releasing these devices.

https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

Change-Id: I6e91fb9b9d7cbe852c5e6dc8b7224d6085175590
2020-11-24 23:57:54 +00:00
Phil Sphicas 55ba4cb61c Allow node selector configuration per module
This change adds the ability to configure node selectors per module. The
default node selector is 'kubernetes.io/os=linux'. For example:

    labels:
      apt:
        node_selector_key=divingbell-apt
        node_selector_value=enabled

Will result in a node selector of 'divingbell-apt=enabled'.

Change-Id: I7150c5f998afa30dce22f505be4d0d164254214f
2020-10-03 01:30:56 +00:00
Prateek Dodda 30200a54d9 Implement Security Context for Divingbell
Change-Id: Ibc93ccac6d6015faff3491211f5f8cb752a0328f
2020-03-30 23:04:50 +00:00
KAVVA, JAGAN MOHAN REDDY (jk330k) 37594c8d16 Add Docker default AppArmor profile to divingbell
This adds default AppArmor profile to divingbell.

Also, update to gate script to install ethtool if it is not present.

Change-Id: I7abb13a533b596f4db5fe65fdae5eb7fc57ec00a
2020-02-13 14:43:44 -08:00
Roman Gorshunov 1504533fb1 Change DaemonSet apiVersion to apps/v1
DaemonSet apiVersion: extensions/v1beta1 is deprecated starting from
Kubernetes v1.8.0-alpha.3 [0].

DaemonSet uses apiVersion: apps/v1 starting from v1.9.0 [1].

We run Kubernetes v1.13.4 and up at the moment.

[0] -
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.8.md
[1] -
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.9.md

Change-Id: Ic286e208836cf17be09fa78ba4d0f45084ae47fb
2019-08-01 20:25:43 +00:00
Kumar, Nishant(nk613n) d5a65962fe Add release uuid annotation to POD spec
Change-Id: I6158af07b15dbc098ae4e67c949b00c293b30894
2019-07-24 14:50:25 +00:00
BARTRA, RICK 2c80c45fe8 Run Divingbell containers as unprivileged
Divingbell runs all its containers as privileged. Some Divingbell
containers can perform their jobs with the default set of Linux
capabilities that Docker gives to unprivileged containers while others
need additional capabilities. The default list of capabilties include
the following:
  - SETPCAP
  - MKNOD
  - AUDIT_WRITE
  - CHOWN
  - NET_RAW
  - DAC_OVERRIDE
  - FOWNER
  - FSETID
  - KILL
  - SETGID
  - SETUID
  - NET_BIND_SERVICE
  - SYS_CHROOT
  - SETFCAP

The capabilities listed in the daemonset templates function as a
whitelist in that the corresponding containers have access to the Linux
capabilities listed in their SecurityContext, but also the
aforementioned capabilties included by default by Docker.

Summary of testing for each daemonset:

The bcc-capable tool [0] was used to discover which Linux capabilities
the Divingbell containers invoke. The tool was ran against all the
processes running in the container. The Divingbell logs for each
container were also carefully analyzed for failed permission checks.

daemonset-exec:
A recent change to use nsenter to enter all host namespaces when running
exec prevents divingbell-exec from being able to run unprivileged as
there are no Linux capabilties that allows write access to '/proc'.
When trying to run as unprivileged, the following prevents the pod from
coming up:
"nsenter: cannot open /proc/1/ns/ipc: Permission denied"

daemonset-sysctl:
Ran the divingbell-sys containers as unprivileged and the kernel config
on the host updated as defined in the manifest. Kernel configs were
checked before and after running divingbell-sys container as
unprivileged. Beyond the default Linux capabilties given by
Docker, the 'SYS_PTRACE', 'SYS_ADMIN', and 'SYS_RAWIO' Linux
capabilities are needed. The following is a snippet of the logs showing
under which circumstance these privileges are needed:

"INFO * Applying /etc/sysctl.d/10-kernel-hardening.conf ...
INFO sysctl: setting key "kernel.kptr_restrict": Operation not permitted

INFO * Applying /etc/sysctl.d/10-ptrace.conf ...
INFO sysctl: setting key "kernel.yama.ptrace_scope": Operation not
permitted

INFO * Applying /etc/sysctl.d/10-zeropage.conf ...
INFO sysctl: setting key "vm.mmap_min_addr": Operation not permitted"

daemonset-perm:
Ran the divingbell-perm containers as unprivileged and the file
ownership and permissions on the host updated as defined in the
manifest. As a test, the daemon was configured to run every minute
and the targeted files ownership and permissions were manually
changed. It was then verified that divingbell restored the ownership
and permissions of the file to what it should be. This applies to
the divingbell-perm-default and the divingbell-perm-calico containers.

daemonset-limits:
Ran the divingbell-limits containers as unprivileged and checked the
ulimits on the host before and after running divingbell and the ulimit
updated to the value defined in the manifest. The capable tool also
showed that no additional Linux capabilties are needed.

daemonset-apparmor:
Ran the divingbell-apparmor containers as unprivileged and logs show no
evidence of failed permission checks. Additionally, the apparmor config
was updated in the manifest and the apparmor profile successfully
loaded. Beyond the default Linux capabilties given by Docker, the
'MAC_ADMIN' Linux capability is needed to load an apparmor profile.

daemonset-apt:
Ran the divingbell-apt containers as unprivileged and was able to
successfully install package without issues. As a test, the
manifest was updated to install 'htop' and after running Divingbell,
it was confirmed that 'htop' installed successfully. Here is
a snippet from the logs:
DEBUG + INSTALLED_THIS_TIME=' htop'
DEBUG + REQUESTED_PACKAGES=' htop'

daemonset-ethtool:
Ran the divingbell-ethtool containers as unprivileged and was able to
manage NIC tunables. As a check, the NIC tunables for ens3 was checked
before and after running Divingbell - 'ethtool -k ens3'. Divingbell
configured the NIC as defined in the manifest. Beyond the default Linux
capabilties given by Docker, the 'NET_ADMIN' Linux capability is needed.
The following is a log snippet showing what happens when the 'NET_ADMIN'
capability is not added:
"DEBUG + /sbin/ethtool -K cali86cb821b7db tx-nocache-copy off
INFO Cannot set device feature settings: Operation not permitted"

daemonset-uamlite:
Ran the divingbell-uamlite containers as unprivileged and was able to
successfully add user accounts as defined in the manifest. No additional
Linux capabilities are needed.

daemonset_mounts:
Ran the divingbell-mounts containers as unprivileged and was able to
successfully add host level mounts as defined in the manifest. No
additional Linux capabilities are needed.

[0]https://github.com/iovisor/bcc/blob/master/tools/capable.py

Change-Id: I26a1b5e06ad27c854d95e6675de05b884ce3bdc1
2019-03-15 19:51:24 +00:00
Nikita Koshikov 606cf35bda Add new apparmor daemonset
Implemented daemonset that will manage host apparmor profiles.
Tests and documentation added.

demo: https://asciinema.org/a/uQjlWgC4bjI3WkfontmThf8t0

Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com>
Change-Id: I13f7357c15b5c4386a61bba50f097eb434d7f211
2018-12-14 19:02:00 -08:00