Skip to content

Commit

Permalink
add extra confiuguration for CIS hardening
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed Apr 23, 2024
1 parent 2b0c3a7 commit b66b1b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions templates/flavors/rke2/rke2ConfigTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
version: ${KUBERNETES_VERSION}
nodeName: '{{ ds.meta_data.label }}'
cisProfile: ${CIS_PROFILE:-"cis-1.23"}
protectKernelDefaults: true
# TODO: use MDS to get public and private IP instead because hostname ordering can't always be assumed
preRKE2Commands:
- |
Expand All @@ -18,3 +19,6 @@ spec:
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
- cp -f /usr/local/share/rke2/rke2-cis-sysctl.conf /etc/sysctl.d/60-rke2-cis.conf
- systemctl restart systemd-sysctl
- useradd -r -c "etcd user" -s /sbin/nologin -M etcd -U
4 changes: 4 additions & 0 deletions templates/flavors/rke2/rke2ControlPlane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ spec:
version: ${KUBERNETES_VERSION}
nodeName: '{{ ds.meta_data.label }}'
cisProfile: ${CIS_PROFILE:-"cis-1.23"}
protectKernelDefaults: true
preRKE2Commands:
- |
mkdir -p /etc/rancher/rke2/config.yaml.d/
echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
- cp -f /usr/local/share/rke2/rke2-cis-sysctl.conf /etc/sysctl.d/60-rke2-cis.conf
- systemctl restart systemd-sysctl
- useradd -r -c "etcd user" -s /sbin/nologin -M etcd -U
replicas: ${CONTROL_PLANE_MACHINE_COUNT}

0 comments on commit b66b1b1

Please sign in to comment.