Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página se muestra cómo proteger tus contenedores mediante la habilitación de SELinux. SELinux es compatible con Red Hat Enterprise Linux (RHEL). Si tus máquinas anfitrión ejecutan RHEL o CentOS y deseas habilitar SELinux para tu clúster, debes habilitar SELinux en todas tus máquinas anfitrión. A partir de la versión 1.9.0 de Google Distributed Cloud, puedes habilitar o inhabilitar SELinux antes o después de la creación o actualización de clústeres. Cuando SELinux está habilitado en el host, está habilitado para el entorno de ejecución del contenedor.
Comprueba si SELinux está habilitado
SELinux está habilitado en RHEL de forma predeterminada.
Para verificarlo, ejecute el siguiente comando:
getenforce
El comando muestra Enforcing, Permissive o Disabled. Si el comando muestra Enforcing, puedes continuar con la actualización o la creación de tus clústeres.
Habilita SELinux
Si el comando getenforce muestra Permissive, puedes cambiar al modo Enforcing con el comando setenforce. Activar o desactivar el modo Permissive y Enforcing mediante setenforce no requiere que se reinicie el sistema. Sin embargo, si deseas que los cambios sean persistentes en todos los reinicios, debes actualizar el archivo /etc/selinux/config.
Para cambiar al modo Enforcing, ejecuta lo siguiente:
sudosetenforce1# temporary
sudosed-i's/SELINUX=permissive/SELINUX=enforcing/g'/etc/selinux/config# persistent - after reboot
Si SELinux es Disabled, para habilitarlo, primero debes habilitarlo en el modo Permissive y reiniciar el sistema a fin de verificar que el sistema se inicie correctamente. Si no hay errores de SELinux, puedes cambiar SELinux de forma segura al modo Enforcing.
Una vez que SELinux está habilitado en modo Enforcing, SELinux se habilita para todos los procesos en el host, incluido el entorno de ejecución del contenedor.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]