This Python script annotates Kubernetes manifest files using descriptions provided by OpenAPI references.
- Automatic Annotation: Adds comments in Kubernetes manifest YAML files based on OpenAPI descriptions.
- Handling of Subresources: Recursive tracking of OpenAPI references to annotate subresources such as container specifications.
- Customizable: Ability to specify the output file and automatic creation of the output directory if necessary.
- Python 3.x
- Python library:
ruamel.yaml
(automatically installed viarequirements.txt
)
-
Clone the repository:
git clone https://github.com/your_username/kubernetes-manifest-annotator.git cd kubernetes-manifest-annotator
-
Install dependencies:
pip install -r requirements.txt
First generate the openapi.json
file:
kubectl get --raw /openapi/v2 > openapi.json
To annotate a Kubernetes manifest file, use the following command:
python annotate_manifests.py path/to/deployment.yaml [--openapi path/to/openapi.json] [--output path/to/output.yaml]
path/to/deployment.yaml
: Path to the Kubernetes manifest file you want to annotate.--openapi path/to/openapi.json
(optional): Path to the OpenAPI JSON file containing API descriptions.--output path/to/output.yaml
(optional): Path to the annotated output file. If not specified, the script will useannotated_<original_filename>.yaml
.
Example:
python annotate_manifests.py examples/deployment.yaml --openapi openapi_definitions/kubernetes.json --output examples/output/deployment_annotated.yaml
Contributions are welcome! For bugs, suggestions for improvement, or new features, please open an issue or submit a pull request.
This project is licensed under the MIT License.