Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina mostra come proteggere i container attivando SELinux. SELinux è supportato per Red Hat Enterprise Linux (RHEL). Se le tue macchine host eseguono RHEL e vuoi attivare SELinux per il cluster, devi attivare SELinux su tutte le macchine host. A partire dalla release 1.9.0 di Google Distributed Cloud, puoi attivare o disattivare SELinux prima o dopo la creazione o gli upgrade dei cluster. Quando SELinux è abilitato sull'host, lo è anche per il runtime del contenitore.
Verificare se SELinux è attivo
SELinux è attivo su RHEL per impostazione predefinita.
Per verificare, esegui:
getenforce
Il comando restituisce Enforcing, Permissive o Disabled. Se il comando restituisce Enforcing, puoi procedere con l'upgrade o la creazione dei cluster.
Abilita SELinux
Se il comando getenforce restituisce Permissive, puoi passare alla modalità Enforcing utilizzando il comando setenforce. Il passaggio dalla modalità Permissive alla modalità
Enforcing utilizzando setenforce non richiede il riavvio del sistema. Tuttavia, se
vuoi che le modifiche siano permanenti dopo i riavvii, devi aggiornare il
file /etc/selinux/config.
Per passare alla modalità Enforcing, esegui:
sudosetenforce1# temporary
sudosed-i's/SELINUX=permissive/SELINUX=enforcing/g'/etc/selinux/config# persistent - after reboot
Se SELinux è Disabled, per attivarlo ti consigliamo di attivarlo prima in modalità Permissive e di riavviare il sistema per verificare che l'avvio sia andato a buon fine. Se non sono presenti errori SELinux, puoi passare in sicurezza a modalità SELinuxEnforcing.
Facoltativo: abilita SELinux in modalità Permissive:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-01 UTC."],[],[],null,["This page shows you how to secure your containers by enabling SELinux. SELinux\nis supported for Red Hat Enterprise Linux (RHEL). If your host machines are\nrunning RHEL and you want to enable SELinux for your cluster, you must enable\nSELinux in all of your host machines. Starting with Google Distributed Cloud release\n1.9.0, you can enable or disable SELinux before or after cluster creation or\ncluster upgrades. When SELinux is enabled on the host, it is enabled for the\ncontainer runtime.\n\nCheck if SELinux is enabled\n\nSELinux is enabled on RHEL by default.\n\n- To verify, run:\n\n getenforce\n\nThe command returns either `Enforcing`, `Permissive`, or `Disabled`. If the\ncommand returns `Enforcing`, then you can proceed with upgrading or creating\nyour clusters.\n\nEnable SELinux\n\nIf the `getenforce` command returns `Permissive`, you can switch to `Enforcing`\nmode using the `setenforce` command. Toggling between `Permissive` and\n`Enforcing` mode using `setenforce` doesn't require a system reboot. However, if\nyou want the changes to be persistent across reboots, you must update the\n`/etc/selinux/config` file.\n\n- To switch to `Enforcing` mode, run:\n\n sudo setenforce 1 # temporary\n sudo sed -i 's/SELINUX=permissive/SELINUX=enforcing/g' /etc/selinux/config # persistent - after reboot\n\nIf SELinux is `Disabled`, to enable it, we recommend to first enable it in\n`Permissive` mode first and reboot the system to verify that the system boots\nsuccessfully. If there are no SELinux errors, then you can safely switch SELinux\nto `Enforcing` mode.\n\n1. **Optional** : Enable SELinux in `Permissive` mode:\n\n sudo sed -i 's/SELINUX=disabled/SELINUX=permissive/g' /etc/selinux/config\n sudo reboot\n\n2. If the system reboots successfully with no SELinux errors, then you can\n enable `Enforcing` mode:\n\n sudo sed -i 's/SELINUX=disabled/SELINUX=enforcing/g' /etc/selinux/config\n sudo reboot\n\nOnce SELinux is enabled in `Enforcing` mode, SELinux is enabled for all\nprocesses on the host, including the container runtime."]]