- Go 1.22 or newer (to build the application)
- GNU Make (to build and test easier)
- Open Policy Agent (to test REGO policies)
Note: This project uses Go Modules
making it safe to work with it outside of your existing GOPATH.
The instructions that follow assume a directory in your home directory outside of
the standard GOPATH (i.e $HOME/development/
).
-
Clone GKE Policy Automation repository
mkdir -p $HOME/development; cd $HOME/development git clone https://github.com/google/gke-policy-automation.git
-
Enter the application directory and compile it
cd gke-policy-automation make build
-
To run unit tests, use make
test
targetmake test
-
To check code and report suspicious constructs, use make
vet
targetmake vet
-
To check code formatting, use make
fmtcheck
targetmake fmtcheck
The application repository comes with a set of recommended REGO rules that cover GKE cluster best practices. Rego rules can be tested with OPA Policy Testing framework.
NOTE: -v
flag sets verbose reporting mode.
opa test <POLICY_DIR> -v
To test set of project policies:
opa test gke-policies-v2 -v
Please check GKE Policy authoring guide for guides on authoring REGO rules for GKE Policy Automation.