이 페이지에서는 SELinux를 사용 설정하여 컨테이너를 보호하는 방법을 설명합니다. SELinux는 Red Hat Enterprise Linux(RHEL)에서 지원됩니다. 호스트 머신이 RHEL을 실행 중이고 클러스터에서 SELinux를 사용 설정하려면 모든 호스트 머신에서 SELinux를 사용 설정해야 합니다. Google Distributed Cloud 출시 버전 1.9.0부터 클러스터 만들기 또는 클러스터 업그레이드 전후에 SELinux를 사용 설정하거나 중지할 수 있습니다. SELinux가 호스트에서 사용 설정되면 컨테이너 런타임에 대해 사용 설정됩니다.
SELinux가 사용 설정되었는지 확인
SELinux는 기본적으로 RHEL에서 사용 설정됩니다.
확인하려면 다음을 실행합니다.
getenforce
이 명령어는 Enforcing, Permissive, Disabled를 반환합니다. 이 명령어가 Enforcing을 반환하면 클러스터를 업그레이드하거나 만들 수 있습니다.
SELinux 사용 설정
getenforce 명령어가 Permissive를 반환하면 setenforce 명령어를 사용하여 Enforcing 모드로 전환할 수 있습니다. setenforce를 사용하여 Permissive 또는 Enforcing 모드로 전환할 때는 시스템 재부팅이 필요하지 않습니다. 하지만 재부팅 시에도 변경사항이 유지되도록 하려면 /etc/selinux/config 파일을 업데이트해야 합니다.
Enforcing 모드로 전환하려면 다음을 실행합니다.
sudosetenforce1# temporary
sudosed-i's/SELINUX=permissive/SELINUX=enforcing/g'/etc/selinux/config# persistent - after reboot
SELinux가 Disabled일 때, 이를 사용 설정하려면 먼저 Permissive 모드에서 사용 설정한 후 시스템을 재부팅하여 시스템이 성공적으로 부팅되는지 확인하는 것이 좋습니다. SELinux 오류가 없으면 SELinux를 Enforcing 모드로 안전하게 전환할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 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."]]