wget https://github.com/controlplaneio/kubesec/releases/download/v2.14.0/kubesec_linux_amd64.tar.gz
链接:https://pan.baidu.com/s/1KHb5Qn9k1uIQeFOE_Ib6rg?pwd=h0i0
提取码:h0i0
–来自百度网盘超级会员V7的分享
tar -zxf kubesec_linux_amd64.tar.gz
mv kubesec /usr/bin/
kubesec version
cat <> kubesec-test.yaml
apiVersion: v1
kind: Pod
metadata:
name: kubesec-demo
spec:
containers:
- name: kubesec-demo
image: gcr.io/google-samples/node-hello:1.0
securityContext:
readOnlyRootFilesystem: true
EOF
kubesec scan kubesec-test.yaml
docker run -d -p 8080:8080 kubesec/kubesec http 8080
curl -sSX POST --data-binary @kubesec-test.yaml http://localhost:8080/scan
[
{
"object": "Pod/kubesec-demo.default",
"valid": true,
"fileName": "kubesec-test.yaml",
"message": "Passed with a score of 1 points",
"score": 1,
"scoring": {
"passed": [
{
"id": "ReadOnlyRootFilesystem",
"selector": "containers[] .securityContext .readOnlyRootFilesystem == true",
"reason": "An immutable root filesystem can prevent malicious binaries being added to PATH and increase attack cost",
"points": 1
}
],
"advise": [
{
"id": "ApparmorAny",
"selector": ".metadata .annotations .\"container.apparmor.security.beta.kubernetes.io/nginx\"",
"reason": "Well defined AppArmor policies may provide greater protection from unknown threats. WARNING: NOT PRODUCTION READY",
"points": 3
},
{
"id": "ServiceAccountName",
"selector": ".spec .serviceAccountName",
"reason": "Service accounts restrict Kubernetes API access and should be configured with least privilege",
"points": 3
},
{
"id": "SeccompAny",
"selector": ".metadata .annotations .\"container.seccomp.security.alpha.kubernetes.io/pod\"",
"reason": "Seccomp profiles set minimum privilege and secure against unknown threats",
"points": 1
},
{
"id": "AutomountServiceAccountToken",
"selector": ".spec .automountServiceAccountToken == false",
"reason": "Disabling the automounting of Service Account Token reduces the attack surface of the API server",
"points": 1
},
{
"id": "RunAsGroup",
"selector": ".spec, .spec.containers[] | .securityContext .runAsGroup -gt 10000",
"reason": "Run as a high-UID group to avoid conflicts with the host's groups",
"points": 1
},
{
"id": "RunAsNonRoot",
"selector": ".spec, .spec.containers[] | .securityContext .runAsNonRoot == true",
"reason": "Force the running image to run as a non-root user to ensure least privilege",
"points": 1
},
{
"id": "RunAsUser",
"selector": ".spec, .spec.containers[] | .securityContext .runAsUser -gt 10000",
"reason": "Run as a high-UID user to avoid conflicts with the host's users",
"points": 1
},
{
"id": "LimitsCPU",
"selector": "containers[] .resources .limits .cpu",
"reason": "Enforcing CPU limits prevents DOS via resource exhaustion",
"points": 1
},
{
"id": "LimitsMemory",
"selector": "containers[] .resources .limits .memory",
"reason": "Enforcing memory limits prevents DOS via resource exhaustion",
"points": 1
},
{
"id": "RequestsCPU",
"selector": "containers[] .resources .requests .cpu",
"reason": "Enforcing CPU requests aids a fair balancing of resources across the cluster",
"points": 1
},
{
"id": "RequestsMemory",
"selector": "containers[] .resources .requests .memory",
"reason": "Enforcing memory requests aids a fair balancing of resources across the cluster",
"points": 1
},
{
"id": "CapDropAny",
"selector": "containers[] .securityContext .capabilities .drop",
"reason": "Reducing kernel capabilities available to a container limits its attack surface",
"points": 1
},
{
"id": "CapDropAll",
"selector": "containers[] .securityContext .capabilities .drop | index(\"ALL\")",
"reason": "Drop all capabilities and add only those required to reduce syscall attack surface",
"points": 1
}
]
}
}
]
Kubesec 是一个针对 Kubernetes 的安全特性扩展项目,旨在提供自动化的安全策略、加密和身份验证、漏洞扫描和修复、合规性检查以及安全审计日志等功能,以增强 Kubernetes 集群的安全性、可靠性和合规性。
通过部署 Kubesec,可以自动化地定义和执行安全规则,减少手动编写安全脚本的工作量,同时提供加密和身份验证机制,确保集群中的数据和通信的安全性。此外,Kubesec 还支持与漏洞扫描工具集成,以发现和修复工作负载中的漏洞,并可以监视容器映像以自动更新漏洞修复。
Kubesec 还提供了合规性检查功能,以确保 Kubernetes 集群符合特定的安全标准和法规要求。它支持可扩展的插件架构,可以轻松添加新的合规性规则和检查。此外,Kubesec 还生成详细的安全审计日志,记录集群中的安全事件和操作,以便进行监控和检测潜在的安全问题,并提供合规性报告。
总之,Kubesec 是一个强大的工具,可以帮助开发人员和运维人员在 Kubernetes 环境中实现安全性、可靠性和合规性。