@@ -6,65 +6,84 @@ The Policy Generator constructs Open Cluster Management policies from Kubernetes
66PolicyGenerator Custom Resource. The Policy Generator is a binary compiled for use as a
77[ kustomize] ( https://kustomize.io/ ) exec plugin.
88
9+ - [ Installing the Policy Generator] ( #installing-the-policy-generator )
10+ - [ Prerequisite] ( #prerequisite )
11+ - [ Install the binary] ( #install-the-binary )
12+ - [ Download a released version] ( #download-a-released-version )
13+ - [ Using ` go install ` (available for ` v1.11.0 ` and higher)] ( #using-go-install-available-for-v1110-and-higher )
14+ - [ Build from source] ( #build-from-source )
15+ - [ Using the Policy Generator] ( #using-the-policy-generator )
16+ - [ As a Kustomize plugin] ( #as-a-kustomize-plugin )
17+ - [ As a standalone binary] ( #as-a-standalone-binary )
18+ - [ Additional Policy Generator references] ( #additional-policy-generator-references )
19+
920For more about Open Cluster Management and its Policy Framework:
1021
1122- [ Open Cluster Management website] ( https://open-cluster-management.io/ )
1223- [ Governance Policy Framework] ( https://open-cluster-management.io/getting-started/integration/policy-framework/ )
1324- [ Policy Collection repository] ( https://github.com/open-cluster-management-io/policy-collection )
1425
15- ## Using the Policy Generator
26+ ## Install the Policy Generator
1627
17- ### As a Kustomize plugin
28+ ### Prerequisite
1829
19- #### Install from the GitHub release
30+ Create the plugin directory (optional if using the generator without Kustomize):
2031
21- 1 . Create the plugin directory:
32+ ``` bash
33+ mkdir -p ${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator
34+ ```
2235
23- ``` bash
24- mkdir -p ${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator
25- ```
36+ ** NOTE: ** The default directory for Kustomize plugins is ` ${HOME}/.config/kustomize/plugin/ ` , which is used directly in
37+ this readme. You can change this by exporting ` KUSTOMIZE_PLUGIN_HOME ` to a different path and updating the root of the
38+ paths used in this document.
2639
27- 2 . Install the binary. You can either:
40+ ### Install the binary
2841
29- - Download a released version:
42+ #### Download a released version
3043
31- 1 . Download the precompiled plugin binary from the
32- [ release] ( https://github.com/open-cluster-management-io/policy-generator-plugin/releases ) of your choice.
44+ 1 . Download the precompiled plugin binary from the
45+ [ release] ( https://github.com/open-cluster-management-io/policy-generator-plugin/releases ) of your choice.
3346
34- 2 . Move the binary to the plugin directory:
47+ 2 . Make the binary executable and move the binary to the plugin directory:
3548
36- - Linux:
49+ - Linux:
3750
38- ``` bash
39- chmod +x linux-amd64-PolicyGenerator
40- mv linux-amd64-PolicyGenerator ${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
41- ```
51+ ``` bash
52+ chmod +x linux-amd64-PolicyGenerator
53+ mv linux-amd64-PolicyGenerator ${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
54+ ```
4255
43- - MacOS:
56+ - MacOS:
57+ ` ` ` bash
58+ chmod +x darwin-amd64-PolicyGenerator
59+ mv darwin-amd64-PolicyGenerator ${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
60+ ` ` `
4461
45- ` ` ` bash
46- chmod +x darwin-amd64-PolicyGenerator
47- mv darwin-amd64-PolicyGenerator ${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
48- ` ` `
62+ # ### Use `go install` (available for `v1.11.0` and higher)
4963
50- - Use ` go install ` (available for ` v1.11.0 ` and higher ):
64+ Set the ` GOBIN ` to the plugin directory and specify the desired version (this command uses ` latest ` ):
5165
52- - Set the ` GOBIN` to the plugin directory and specify the desired version (this command uses ` latest` ):
53- ` ` ` bash
54- GOBIN=${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator \
55- go install open-cluster-management.io/policy-generator-plugin/cmd/PolicyGenerator@latest
56- ` ` `
66+ ` ` ` bash
67+ GOBIN=${HOME} /.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator \
68+ go install open-cluster-management.io/policy-generator-plugin/cmd/PolicyGenerator@latest
69+ ` ` `
5770
58- # ### Build and install from source
71+ # ### Build from source
5972
60- 1. Build the plugin binary (only needed once or to update the plugin):
61- ` ` ` bash
62- make build
63- ` ` `
64- ** NOTE:** This will default to placing the binary in ` ${HOME} /.config/kustomize/plugin/` . You can change this by
65- exporting ` KUSTOMIZE_PLUGIN_HOME` to a different path.
73+ ` ` ` bash
74+ make build
75+ ` ` `
76+
77+ ** NOTE:**
78+
79+ - This defaults to placing the binary in the Kustomize default plugin directory ` ${HOME} /.config/kustomize/plugin/` . You
80+ can change this by exporting ` KUSTOMIZE_PLUGIN_HOME` to a different path.
81+ - Alternatively, you can run ` make build-binary` to place the binary at the root of the repository and either use it
82+ directly from there or move it to the plugin directory to use with Kustomize.
83+
84+ # # Using the Policy Generator
6685
67- # ### Configuration
86+ # ## As a Kustomize plugin
6887
69881. Create a ` kustomization.yaml` file that points to ` PolicyGenerator` manifest(s), with any additional desired patches
7089 or customizations (see [` examples/policyGenerator.yaml` ](./examples/policyGenerator.yaml) for an example):
@@ -74,44 +93,35 @@ For more about Open Cluster Management and its Policy Framework:
7493 - path/to/generator/file.yaml
7594 ` ` `
7695
77- - To read more about the ` PolicyGenerator` YAML, see [About the PolicyGenerator plugin](./docs/policygenerator.md)
96+ - To read more about the ` PolicyGenerator` YAML structure, see the
97+ [Policy Generator reference YAML](./docs/policygenerator-reference.yaml)
7898
79- 2. To use the plugin to generate policies, do one of:
80- - Utilize the ` examples/` directory in this repository (the directory can be modified by exporting a new path to
81- ` SOURCE_DIR` ):
82- ` ` ` bash
83- make generate
84- ` ` `
85- - From any directory with a ` kustomization.yaml` file pointing to ` PolicyGenerator` manifests:
86- ` ` ` bash
87- kustomize build --enable-alpha-plugins
88- ` ` `
99+ 2. To use the plugin to generate policies, run the Kustomize build command from any directory with a
100+ ` kustomization.yaml` file pointing to ` PolicyGenerator` manifests:
101+ ` ` ` bash
102+ kustomize build --enable-alpha-plugins
103+ ` ` `
89104
90105# ## As a standalone binary
91106
92- In order to bypass Kustomize and run the generator binary directly:
107+ In order to bypass Kustomize and run the generator binary directly, change to the directory of PolicyGenerator
108+ manifest(s) and run the binary with the manifest(s) as the input arguments:
93109
94- 1. Get the binary. You can either:
110+ ` ` ` bash
111+ path/to/PolicyGenerator < path/to/file/1> ... < path/to/file/n>
112+ ` ` `
95113
96- - Build from source :
114+ For example :
97115
98- ` ` ` bash
99- make build-binary
100- ` ` `
116+ ` ` ` bash
117+ make build-binary # This places the binary at the root of the repo, so this is optional if it was done previously
118+ cd examples
119+ ../PolicyGenerator policyGenerator.yaml
120+ ` ` `
101121
102- - Use ` go install ` (available for ` v1.11.0 ` and higher):
122+ ** NOTE: ** To print the trace in the case of an error, you can add the ` --debug ` flag to the arguments.
103123
104- ` ` ` bash
105- go install open-cluster-management.io/policy-generator-plugin/cmd/PolicyGenerator@latest
106- ` ` `
124+ # # Additional Policy Generator references
107125
108- 2. Run the binary from the location of the PolicyGenerator manifest(s):
109- ` ` ` bash
110- path/to/PolicyGenerator < path/to/file/1> ... < path/to/file/n>
111- ` ` `
112- - For example:
113- ` ` ` bash
114- cd examples
115- ../PolicyGenerator policyGenerator.yaml
116- ` ` `
117- ** NOTE:** To print the trace in the case of an error, you can add the ` --debug` flag to the arguments.
126+ - [Policy Generator reference YAML](./docs/policygenerator-reference.yaml)
127+ - [Policy Generator technical documentation](./docs/policygenerator.md)
0 commit comments