k3s-io / k3s-selinux

SELinux policy for k3s
Apache License 2.0
66 stars 20 forks source link

K3s Selinux with Cilium CNI Problem #64

Open deiberts86 opened 1 month ago

deiberts86 commented 1 month ago

PROBLEM: K3s Selinux doesn't seem to work well with Cilium CNI on K3s.

Installed container-selinux and k3s-selinux:

rpm -Ivh https://github.com/k3s-io/k3s-selinux/releases/download/v1.5.stable.1/k3s-selinux-1.5-1.el9.noarch.rpm

Current K3s config.yaml file:

cluster-init: true
disable-network-policy: true
disable-cloud-controller: true
disable-kube-proxy: true
flannel-backend: "none"
disable:
- traefik
- servicelb
node-ip: "$NODEIP"
node-external-ip: "$NODEEXTIP"
selinux: true
secrets-encryption: true
write-kubeconfig-mode: 0600
kube-controller-manager-arg:
- bind-address=127.0.0.1
- use-service-account-credentials=true
- tls-min-version=VersionTLS12
- tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
kube-scheduler-arg:
- tls-min-version=VersionTLS12
- tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
kube-apiserver-arg:
- tls-min-version=VersionTLS12
- tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- authorization-mode=RBAC,Node
- anonymous-auth=false
- admission-control-config-file=/etc/rancher/k3s/rancher-psact.yaml
- audit-policy-file=/etc/rancher/k3s/audit-policy.yaml
- audit-log-mode=blocking-strict
- audit-log-maxage=30
kubelet-arg:
- protect-kernel-defaults=true
- read-only-port=0
- authorization-mode=Webhook
- streaming-connection-idle-timeout=5m
token: "$TOKEN"
tls-san:
- $VIPSAN
- $VIP
dronenb commented 1 week ago

@deiberts86 check the SELinux labels of the k3s binary:

ls -Z /usr/local/bin/k3s

Output should be similar to the following:

unconfined_u:object_r:container_runtime_exec_t:s0 /usr/local/bin/k3s

If not, try restoring the SELinux labels on that file using the following:

/usr/sbin/restorecon /usr/local/bin/k3s

A primer on SELinux that I found very helpful: https://www.youtube.com/watch?v=_WOKRaM-HI4