{"id":13798258,"url":"https://github.com/open-cluster-management-io/policy-generator-plugin","last_synced_at":"2025-04-24T06:09:56.019Z","repository":{"id":37044978,"uuid":"403791820","full_name":"open-cluster-management-io/policy-generator-plugin","owner":"open-cluster-management-io","description":"A Kustomize generator plugin to generate Open Cluster Management policies","archived":false,"fork":false,"pushed_at":"2025-04-21T17:50:47.000Z","size":487,"stargazers_count":29,"open_issues_count":1,"forks_count":30,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-24T06:09:49.261Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-cluster-management-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-07T00:24:55.000Z","updated_at":"2025-04-21T17:50:49.000Z","dependencies_parsed_at":"2023-02-19T11:31:25.458Z","dependency_job_id":"3960a946-5bdd-4868-9157-da4a3e45b3a9","html_url":"https://github.com/open-cluster-management-io/policy-generator-plugin","commit_stats":null,"previous_names":["open-cluster-management/policy-generator-plugin"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-cluster-management-io%2Fpolicy-generator-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-cluster-management-io%2Fpolicy-generator-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-cluster-management-io%2Fpolicy-generator-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-cluster-management-io%2Fpolicy-generator-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-cluster-management-io","download_url":"https://codeload.github.com/open-cluster-management-io/policy-generator-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250573351,"owners_count":21452352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:00:41.008Z","updated_at":"2025-04-24T06:09:55.988Z","avatar_url":"https://github.com/open-cluster-management-io.png","language":"Go","funding_links":[],"categories":["Plugins"],"sub_categories":["Generators"],"readme":"# Policy Generator\n\n## Overview\n\nThe Policy Generator constructs Open Cluster Management policies from Kubernetes YAML files provided through a\nPolicyGenerator Custom Resource. The Policy Generator is a binary compiled for use as a\n[kustomize](https://kustomize.io/) exec plugin.\n\n- [Installing the Policy Generator](#installing-the-policy-generator)\n  - [Prerequisite](#prerequisite)\n  - [Install the binary](#install-the-binary)\n    - [Download a released version](#download-a-released-version)\n    - [Using `go install` (available for `v1.11.0` and higher)](#using-go-install-available-for-v1110-and-higher)\n    - [Build from source](#build-from-source)\n- [Using the Policy Generator](#using-the-policy-generator)\n  - [As a Kustomize plugin](#as-a-kustomize-plugin)\n  - [As a standalone binary](#as-a-standalone-binary)\n- [Additional Policy Generator references](#additional-policy-generator-references)\n\nFor more about Open Cluster Management and its Policy Framework:\n\n- [Open Cluster Management website](https://open-cluster-management.io/)\n- [Governance Policy Framework](https://open-cluster-management.io/getting-started/integration/policy-framework/)\n- [Policy Collection repository](https://github.com/open-cluster-management-io/policy-collection)\n\n## Install the Policy Generator\n\n### Prerequisite\n\nCreate the plugin directory (optional if using the generator without Kustomize):\n\n```bash\nmkdir -p ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator\n```\n\n**NOTE:** The default directory for Kustomize plugins is `${HOME}/.config/kustomize/plugin/`, which is used directly in\nthis readme. You can change this by exporting `KUSTOMIZE_PLUGIN_HOME` to a different path and updating the root of the\npaths used in this document.\n\n### Install the binary\n\n#### Download a released version\n\n1. Download the precompiled plugin binary from the\n   [release](https://github.com/open-cluster-management-io/policy-generator-plugin/releases) of your choice.\n\n2. Make the binary executable and move the binary to the plugin directory:\n\n   - Linux:\n\n     ```bash\n     chmod +x linux-amd64-PolicyGenerator\n     mv linux-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator\n     ```\n\n   - MacOS:\n     ```bash\n     chmod +x darwin-amd64-PolicyGenerator\n     mv darwin-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator\n     ```\n\n#### Use `go install` (available for `v1.11.0` and higher)\n\nSet the `GOBIN` to the plugin directory and specify the desired version (this command uses `latest`):\n\n```bash\nGOBIN=${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator \\\ngo install open-cluster-management.io/policy-generator-plugin/cmd/PolicyGenerator@latest\n```\n\n#### Build from source\n\n```bash\nmake build\n```\n\n**NOTE:**\n\n- This defaults to placing the binary in the Kustomize default plugin directory `${HOME}/.config/kustomize/plugin/`. You\n  can change this by exporting `KUSTOMIZE_PLUGIN_HOME` to a different path.\n- Alternatively, you can run `make build-binary` to place the binary at the root of the repository and either use it\n  directly from there or move it to the plugin directory to use with Kustomize.\n\n## Using the Policy Generator\n\n### As a Kustomize plugin\n\n1. Create a `kustomization.yaml` file that points to `PolicyGenerator` manifest(s), with any additional desired patches\n   or customizations (see [`examples/policyGenerator.yaml`](./examples/policyGenerator.yaml) for an example):\n\n   ```yaml\n   generators:\n     - path/to/generator/file.yaml\n   ```\n\n   - To read more about the `PolicyGenerator` YAML structure, see the\n     [Policy Generator reference YAML](./docs/policygenerator-reference.yaml)\n\n2. To use the plugin to generate policies, run the Kustomize build command from any directory with a\n   `kustomization.yaml` file pointing to `PolicyGenerator` manifests:\n   ```bash\n   kustomize build --enable-alpha-plugins\n   ```\n\n  **NOTE:** To enable Helm processing when passing a Kustomize directory into the generator, set\n  the environment variable `POLICY_GEN_ENABLE_HELM` to `\"true\"`. If the Helm directory is outside of the Kustomize path,\n  you may set the environment variable `POLICY_GEN_DISABLE_LOAD_RESTRICTORS` to `\"true\"`.\n\n### As a standalone binary\n\nIn order to bypass Kustomize and run the generator binary directly, change to the directory of PolicyGenerator\nmanifest(s) and run the binary with the manifest(s) as the input arguments:\n\n```bash\npath/to/PolicyGenerator \u003cpath/to/file/1\u003e ... \u003cpath/to/file/n\u003e\n```\n\nFor example:\n\n```bash\nmake build-binary # This places the binary at the root of the repo, so this is optional if it was done previously\ncd examples\n../PolicyGenerator policyGenerator.yaml\n```\n\n**NOTE:** \n- To print the trace in the case of an error, you can add the `--debug` flag to the arguments.\n- To enable Helm processing when passing a Kustomize directory into the generator, set\n  the environment variable `POLICY_GEN_ENABLE_HELM` to `\"true\"`. If the Helm directory is outside of the Kustomize path,\n  you may set the environment variable `POLICY_GEN_DISABLE_LOAD_RESTRICTORS` to `\"true\"`.\n\n## Additional Policy Generator references\n\n- [Policy Generator reference YAML](./docs/policygenerator-reference.yaml)\n- [Policy Generator technical documentation](./docs/policygenerator.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-cluster-management-io%2Fpolicy-generator-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-cluster-management-io%2Fpolicy-generator-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-cluster-management-io%2Fpolicy-generator-plugin/lists"}