Pod is targeted by a NetworkPolicy, both egress and ingress rules are recommended
Deployments and StatefulSets should have a PodDisruptionPolicy
Deployments and StatefulSets should have host PodAntiAffinity configured
Container probes, a readiness should be configured, and should not be identical to the liveness probe. Read more in README_PROBES.md.
Container securityContext, run as high number user/group, do not run as root or with privileged root fs. Read more in README_SECURITYCONTEXT.md.
Stable APIs, use a stable API if available (supported: Deployments, StatefulSets, DaemonSet)
Example output
Usage in CI
kube-score can run in your CI/CD environment and will exit with exit code 1 if a critical error has been found.
The trigger level can be changed to warning with the --exit-one-on-warning argument.
The input to kube-score should be all applications that you deploy to the same namespace for the best result.
docker run -v $(pwd):/project zegl/kube-score:latest score my-app/*.yaml
Configuration
Usage of kube-score:
kube-score [action] --flags
Actions:
score Checks all files in the input, and gives them a score and recommendations
list Prints a CSV list of all available score checks
version Print the version of kube-score
help Print this message
Flags for score:
--disable-ignore-checks-annotations Set to true to disable the effect of the 'kube-score/ignore' annotations
--disable-optional-checks-annotations Set to true to disable the effect of the 'kube-score/enable' annotations
--enable-optional-test strings Enable an optional test, can be set multiple times
--exit-one-on-warning Exit with code 1 in case of warnings
--help Print help
--ignore-container-cpu-limit Disables the requirement of setting a container CPU limit
--ignore-container-memory-limit Disables the requirement of setting a container memory limit
--ignore-test strings Disable a test, can be set multiple times
--kubernetes-version string Setting the kubernetes-version will affect the checks ran against the manifests. Set this to the version of Kubernetes that you're using in production for the best results. (default "v1.18")
-o, --output-format string Set to 'human', 'json', 'ci' or 'sarif'. If set to ci, kube-score will output the program in a format that is easier to parse by other programs. Sarif output allows for easier integration with CI platforms. (default "human")
--output-version string Changes the version of the --output-format. The 'json' format has version 'v2' (default) and 'v1' (deprecated, will be removed in v1.7.0). The 'human' and 'ci' formats has only version 'v1' (default). If not explicitly set, the default version for that particular output format will be used.
-v, --verbose count Enable verbose output, can be set multiple times for increased verbosity.
Ignoring a test
Tests can be ignored in the whole run of the program, with the --ignore-test flag.
A test can also be ignored on a per-object basis, by adding the annotation kube-score/ignore to the object.
The value should be a comma separated string of the test IDs.
Example:
Testing this object will temporarily disable the service-type test, which warns against using services of type NodePort.
Optional tests can be enabled in the whole run of the program, with the --enable-optional-test flag.
A test can also be enabled on a per-object basis, by adding the annotation kube-score/enable to the object.
The value should be a comma separated string of the test IDs.
Example:
Testing this object will enable the container-seccomp-profile test.
Also multiple tests defined by kube-score/ignore are also ignored at the same.
请发表评论