The Policy Generator constructs Open Cluster Management policies from Kubernetes YAML files provided through a PolicyGenerator Custom Resource. The Policy Generator is a binary compiled for use as a kustomize exec plugin.
For more about Open Cluster Management and its Policy Framework:
Go to the Contributing guide to learn how to get involved.
-
Download the precompiled plugin binary from the release of your choice.
-
Create the plugin directory:
mkdir -p ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator
-
Move the binary to the plugin directory:
-
Linux:
chmod +x linux-amd64-PolicyGenerator mv linux-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
-
MacOS:
chmod +x darwin-amd64-PolicyGenerator mv darwin-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
-
- Build the plugin binary (only needed once or to update the plugin):
NOTE: This will default to placing the binary in
make build
${HOME}/.config/kustomize/plugin/
. You can change this by exportingKUSTOMIZE_PLUGIN_HOME
to a different path.
-
Create a
kustomization.yaml
file that points toPolicyGenerator
manifest(s), with any additional desired patches or customizations (seeexamples/policyGenerator.yaml
for an example):generators: - path/to/generator/file.yaml
- To read more about the
PolicyGenerator
YAML, see About the PolicyGenerator plugin
- To read more about the
-
To use the plugin to generate policies, do one of:
- Utilize the
examples/
directory in this repository (the directory can be modified by exporting a new path toSOURCE_DIR
):make generate
- From any directory with a
kustomization.yaml
file pointing toPolicyGenerator
manifests:kustomize build --enable-alpha-plugins
- Utilize the
In order to bypass Kustomize and run the generator binary directly:
-
Build the binary:
make build-binary
-
Run the binary from the location of the PolicyGenerator manifest(s):
path/to/PolicyGenerator <path/to/file/1> ... <path/to/file/n>
- For example:
NOTE: To print the trace in the case of an error, you can add the
cd examples ../PolicyGenerator policyGenerator.yaml
--debug
flag to the arguments.
- For example: