<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Kubernetes 資源清單靜態(tài)分析工具 - KubeLinter

          共 3873字,需瀏覽 8分鐘

           ·

          2021-07-28 09:12

          KubeLinter 是一種開(kāi)源靜態(tài)分析工具,用于識(shí)別 Kubernetes 對(duì)象中的錯(cuò)誤配置。KubeLinter 提供了對(duì) Kubernetes YAML 文件和 Helm Chart 的安全檢查的能力,驗(yàn)證集群配置是否遵循最佳安全實(shí)踐。通過(guò)內(nèi)置檢查,可以獲得有關(guān)錯(cuò)誤配置和違反 Kubernetes 策略的反饋。這提高了開(kāi)發(fā)人員的工作效率,將安全即代碼與 DevOps 和 DevSecOps 流程集成,同時(shí)確保為 Kubernetes 應(yīng)用程序自動(dòng)實(shí)施強(qiáng)化的安全策略。

          KubeLinter 分析 YAML 文件和 Helm Chart 并運(yùn)行 Kubernetes 原生安全檢查,以識(shí)別提升的訪問(wèn)權(quán)限、錯(cuò)誤配置和一般的最佳實(shí)踐違規(guī)行為。KubeLinter 是一個(gè)基于 Go 的二進(jìn)制文件,用于命令行或 CI 管道的一部分,并在允許任何 Kubernetes 配置更改之前為開(kāi)發(fā)人員提供必要的安全檢查。目前,CLI 中內(nèi)置了 19 項(xiàng)安全檢查,包括:

          • 使用默認(rèn)ServiceAccount
          • 不匹配的選擇器
          • 以 root 身份運(yùn)行容器
          • 設(shè)置可寫(xiě)的 host 主機(jī)掛載

          安裝 KubeLinter

          使用 Go 安裝

          GO111MODULE=on go get golang.stackrox.io/kube-linter/cmd/kube-linter

          或者直接從 Release 頁(yè)面(https://github.com/stackrox/kube-linter/releases/tag/0.2.2)下載最新的二進(jìn)制文件添加到 PATH 路徑下即可。

          使用 brew 安裝

          在 macOS 下使用 Homebrew 或者在 Linux 下使用 LinuxBrew 安裝:

          brew install kube-linter

          使用 KubeLinter

          運(yùn)行 KubeLinter 對(duì) YAML 文件進(jìn)行 Lint 只需要最基本的兩個(gè)步驟即可:

          1. 找到您要測(cè)試安全性和生產(chǎn)就緒最佳實(shí)踐的 YAML 文件

          2. 執(zhí)行命令 kube-linter lint /path/to/your/yaml.yaml

          例如下面的的 pod.yaml 資源文件,該文件存在幾個(gè)問(wèn)題:

          安全問(wèn)題

          1. 這個(gè) pod 中的容器不是作為只讀文件系統(tǒng)運(yùn)行的,這可能允許它寫(xiě)入 root 文件系統(tǒng)。

          生產(chǎn)就緒

          1. 容器的 CPU 限制未設(shè)置,這可能會(huì)使其消耗過(guò)多的 CPU
          2. 未設(shè)置容器的內(nèi)存限制,這可能會(huì)使其消耗過(guò)多內(nèi)存
          apiVersion: v1
          kind: Pod
          metadata:
          name: security-context-demo
          spec:
          securityContext:
              runAsUser: 1000
              runAsGroup: 3000
              fsGroup: 2000
          volumes:
          - name: sec-ctx-vol
              emptyDir: {}
          containers:
          - name: sec-ctx-demo
              image: busybox
              resources:
              requests:
                  memory: "64Mi"
                  cpu: "250m"
              command: [ "sh", "-c", "sleep 1h" ]
              volumeMounts:
              - name: sec-ctx-vol
              mountPath: /data/demo
              securityContext:
              allowPrivilegeEscalation: false
          3. 拷貝上面的 pod.yaml 文件執(zhí)行下面的命令進(jìn)行 lint
          kube-linter lint pod.yaml
          4. KubeLinter 運(yùn)行默認(rèn)檢查,會(huì)輸出如下所示的結(jié)果
          pod.yaml: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" does not have a read-only root file system (check: no-read-only-root-fs, remediation: Set readOnlyRootFilesystem to true in your container's securityContext.)

          pod.yaml: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" has cpu limit 0 (check: unset-cpu-requirements, remediation: Set    your container's CPU requests and limits depending on its requirements. See    https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/   #requests-and-limits for more details.)

          pod.yaml: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" has memory limit 0 (check: unset-memory-requirements, remediation:    Set your container's memory requests and limits depending on its requirements.    See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/   #requests-and-limits for more details.)

          Error: found 3 lint errors

          要了解有關(guān) KubeLinter 使用和配置的更多信息,請(qǐng)?jiān)L問(wèn) https://docs.kubelinter.io。

          倉(cāng)庫(kù)地址:https://github.com/stackrox/kube-linter

          瀏覽 53
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  九九色在线播放 | 狠狠躁日日躁夜夜躁A片男男视频 | 天天射天天干亚洲69 | 午夜熟妇| 成 人 免费 黄 色 |