Skip to content

Commit b66b1b1

Browse files
committed
add extra confiuguration for CIS hardening
1 parent 2b0c3a7 commit b66b1b1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

templates/flavors/rke2/rke2ConfigTemplate.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ spec:
1010
version: ${KUBERNETES_VERSION}
1111
nodeName: '{{ ds.meta_data.label }}'
1212
cisProfile: ${CIS_PROFILE:-"cis-1.23"}
13+
protectKernelDefaults: true
1314
# TODO: use MDS to get public and private IP instead because hostname ordering can't always be assumed
1415
preRKE2Commands:
1516
- |
@@ -18,3 +19,6 @@ spec:
1819
- sed -i '/swap/d' /etc/fstab
1920
- swapoff -a
2021
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
22+
- cp -f /usr/local/share/rke2/rke2-cis-sysctl.conf /etc/sysctl.d/60-rke2-cis.conf
23+
- systemctl restart systemd-sysctl
24+
- useradd -r -c "etcd user" -s /sbin/nologin -M etcd -U

templates/flavors/rke2/rke2ControlPlane.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ spec:
3434
version: ${KUBERNETES_VERSION}
3535
nodeName: '{{ ds.meta_data.label }}'
3636
cisProfile: ${CIS_PROFILE:-"cis-1.23"}
37+
protectKernelDefaults: true
3738
preRKE2Commands:
3839
- |
3940
mkdir -p /etc/rancher/rke2/config.yaml.d/
4041
echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml
4142
- sed -i '/swap/d' /etc/fstab
4243
- swapoff -a
4344
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
45+
- cp -f /usr/local/share/rke2/rke2-cis-sysctl.conf /etc/sysctl.d/60-rke2-cis.conf
46+
- systemctl restart systemd-sysctl
47+
- useradd -r -c "etcd user" -s /sbin/nologin -M etcd -U
4448
replicas: ${CONTROL_PLANE_MACHINE_COUNT}

0 commit comments

Comments
 (0)