開発メモ

conftestざっくり調査

April 26, 2020

GitHub - instrumenta/conftest: Write tests against structured configuration data using the Open Policy Agent Rego query language

  • YAML/JSONをチェックできるツール

  • チェックする内容はOpen Policy Agentの規定する言語Regoで記述

  • k8sのマニフェストに使われる事例が多いが機能としては汎用的

  • ルールの例

package main

deny[msg] {
  input.kind = "Deployment"
  not input.spec.template.spec.securityContext.runAsNonRoot = true
  msg = "Containers must not run as root"
}

deny[msg] {
  input.kind = "Deployment"
  not input.spec.selector.matchLabels.app
  msg = "Containers must provide app label for pod selectors"
}
2020/04/27追記

Tagged: #conftest #Rego