共計 3776 個字符,預計需要花費 10 分鐘才能閱讀完成。
本篇內容主要講解“怎么在 Rancher 2.4 中實現 CIS 集群”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓丸趣 TV 小編來帶大家學習“怎么在 Rancher 2.4 中實現 CIS 集群”吧!
為什么 IT Ops 需要 CIS 安全掃描?
根據 CIS 基準手動評估集群是一個十分耗時且容易失敗的過程。而現實中,我們的系統不斷變化,因此我們需要經常進行重新評估。這就是 kube-bench 大展身手之處。這是 Aqua 創建的一種開源工具,用于根據 CIS Benchmark 自動評估集群。
Rancher 2.4 使用 kube-bench 作為安全引擎,并且對其進行了一些補充。借助 Rancher 2.4 中的 CIS 安全掃描,你可以一鍵編排集群掃描。Rancher 負責獲取 kube-bench 工具并將其連接到集群。然后,Rancher 將從所有節點的結果中總結出一個易于閱讀的報告,該報告會展示集群通過或失敗的區域。此外,Rancher 還能讓你在集群級別安排周期掃描。該設置可以在集群模板級別啟用,并在默認情況下,允許管理員為計劃的掃描配置模板,以便針對 Rancher 設置中任何用戶創建的每個新集群運行掃描。最后,Rancher 為 CIS 安全掃描提供自定義告警和通知,由于集群的配置改動導致安全不合規,或者本身集群配置就不合規的時候通過郵件、微信等方式通知安全管理員。
在 Rancher 2.4 中動手實踐 CIS 集群
讓我們啟動一個 Rancher RKE 集群。
前期準備:CentOS VM(至少 2 核),并安裝好 Docker
Step1:運行 Rancher Server
[root@rancher-rke ~]# sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:v2.4.0-rc3
Unable to find image rancher/rancher:v2.4.0-rc3 locally
Trying to pull repository docker.io/rancher/rancher ...
v2.4.0-rc3: Pulling from docker.io/rancher/rancher
423ae2b273f4: Pull complete
de83a2304fa1: Pull complete
f9a83bce3af0: Pull complete
b6b53be908de: Pull complete
b365c90117f7: Pull complete
c939267bea55: Pull complete
7669306d1ae0: Pull complete
25e0f5e123a3: Pull complete
d6664495480f: Pull complete
99f55ceed479: Pull complete
edd7d0bc05aa: Pull complete
77e4b172baa4: Pull complete
48f474afa2cd: Pull complete
2270fe22f735: Pull complete
44c4786f7637: Pull complete
45e3db8be413: Pull complete
6be735114771: Pull complete
dfa5473bfef3: Pull complete
Digest: sha256:496bd1d204744099d70f191e86d6a35a5827f86501322b55f11c686206010b51
Status: Downloaded newer image for docker.io/rancher/rancher:v2.4.0-rc3
a145d93e8fa66a6a08b4f0e936dafc4b9717a93c59013e78118a4c5af8209a53
[root@rancher-rke ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a145d93e8fa6 rancher/rancher:v2.4.0-rc3 entrypoint.sh About a minute ago Up About a minute 0.0.0.0:80- 80/tcp, 0.0.0.0:443- 443/tcp distracted_albattani
Step2:訪問 Rancher URL 并安裝 RKEhttp://{hostIP}
設置密碼和 URL
設置 Rancher 密碼和 URL 作為 host IP
添加一個新集群并選擇 From existing nodes (Custom)(從現有節點添加)
選擇默認選項并選擇 etcd、控制平面和 worker,因為我們將在一個 VM 上安裝這一切。
復制以上命令并運行在 VM 實例上
[root@rancher-rke ~]# **sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.4.0-rc3 --server https://185.136.233.195 --token** hwpf4kpjf49gk9wq5xvw7gdjxtj257j8wmnn5rj6lb98csz2zmkcgq --ca-checksum 3f9640ab12533287fd5e0ad1663cccf354a4ce2a76243cd6735abcfb085bdbf2 --etcd --controlplane --worker
Unable to find image rancher/rancher-agent:v2.4.0-rc3 locally
Trying to pull repository docker.io/rancher/rancher-agent ...
v2.4.0-rc3: Pulling from docker.io/rancher/rancher-agent
423ae2b273f4: Already exists
de83a2304fa1: Already exists
f9a83bce3af0: Already exists
b6b53be908de: Already exists
931af2228ddf: Pull complete
94b51e50d654: Pull complete
7e7961efe32b: Pull complete
85725dc92c8d: Pull complete
5a82c6e509a6: Pull complete
3b675e73aee3: Pull complete
Digest: sha256:89017bd846a8cc597186f41eb17cfe1520aa0f7e6d86b48d8c32a5490c588f1e
Status: Downloaded newer image for docker.io/rancher/rancher-agent:v2.4.0-rc3
5aaa9fab48db4557c84b7ce0c61816384075570ed3e593446795bf8443610b64
在 Rancher UI 中導入集群,我們可以看到集群的狀態為 active:
現在點擊集群,并從【工具】菜單欄中,選擇 CIS 安全掃描。
當前 CIS 安全掃描僅針對 RKE 集群,有兩個掃描配置文件:寬松(Permissive)和嚴格(Hardened)。
Permissive(寬松):該配置文件具有一組將被跳過的測試,因為它們對于剛開始使用 Kubernetes 的用戶來說沒有必要。
Hardened(嚴格):此配置文件不會跳過任何測試。該配置針對高階用戶以及安全專家。
對于每種配置類型,其中一些測試會被標記為不適用,因為它們不適用于 RKE 集群。
現在我們選擇“寬松”配置文件并運行掃描。結果是所有標準 RKE 集群都通過。
為了看到更多關于測試執行的細節,點擊該測試,然后就能顯示整個測試列表,包含失敗 / 跳過 / 通過的信息。
現在,我們使用“嚴格”配置文件來執行相同的測試,我們將會看到上次跳過的測試失敗。
如你所見,根據 CIS 基準測試,失敗的結果提供了描述以及補救步驟。這十分有效,因為你不僅可以根據 CIS 基準了解集群中哪些東西會崩潰,而且還可以根據建議來修復集群。
加強集群安全性的后續步驟
盡管一鍵單擊就能運行 CIS 安全掃描,但是能夠自動化執行則更好。也可以在 Rancher 中進行配置。定期進行安全掃描可以讓你高枕無憂,也是團隊的一針定心劑。如果集群中的確出現了某些不合規的情況,你也能夠更快找到它。
到此,相信大家對“怎么在 Rancher 2.4 中實現 CIS 集群”有了更深的了解,不妨來實際操作一番吧!這里是丸趣 TV 網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!