目的
- kube-bench を理解する
手段
KillerCoda で手を動かす
環境
KillerCoda
やってみる
基本形は以下の通りです。
$ kube-bench run -s master
# -sオプションでコマンド実行対象を指定
特定の CIS を確認するコマンドは以下の通りです。
$ kube-bench run -s master --check 1.1.19
[INFO] 1 Control Plane Security Configuration
[INFO] 1.1 Control Plane Node Configuration Files
[PASS] 1.1.19 Ensure that the Kubernetes PKI directory and file ownership is set to root:root (Automated)
== Summary master ==
1 checks PASS
0 checks FAIL
0 checks WARN
0 checks INFO
== Summary total ==
1 checks PASS
0 checks FAIL
0 checks WARN
0 checks INFO
# 1.1.19 は PASS している
FAIL している場合は以下の通りです。
$ kube-bench run -s master --check 1.1.12
[INFO] 1 Control Plane Security Configuration
[INFO] 1.1 Control Plane Node Configuration Files
[FAIL] 1.1.12 Ensure that the etcd data directory ownership is set to etcd:etcd (Automated)
== Remediations master ==
1.1.12 On the etcd server node, get the etcd data directory, passed as an argument --data-dir,
from the command 'ps -ef | grep etcd'.
Run the below command (based on the etcd data directory found above).
For example, chown etcd:etcd /var/lib/etcd
== Summary master ==
0 checks PASS
1 checks FAIL
0 checks WARN
0 checks INFO
== Summary total ==
0 checks PASS
1 checks FAIL
0 checks WARN
0 checks INFO
# Remediations master の説明に沿って対処すれば PASS できます
# あとがき
サービス問題ですね。
# ソース
- [CIS](https://www.cisecurity.org/benchmark/kubernetes)